diff --git a/.gitignore b/.gitignore index 44ce34d..7f9db6a 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ web-ext-artifacts +node_modules diff --git a/background.js b/background.js index 0b26721..94efe11 100644 --- a/background.js +++ b/background.js @@ -1,4 +1,4 @@ -trektor.runtime.onMessage.addListener(async (msg) => { +browser.runtime.onMessage.addListener(async (msg) => { switch (msg.action) { case 'track': await track(...msg.args); diff --git a/content_script.js b/content_script.js index d1009c3..755404b 100644 --- a/content_script.js +++ b/content_script.js @@ -33,27 +33,29 @@ async function addButton() { trackButton.addEventListener("click", async () => { trackButtonIcon.classList.add("trektor-state-loading"); - const response = await trektor.runtime.sendMessage({ + try { + const response = await browser.runtime.sendMessage({ action: "track", args: [window.location.pathname.split("/", 3)[2]], - }); - trackButtonIcon.classList.remove("trektor-state-loading"); - - if (response) { - window.alert(response); - } else { + }); trackButtonIcon.classList.replace("icon-clock", "icon-check-circle"); window.setTimeout(() => trackButtonIcon.classList.replace("icon-check-circle", "icon-clock"), 2000); + } catch (err) { + window.alert(err); + } finally { + trackButtonIcon.classList.remove("trektor-state-loading"); } }); addButton.addEventListener("click", async () => { - const response = await trektor.runtime.sendMessage({ - action: "addTask", - args: [window.location.pathname.split("/", 3)[2]], - }); - - if (response) window.alert(response); + try { + const response = await browser.runtime.sendMessage({ + action: "addTask", + args: [window.location.pathname.split("/", 3)[2]], + }); + } catch (err) { + window.alert(err); + } }); } diff --git a/manifest.json b/manifest.json index 3bdb265..451f86f 100644 --- a/manifest.json +++ b/manifest.json @@ -2,7 +2,7 @@ "manifest_version": 2, "name": "Trektor", "description": "Browser-Extension zum automatischen Anlegen von Toggl tracking tasks", - "version": "0.0.3", + "version": "0.0.10", "browser_specific_settings": { "gecko": { "id": "trektor@aboutsource.net" @@ -17,7 +17,7 @@ "https://trello.com/*" ], "js": [ - "trektor.js", + "vendor/browser-polyfill.js", "content_script.js" ], "css": [ @@ -27,6 +27,7 @@ ], "background": { "scripts": [ + "vendor/browser-polyfill.js", "trektor.js", "background.js" ] diff --git a/options/index.html b/options/index.html index 990acb3..3a45c93 100644 --- a/options/index.html +++ b/options/index.html @@ -17,7 +17,7 @@
- + Trello Token @@ -29,7 +29,7 @@ - +