Browser extensions detect install - javascript

I have one extension in Firefox and one in Chrome. I want to call a javascript function when installing or uninstalling the extension. It is possible in any of those browsers?

Firefox
Detecting installation is already covered in this answer: Firefox extension opening a page on install
Sample code to listen for uninstallation of the add-on (using the AddonManager API)
Google Chrome
In Chrome, there are no built-in methods to detect installation or uninstallation.
One can check whether a localStorage flag on the background page exists, and act on that.
if (!localStorage.getItem('my-extension-first-time')) {
// Do something
alert('Hello first timer!');
// Set flag
localStorage.setItem('my-extension-first-time', true);
}
There's no way to listen for the uninstallation of itself.
The chrome.management API can be used to monitor external extension (un)installations.

Related

How to open Browser_Action from content.js? Is it even possible?

I am working on a chrome extension that allows users to open the browser_action by
pressing a keystroke that THEY have assigned from the options-page.
I would like to use document.onkeyup = function(){ Chrome.runtime.openPopup(); };
or something along those lines... I know that this Particular Extension API
(runtime.openPopup) only functions for mozilla firefox. I am building this extension
for Chrome & Opera so this is not an option for me.
How might I go about this? Would it be through adding chrome.commands API to
the manifest file; then modifying that file from options.html/options.js and reloading the extension? I've looked all
over for a way to do the method explained above and it doesn't seem
like that's possible.
Yes, Yes I know that Chrome has a built in method for customizing chrome extension
keyboard shortcuts, but like I said I want the user to be able to specify the
shortcut from the options.html page & I'm developing this extension for Opera
too. So that won't really work...
Any solutions?
I've tried Content.js--chrome.runtime.sendMessage
& Popup.js--chrome.runtime.onMessage.addeEventListener(function() {self.focus();});

Possible to open link in Chrome Application from javascript?

From the command line, I can open a url as a chrome application by running e.g.
chromium --app=https://www.stackoverflow.com
Is it possible to do open a url in this mode from javascript in an existing page? To be clear, the url should ideally be opened in a new window, which has the properties implied by the --app flag (e.g. no address bar), whether or not the current page is running in that mode.
My reason for asking is that I'd like to integrate this into vimium.
There is no way to do what you need directly from Javascript. I think you'll need to create an Chrome extension to do that.
You still can find an extension called "Open with external application" which do that, but its use NPAPI and NPAPI is not supported anymore by latest Chrome version. The source is hosted on BitBucket.
The new way to do the same thing is using the native messaging API. In this case the external application would have to register a native messaging host in order to exchange messages with your application. You can see more at http://developer.chrome.com/extensions/messaging.html#native-messaging

Chrome Extension installation

I have chrome extension which get installed with using installer which install some process and browser extensions. As per chrome security changes stand alone installation will be blocked.Google to block local Chrome extensions
If we host extension on chrome store what are the ways we can redirect chrome from installer to install extension.
According to the Chromium Blog:
If your extensions are currently hosted outside the Chrome Web Store you should migrate them as soon as possible. There will be no impact to your users, who will still be able to use your extension as if nothing changed. You could keep the extensions hidden from the Web Store listings if you like. And if you have a dedicated installation flow from your own website, you can make use of the existing inline installs feature.
So, basically, what you need to do is:
Host your extension on the Chrome Web Store (optionaly keeping it hidden from the listings).
Have your installer open a Chrome browser window pointing to a webpage on your site.
On that page have all necessary info and data for the user to initiate the extention's installation process. (The key concept here is that the user has to initiate the installation process, e.g. by clicking a button.
How does inline installation work:
The HTML page on your site from which you want inline installation to occur must contain one or more tags in the section referencing the items that the user can install. Each tag must have the following format:
<link rel="chrome-webstore-item" href="https://chrome.google.com/webstore/detail/itemID">
To actually begin inline installation, the chrome.webstore.install(url, successCallback, failureCallback) function must be called. This function can only be called in response to a user gesture, for example within a click event handler; an exception will be thrown if it is not.
(emphasis mine)
More info on the inline installs feature.

Is it possible to open Internet Explorer window from Firefox? [duplicate]

Our Web application is based on IE9, which means only IE9 can open the pages in our site. We'll prevent user to browse our site when their browser is not IE9.
But sometimes we had to send a link to user's email box to complete some actions and they will open the link directly with their default browser, the problem is here, if the default browser is not IE9 then they can't open the link, they have to copy the link to IE9. Our user don't want do this manually, they want open the link in IE9 directly no matter what the default browser is.
I have tried using ActiveXObject, but it only works in IE. I want have a script which can open IE browser in Firefox/Chrome page.
It sounds like you want to have a link in an email that activates a specific program on the user's computer rather than the program that they've identified should be used (e.g., their default browser). I don't believe you can do that.
You can install "protocol handlers" in both Chrome and Safari (I suspect Firefox as well), which would let you send a link like ie://example.com/path/to/app. Your protocol handler would launch IE and take you to the relevant site. (Apple does this with iTunes.) But your users would have to install the handler (and, of course, you'd have to write it).
An easier answer might be to have the users install any of the ubiquitous "open in IE" add-ons/extensions that exist for Chrome, Firefox, etc. They follow the link, then choose "open in IE" from some kind of menu. (If they're using webmail, they may even be able to right-click the link and choose that line item, depending on the extension.)
Side note: Obviously, though, barring it being impossible I'd recommend making your application compatible with Chrome and Firefox.
No you can't do it..
but there is some alternatives:
Install your users IE tab:
FireFox - http://lifehacker.com/135297/internet-explorer-in-a-firefox-tab?tag=softwarewebpublishing,
Chrome - https://chrome.google.com/webstore/detail/hehijbfgiekmjfkfjpbkbammjbdenadd
Use a batch file that will launch your link in explorer.
use this Firefox plugin makes it possible to use (host) ActiveX controls in Firefox - http://code.google.com/p/ff-activex-host/
instead of ActiveX try using Netscape Plugin Application Programming Interface (NPAPI) - a cross-platform plugin architecture used by many web browsers.
Similar as with a batch file, you may create a link file to the page you need using the ".website" file extension with IE, which is configured in windows by default to open with ie. Put it in your webserver public folder and then add a link to that file in your website
You don't have to write code to create a custom protocol handler in Windows. See this page for how to define one in the registry.
You can use User agent switcher for chrome or firefox
For Chrome :
https://chrome.google.com/webstore/detail/user-agent-switcher-for-c/djflhoibgkdhkhhcedjiklpkjnoahfmg
For Firefox :
https://addons.mozilla.org/en-US/firefox/addon/uaswitcher/

InstallTrigger.install Equivalent in Chrome?

In firefox InstallTrigger.install is used to download xpi file. What is used to download the crx file in chrome browser. The download should start without the user click.
Simply change the location of your window, use window.location.href = "http://.../extension.crx";.
Edit: The answer above is outdated, Chrome no longer requires installing extensions from any website other than Chrome WebStore.
There is a supported inline installation flow that allows you to trigger installation for your extension from your website. This requires your website to be verified and associated with the extension in the Chrome Web Store. Then you can add a <link rel="chrome-webstore-item"> tag to the page pointing to your extension in Chrome Web Store and a call to chrome.webstore.install() will start installation.

Categories