0

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?

user1256960
  • 303
  • 3
  • 11

1 Answers1

2

Firefox

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.
Community
  • 1
  • 1
Rob W
  • 341,306
  • 83
  • 791
  • 678