Chrome Extension should use Web Application or Chrome App - javascript

I want to create a chrome extension and use the Sheets API to do something, so I have reviewed two tutorial.
this article
https://medium.com/swlh/oauth2-openid-chrome-extension-login-system-29285323882f
is using lauchWebAuthFlow to achieve the Authentication, but using Web Application as Application Type.
And this video,
https://www.youtube.com/watch?v=5grkEnYytF4
is using getAuthToken, but the Application Type is Chrome App.
I want to ask when to use Chrome App and when to use Web Application?
For further asking, I want to ask if I want to use my chrome extension not only in Google Chrome but at least with Microsoft Edge, which Authentication method is recommended to do, and if I am using that method, how I can use that method to use the Sheet API.
Thank you.

Related

'chrome.sockets.tcp' in a PWA?

I am creating a PWA using Nuxt and I want to use the Chrome TCP API to communicate with TCP devices directly. The API is detailed here https://developer.chrome.com/apps/sockets_tcp
I have confirmed that clients are downloading it when they access the page.
manifest.json
{
"name":"pwa-demo",
"short_name":"pwa-demo",
"description":"Test App",
"publicPath":"//_nuxt/",
"icons":[
{
"src":"/_nuxt/icons/icon_64.fj_mLYH_Zr_.png",
"sizes":"64x64",
"type":"image/png"
}
],
"start_url":"/?standalone=true",
"display":"standalone",
"background_color":"#ffffff",
"theme_color":false,
"lang":"en",
"sockets":{
"tcp":{
"connect":[
"*:8023"
]
}
}
}
However, when the PWA is run in the browser or after installation (both on desktop and Android) in all cases I get the following error trying to call a chrome.sockets.tcp API: TypeError: Cannot read property 'tcp' of undefined
The Chrome "apps" API (https://developer.chrome.com/apps) does seem to suggest that it is meant to be done using Cordova but I figured that that suggestion was old (there's other content on the page from 2014) and that once a PWA is installed there shouldn't be a functional difference between an installed Cordova app and a new installed PWA. They're both wrappers around a Chrome WebView (except of course Cordova can expose more native APIs).
I am guessing that the chrome.sockets.tcp API is actually exposed through the Cordova wrapper and not Chrome itself, but I have not found anything that confirms this. Google has publicly expressed that they want PWAs to replace Chrome Apps so one would hope that the API was moved into Chrome itself. There seems to be a lot of people confused about whether it can be used by Chrome extensions too.
Is my manifest wrong? Or can someone confirm that this API is not usable by PWAs?
Chrome Apps are specialized apps that are distributed through the Chrome Web Store. Think browser extensions but more app like. Websites do not have access to the privileged APIs available to Chrome Apps.
Also note that Chrome Apps are being retired for everything other than Chrome OS.

Blocking websites on a web app using javascript

I'm currently developing a web app that allows users to add a list of websites that they want to block i.e. preventing them from accessing the website from their browser.
Ideally I want to be able to block websites on every browser but this is difficult, so I narrowed my research to just Chrome for now. I came across the chrome.webRequest api which seems promising but it specifically says its for chrome extensions and am unsure if it would work for my web app.
Can anyone point me in the right direction for blocking websites on a web app, ideally using javascript. Any help is much appreciated!!
EDIT:
1) I forgot to mention that I'm using firebase for my backend.
2) People have been saying that I can't block websites outside the web apps scope, if I instead used electron to make the web app a desktop application would it then be possible?
Firstly you have a database containing URL of blocked websites. URLs are modified using your web app. That's one part. Now your problem is how to make the browser work with your database.
The only possible way for you to share blocked URLs with the browser is via API. You must have API that can communicate outside your web app.
Now browsers such as chrome/firefox give users the power to make changes inside and outside the dom. For chrome, you have chrome extension where Google provides API so the users can manipulate actions outsides regular actions such as manipulating dom. An example I can give that is closely related to your subject matter, which is an action activated before/after a user enters URL on the search box and for that, we use the following API from https://developer.chrome.com/extensions/webRequest
And it's same for Firefox.

Access Chrome API in service worker

I'm trying to show the chrome rich notifications from my ServiceWorker but apparently I cannot access chrome api.
Is there a specific reason why this is not possible or is there a work around this?
Right now I am displaying notifications using ServiceWorker API by calling ServiceWorkerRegistration.showNotification() but this API can only do classic simple notifications.
That API belongs to Chrome Apps, it is not meant for website.
Indeed the documentation you linked is under the section Apps.

Chrome Application - Interract with a tab [duplicate]

I need to combine functionality available only in a Chrome packaged app (access to syncFileSystem) and functionality available only in a Chrome extension (injecting a script into a 3rd party website).
It seems that neither a packaged app nor an extension can achieve both these things, so I'm now considering trying to achieve what I'm after with a separate packaged app and extension communicating.
I see that Chrome's documentation explains how two extensions can communicate via chrome.runtime.onMessageExternal.addListener and chrome.runtime.sendMessage, but nothing about packaged apps and extensions communicating.
Does anyone know if this is allowed? Is there any documentation, or a working example out there?
Yes, that is possible. The code sample in the documentation you linked works for any combination of app and extension.
The extension documentation for chrome.runtime.sendMessage says:
Sends a single message to onMessage event listeners within the extension (or another extension/app).
Messaging works the same in both extensions and apps, and they seem to be fully compatible; simply use the ID for the destination extension or app. If you look at the docs for the app version of chrome.runtime.sendMessage, you'll see that it is identical to the extension version.

How to call run/invoke a local application inside google chrome

In out local intranet, we have a website that will be only used inside our intranet.
Before we use it in internet explorer, there are lots of page using JavaScript + ActiveX to open local applications, like Microsoft excel etc.
Now we want to shift to using Google Chrome, but we don't know to call these applications inside Chrome.
Is it possible to do in Google Chrome? Or is there any extensions of Chrome can do it?
You can do it with NPAPI Plugins: "You can bundle an NPAPI plugin with your extension, allowing you to call into native binary code from JavaScript."
I have seen the new desktop notification from google, that does work really outside the browser, so you can have look on its concepts and try to mimic its techniques!
You could check out Native Client SDK for Google Chrome.

Categories