How can I detect if a Chrome Extension has been enabled (after having been disabled)
659 views
Skip to first unread message
mo
unread,
Nov 2, 2011, 4:25:32 AM11/2/11
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Chromium-extensions
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;
}
Ben
unread,
Nov 2, 2011, 9:14:10 PM11/2/11
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to mo, Chromium-extensions
You should extend that test a bit:
if (!localStorage["isInstalled"]) { onInstall(); localStorage["isInstalled"] = 1;
} else { /* code to run when extension is re-enabled */ onEnable();
mo
unread,
Nov 2, 2011, 10:24:27 PM11/2/11
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Chromium-extensions
Hi Ben,
Unfortunately, onEnable() will also run when the browser is closed and
reopened in your code.
I'm wondering if it's possible to only run onEnable after the
extension has been disabled and then re-enabled again.
mo
unread,
Nov 2, 2011, 10:24:56 PM11/2/11
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Chromium-extensions
I'm planning on building easier enable/disable functionality within my
app itself - independent of chrome enable/disable functionality, you
might also be interested in this too though it is more work.