Skip to content

Commit e256508

Browse files
committed
auto lock web - WIP
1 parent d689942 commit e256508

File tree

11 files changed

+1607
-102
lines changed

11 files changed

+1607
-102
lines changed

manifest.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@
1717
"permissions": [
1818
"idle",
1919
"tts",
20-
"power",
2120
"tabs",
21+
"power",
22+
"history",
2223
"storage",
2324
"cookies",
2425
"debugger",
@@ -28,6 +29,7 @@
2829
"scripting",
2930
"webRequest",
3031
"tabCapture",
32+
"pageCapture",
3133
"contextMenus",
3234
"desktopCapture",
3335
"webNavigation",

popup/index.js

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {
44
isFunction,
55
removeAccents,
66
runScriptInCurrentTab,
7-
toggleActiveScript,
7+
setActiveScript,
88
trackEvent,
99
debounce,
1010
Storage,
@@ -162,12 +162,18 @@ function createScriptButton(script, isFavorite = false) {
162162
const checkmark = document.createElement("button");
163163
checkmark.className = "checkmark tooltip";
164164
checkmark.onclick = async (e) => {
165-
let newValue = await toggleActiveScript(script.id);
166-
trackEvent(script.id + (newValue ? "-ON" : "-OFF"));
167-
newValue
168-
? script.popupScript?.onEnable?.()
169-
: script.popupScript?.onDisable?.();
170-
updateButtonChecker(script, buttonContainer, newValue);
165+
let oldVal = await isActiveScript(script.id);
166+
let newVal = !oldVal;
167+
168+
if (
169+
(newVal && (await script.popupScript?.onEnable?.()) === false) ||
170+
(!newVal && (await script.popupScript?.onDisable?.()) === false)
171+
)
172+
return;
173+
174+
setActiveScript(script.id, newVal);
175+
trackEvent(script.id + (newVal ? "-ON" : "-OFF"));
176+
updateButtonChecker(script, buttonContainer, newVal);
171177
};
172178

173179
buttonContainer.appendChild(checkmark);

0 commit comments

Comments
 (0)