-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbackgroundsd.js
30 lines (29 loc) · 1007 Bytes
/
backgroundsd.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
let isPanicModeActive = false;
let originalWindowId = null;
let safeWindowId = null;
chrome.commands.onCommand.addListener(function (command) {
if (command === "toggle-panic") {
if (isPanicModeActive) {
// Close the safe window and show the original window
if (safeWindowId) {
chrome.windows.remove(safeWindowId);
safeWindowId = null;
}
if (originalWindowId) {
chrome.windows.update(originalWindowId, { focused: true });
originalWindowId = null;
}
isPanicModeActive = false;
} else {
// Hide the original window and open the safe website in a new window
chrome.windows.getCurrent(function (currentWindow) {
originalWindowId = currentWindow.id;
chrome.windows.update(originalWindowId, { state: "minimized" });
chrome.windows.create({ url: "https://github.com" }, function (newWindow) {
safeWindowId = newWindow.id;
});
});
isPanicModeActive = true;
}
}
});