Skip to content

Commit

Permalink
multi-tabs: show error only if the stored url is open
Browse files Browse the repository at this point in the history
  • Loading branch information
chdinesh1089 committed Oct 6, 2020
1 parent ff97737 commit b6858a8
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -207,12 +207,19 @@ getPageURL().then((url) => {
} else {
browser.storage.local.get("url").then((storedURL) => {
storedURL = storedURL.url;
if (storedURL && storedURL !== url) {
const content = document.getElementById("buttons-div");
content.removeAttribute("buttons-div");
content.setAttribute("id", "single-instance-err");
content.innerHTML = `Supports only one tab now. Open the extension in <p id="stored-url">${storedURL}</p> and click "Reset" to use here`;
}
browser.tabs.query({}).then((tabs) => {
const urls = tabs.map((tab) => tab.url);
if (storedURL && storedURL !== url) {
if (!urls.includes(storedURL)) {
removeCurrentURLfromStorage();
return;
}
const content = document.getElementById("buttons-div");
content.removeAttribute("buttons-div");
content.setAttribute("id", "single-instance-err");
content.innerHTML = `Supports only one tab now. Open the extension in <p id="stored-url">${storedURL}</p> and click "Reset" to use here`;
}
});
});
}
});
Expand Down

0 comments on commit b6858a8

Please sign in to comment.