Can a chrome extension be opened when requesting specific external protocol? - javascript

I want to write a chrome extension that is triggered when the browser redirect to a specific external protocol: myApp://...
I googled a bit and didn't find an easy meta-data way to do so.
is there a way to define it in the manifest?
I want the extension to open a popup then, and I'll wait for it in my automation testing.

You can, in theory, use a protocol handler with navigator.registerProtocolHandler, but there are limitations:
Custom protocols must start with web+ in Chrome, e.g. web+myApp:
There is no way to declare this in a manifest; according to this feature request to add that possibility, currently it will pop up an allow/deny infobar for the user.
In any case, opening a popup programmatically is impossible. At most you can open an extension page in a tab.

Related

Detect supported protocols in browser

I have a web page, where i would like to add links using a custom protocol, to open in my desktop application. For example "myprotocol:www.mytestpage.com".
My issue is, how do I detect, using javascript, if the user has registered my protocol?
If for example I use the link above in firefox, withouth having the protocol registered, I am just taken to an error page. Instead I want to show a dialog telling the user to download my application.
As far as I know you cannot tell whether the protocol has been registered or not.
This answer should give you a step in the right direction. https://stackoverflow.com/a/24129863/7326037

Can a Chrome extension act as a web app in place of a website?

I'm trying to develop a Chrome extension that is supposed to completely replace a specific website's pages with a new UI. In other words, when the user visits said website, the extension should "intercept" it seamlessly and display the new "app" (preserving the URL and without opening a new tab or window). I currently use a content script to manipulate the DOM, but it's too messy.
Chrome apps such as Google Docs achieve the same goal through URL handlers, but they're not an option since they're now deprecated.
Currently, I'm aware of two options:
Intercept the URL and redirect it to an extension URL. I want the URL to be preserved.
Use a content script to stop the page from loading at document_start (using window.stop()) and then "inject" the new app. Apparently, that works, but it sounds quite hacky and prone to unexpected glitches.
What I'd like to know:
Is the second approach good enough? What limitations and other issues will I face if I use it?
Is there any other approach that is at least as good (and preferably designed for this purpose)?
You can't open a chrome app in a tab, only in a window. I don't think they have content scripts either.
Also, chrome apps are now only available on chrome os when you publish it for the first time (existing chrome apps work for any os).
To solve your question, you could use an extension with content scripts and just open up an iframe fullscreen so the url is preserved in the omnibox and it could have the page you want in the iframe as the page that would be in the app.
Content handlers are meant for opening a special protocol url to do something like send an email, etc. Examples would be like tel://, sms://, mailto:, etc.
So you would not want this. Also they aren't that noticable when approving to handle the protocol.

Open devTools in chrome, and select "Network", click "XHR", and there are extra information in any page [duplicate]

When I'm viewing the downloaded resources for a page in the Chrome web inspector, I also see the HTML/JS/CSS requested by certain extensions.
In the example above, indicator.html, indicator.js and indicator.css are actually part of the Readability Chrome extension, not part of my app.
This isn't too big a deal in this particular situation, but on a more complex page and with several extensions installed, it can get quite crowded in there!
I was wondering if there was a way to filter out any extension-related resources from this list (i.e. any requests using the chrome-extension:// protocol).
Does anyone know how I could achieve this?
Not quite the solution I was after (I'd have preferred a global setting), but there is now a way to filter out requests from extensions, as mentioned by a commenter on the issue I originally opened.
In the network tab filter box, enter the string -scheme:chrome-extension (as shown below):
This is case-sensitive, so make sure it's lowercase. Doing this will hide all resources which were requested by extensions.
Just enter "-f" in Network field
Was having the same question when my extension adds a lot of noise in the network tab.
Some extensions also fire a lot of data like data:text/image etc, you can append more filter with - like:
-scheme:chrome-extension -scheme:data
Another way to get the http/https requests is to just use scheme:https without - because the resources that extensions request are usually from their local bundle:
scheme:https
An Incognito Window, can be configured to include or exclude extensions from the extensions page of Chrome settings.
One alternative is to go to "Network Request blocking" tab and add "chrome-extension:" to the list, thus extension requests will be blocked and coloured red so it's easy to visually filter them out.
you can simply enable this option and requests from extension will be group.
Update: It can only group requests that create by the extension that draw iframe, such as cVim

Detect if user have my Chrome extension installed?

I started to work on a very cool Chrome extension and I ran into a little problem.
I want to allow my user to share a link. By sharing this link, other users can get some information with my extension.
The problem is when a user click on the shared link, I want to check if my Chrome extension is installed on his browser. If it does - great, else - I want to redirect him to download my extension.
Any ideas how to?
One possibility is to have your extension run a content script on all sites* and add a listener for click events on document. It would check event.target to make sure it's a link and has a particular prefix, and if it does, it would call the preventDefault method of its parameter and do its stuff. For users without your extension, the link would of course work like any other.
*This causes Chrome to warn your potential users about this when they install your extension; read Permission Warnings for more information.
Make the extension add an invisible element to the DOM of every page that it loads, marking it with a unique ID. When the user clicks on that link, run some javascript to check for that element -- if it doesn't exist, then you know the extension hasn't been installed.
I think you should be able to set/modify headers in the HTTP requests (as of Chrome 17?). Adding a header to requests would mean you can detect the presence of the extension on the server side.
This is fairly unintrusive. Many extensions/plugins have historically modified the User-Agent header.

javascript to open a firefox extension

I try to open a new tab of Firefox extension (URL starts like chrome://xxx/content) in a web page.
I have tried window.open().location='chrome://xxx/content';, but I always got a new tab like http://chrome://xxx/content.
So the question is whether there is a solution to open the Firefox extension in web-page JavaScript.
If the answer is yes, how to realize it?
The answer is "no". A web page is not allowed to open browser/extension user interface elements, for security reasons.
Now the web page could notify the extension that a particular extension page needs opening: https://developer.mozilla.org/en/Code_snippets/Interaction_between_privileged_and_non-privileged_pages. But given that your question doesn't provide any details on what you are trying to achieve it isn't clear whether this is a viable approach for you.

Categories