Let's say a user disables my extension and then later enables it.
How can I run a function when the extension gets re-enabled?
I tried doing something akin to running a function on-extension-install, using localStorage, but it does not appear to work for this on-extension-reenabled case because localStorage doesn't get cleared for the background-page when it is disabled.
if (!localStorage["isInstalled"]) {
onInstall();
localStorage["isInstalled"] = 1;
}
A researcher has found a way to generate a fingerprintof your device from your installed Google Chrome extensions, and then use that fingerprint to track you online. Fingerprinting is a way of figuring out what makes your device unique and then using that to identify you as you move around the internet.
An extension on its own can't monitor when it gets disabled. You'd need a second extension to monitor this.
As a slight alternative, you could use sessionStorage["isInstalled"] = 1;
, which would get cleared if the extension was disabled, but this would also be cleared if the user exited Chrome.
Have a look at the management API, which lets you respond to events like onEnabled
, firing when an app or extension has been enabled.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With