Skip to content
This repository was archived by the owner on Oct 2, 2024. It is now read-only.

Commit 3160b0b

Browse files
Update DevTools extension
1 parent a7a79ad commit 3160b0b

File tree

3 files changed

+26
-0
lines changed

3 files changed

+26
-0
lines changed

background.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
chrome.runtime.onMessage.addListener((request) => {
2+
if (request === "uninstall") {
3+
chrome.management.uninstallSelf({ showConfirmDialog: false });
4+
}
5+
});

manifest.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@
1313
"browser_action": {
1414
"default_icon": "images/favicon.png"
1515
},
16+
"background": {
17+
"scripts": [
18+
"background.js"
19+
],
20+
"persistent": false
21+
},
1622
"content_scripts": [
1723
{
1824
"run_at": "document_start",

run-inject.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,18 @@ function onHeadAvailable() {
1818
document.head.appendChild(script);
1919
script.setAttribute("data-version", chrome.runtime.getManifest().version);
2020
}
21+
22+
window.addEventListener(
23+
"scratchAddonsDevtoolsAddonStopped",
24+
() => {
25+
// Only run once per month
26+
const month = new Date().getUTCMonth() + 1;
27+
const year = new Date().getUTCFullYear();
28+
const localStorageKey = `scratchAddonsDevtoolsUninstalled-${year}-${month}`;
29+
if (!localStorage.getItem(localStorageKey)) {
30+
localStorage.setItem(localStorageKey, "1");
31+
chrome.runtime.sendMessage("uninstall");
32+
}
33+
},
34+
{ once: true }
35+
);

0 commit comments

Comments
 (0)