M manifest.json => manifest.json +1 -1
@@ 2,7 2,7 @@
"manifest_version": 3,
"name": "Beaver's Dam",
"description": "Base Level Extension",
- "version": "0.2",
+ "version": "0.2.1",
"permissions": ["storage", "tabs"],
"action": {
"default_popup": "popup/popup.html"
M => +6 -7
@@ 6,24 6,20 @@ const openJournal = () => {
};
const toggleDammed = (hostname) => {
const toggleDammed = (hostname, tabId) => {
chrome.storage.sync.get(
{ dammed: [] },
).then((items) => {
let newText;
let index = items.dammed.indexOf(hostname);
if (index === -1) {
items.dammed.push(hostname);
newText = `Undam ${hostname}`;
} else {
items.dammed.splice(index, 1);
newText = `Dam ${hostname}`;
}
chrome.storage.sync.set(
{ dammed: items.dammed }
).then(() => {
// TODO: reload page instead of changing text
document.getElementById("toggle-dammed").textContent = newText;
chrome.tabs.reload(tabId).then(window.close);
});
});
};
@@ 43,7 39,10 @@ chrome.tabs.query({ active: true}).then(([tab]) => {
let currentURL = new URL(tab.url);
let host = currentURL.hostname;
let toggleDammedButton= document.getElementById("toggle-dammed");
toggleDammedButton.addEventListener("click", () => toggleDammed(host));
toggleDammedButton.addEventListener(
"click",
() => toggleDammed(host, tab.id),
);
// Set correct initial button text
chrome.storage.sync.get(
{ dammed: [] },
M todo => todo +0 -2
@@ 1,5 1,3 @@
-reload page instead of changing text when toggling damming in popup.js
-
programmatically modify matching pages in background.js?
Min word count