aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorRahiel Kasim <rahielkasim@gmail.com>2018-04-17 15:07:06 +0200
committerRahiel Kasim <rahielkasim@gmail.com>2018-04-17 15:07:06 +0200
commit6b75f9c7c795c931cd5bef2944c0a484f505ed27 (patch)
treed32b8a8213a56c594a6e55687c109d7182410733
parent680797fedfc10fe9609bd5b3b839aaad40877dd9 (diff)
close popup after opening a new tab
-rw-r--r--src/popup.js22
1 files changed, 19 insertions, 3 deletions
diff --git a/src/popup.js b/src/popup.js
index ac60f4a..bd47b95 100644
--- a/src/popup.js
+++ b/src/popup.js
@@ -11,6 +11,7 @@ function requestOnline(services) {
services: services,
url: url,
});
+ closePopup();
});
}
@@ -24,6 +25,7 @@ function requestMHTML() {
label: "saveLocal",
tabId: tab.id,
});
+ closePopup();
});
}
@@ -35,6 +37,7 @@ function requestArchiveNow() {
tabId: tab.id,
url: tab.url,
});
+ closePopup();
});
}
@@ -66,8 +69,8 @@ function showElements() {
function addArchiveLink(url) {
let e = document.createElement("li");
- e.innerHTML = `<a href="${url}">${url}</a>`;
- e.onclick = function () { chrome.tabs.create({url: url}); };
+ e.innerHTML = `<a>${url}</a>`;
+ e.onclick = openURL(url);
document.getElementById("archiveList").appendChild(e);
showBookmarkSection = true;
}
@@ -80,11 +83,24 @@ function showElements() {
}
showElements();
+function closePopup() {
+ // Popups are not automatically closed after opening new tabs in Firefox.
+ window.close();
+}
+
+function openURL(url) {
+ function f() {
+ chrome.tabs.create({url: url});
+ closePopup();
+ }
+ return f;
+}
+
function showVersion() {
const manifest = chrome.runtime.getManifest();
const version = manifest.version;
const url = manifest.homepage_url;
document.getElementById("version").textContent = version;
- document.getElementsByTagName("footer")[0].onclick = function () { chrome.tabs.create({url: url}); };
+ document.getElementsByTagName("footer")[0].onclick = openURL(url);
}
showVersion();