-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpopup.js
26 lines (23 loc) · 1.02 KB
/
popup.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
document.getElementById("redirect").addEventListener("click", function () {
chrome.tabs.query({ active: true, currentWindow: true }, function (tabs) {
let currentTab = tabs[0];
chrome.runtime.sendMessage({ action: "redirectCurrent", tab: currentTab });
});
});
document.getElementById("openInTab").addEventListener("click", function () {
chrome.tabs.query({ active: true, currentWindow: true }, function (tabs) {
let currentTab = tabs[0];
chrome.runtime.sendMessage({ action: "openInNewTab", tab: currentTab });
});
});
let checkbox = document.getElementById("autoRedirect");
checkbox.addEventListener("change", function () {
chrome.storage.local.set({ autoRedirect: checkbox.checked });
});
// Fetching the saved preference when popup is opened
chrome.storage.local.get("autoRedirect", function (data) {
// Check if data and the autoRedirect key are not undefined
if (data && typeof data.autoRedirect !== 'undefined') {
checkbox.checked = data.autoRedirect;
}
});