Fixed getting query urls

This commit is contained in:
Nicolai Ort 2021-08-14 15:32:03 +02:00
parent e00df8d0fc
commit 06fa44f2bf
Signed by: niggl
GPG Key ID: 13AFA55AF62F269F
2 changed files with 26 additions and 22 deletions

View File

@ -14,10 +14,12 @@ clipboard.on('success', function (e) {
document.getElementById("create").onclick = createUrl;
// Calls the api to create a new short url
function createUrl() {
shorturl = {
target: window.location.href,
chrome.tabs.query({ active: true, lastFocusedWindow: true }, tabs => {
let shorturl = {
target: tabs[0].url,
shortcode: document.getElementById("shortcode").value
};
if (shorturl.shortcode == "" | !shorturl.shortcode) {
delete shorturl.shortcode;
}
@ -37,6 +39,8 @@ function createUrl() {
document.getElementById("create").classList.add("hidden");
document.getElementById("reset").classList.remove("hidden");
});
});
}
document.getElementById("reset").onclick = reset;

View File

@ -5,7 +5,7 @@
"description": "A simple url shortener",
"short_name": "LinkyLinky",
"permissions": [
"activeTab",
"tabs",
"notifications"
],
"browser_action": {