diff --git a/InviTube.zip b/InviTube.zip new file mode 100644 index 0000000..48446e1 Binary files /dev/null and b/InviTube.zip differ diff --git a/background.js b/background.js index 2a9670b..fb10205 100644 --- a/background.js +++ b/background.js @@ -1,25 +1,24 @@ let tabWhitelist = []; // Einstellungen ziehen, ContentScript registrieren -browser.storage.local.get( - { - activated: true, - instance: "yewtu.be", - } -).then((storage) => { - if (storage.activated) { - activateBlocker(); - } else { - deactivateBlocker(); - } +browser.storage.local.get({ + activated: true, + instance: "yewtu.be", +}) + .then((storage) => { + if (storage.activated) { + activateBlocker(); + } else { + deactivateBlocker(); + } - registerCS(storage.instance); -}); + registerCS(storage.instance); + }); // ContentScript für aktuelle Instanz registrieren -async function registerCS(url) { - return await browser.contentScripts.register({ +function registerCS(url) { + browser.contentScripts.register({ js: [{ file: "content.js" }], matches: ["*://" + url + "/*"] }); @@ -27,7 +26,7 @@ async function registerCS(url) { // pageAction anzeigen browser.runtime.onMessage.addListener((data, sender) => { - if (data.type == "showYoutubePageAction") { + if (data === "showYoutubePageAction") { browser.pageAction.setIcon({ tabId: sender.tab.id, path: "icons/youtube.png" @@ -36,7 +35,8 @@ browser.runtime.onMessage.addListener((data, sender) => { tabId: sender.tab.id, title: "Open on YouTube" }); - } else if (data.type == "showInvidiousPageAction") { + + } else if (data === "showInvidiousPageAction") { browser.pageAction.setIcon({ tabId: sender.tab.id, path: "icons/invidious.png" @@ -126,25 +126,27 @@ browser.webRequest.onBeforeRequest.addListener(async (details) => { // URL Icon Click --> Open on YouTube/Invidious browser.pageAction.onClicked.addListener((tab) => { - browser.storage.local.get({ activated: true, instance: "yewtu.be" }).then(async (storage) => { - if (tab.url.startsWith("https://www.youtube.com")) { - browser.tabs.create({ - url: "https://" + storage.instance + "/" + tab.url.split("/")[3] - }); - } else { - let newTab = await browser.tabs.create({ - url: "https://www.youtube.com/" + tab.url.split("/")[3] - }); - if (!tabWhitelist.includes(newTab.id)) { - tabWhitelist.push(newTab.id); + browser.storage.local.get({ + activated: true, + instance: "yewtu.be" + }) + .then(async (storage) => { + if (tab.url.includes("youtube")) { + browser.tabs.create({ + url: "https://" + storage.instance + "/" + tab.url.split("/")[3] + }); + } else { + const newTab = await browser.tabs.create({ + url: "https://www.youtube.com/" + tab.url.split("/")[3] + }); + if (!tabWhitelist.includes(newTab.id)) + tabWhitelist.push(newTab.id); } - } - }); + }); }); // Close tab -> Remove from whitelist browser.tabs.onRemoved.addListener((tabId) => { - if (tabWhitelist.includes(tabId)) { + if (tabWhitelist.includes(tabId)) tabWhitelist.splice(tabWhitelist.indexOf(tabId), 1); - } }); \ No newline at end of file diff --git a/content.js b/content.js index 99859bb..ec0166f 100644 --- a/content.js +++ b/content.js @@ -1,5 +1,5 @@ if (location.href.startsWith("https://www.youtube.com")) { - browser.runtime.sendMessage({ type: "showInvidiousPageAction" }); + browser.runtime.sendMessage("showInvidiousPageAction"); } else { - browser.runtime.sendMessage({ type: "showYoutubePageAction" }); + browser.runtime.sendMessage("showYoutubePageAction"); } \ No newline at end of file diff --git a/manifest.json b/manifest.json index 5963b55..29630f3 100644 --- a/manifest.json +++ b/manifest.json @@ -2,7 +2,7 @@ "manifest_version": 2, "name": "InviTube", "author": "Indogermane", - "version": "1.1", + "version": "1.2", "description": "Redirect YouTube to Invidious.", "background": { "scripts": [ diff --git a/options/options.html b/options/options.html index c338743..4825e43 100644 --- a/options/options.html +++ b/options/options.html @@ -1,95 +1,86 @@ -
- - - - - - - - + .full-width { + width: 100%; + } + + .red-border { + border: 1px solid red; + } + + table input { + width: 100%; + } + + .mt-2 { + margin-top: 8px; + } + + .mt-3 { + margin-top: 12px; + } + + .mt-4 { + margin-top: 16px; + } + + .mt-12 { + margin-top: 48px; + } + + .rounded { + border-radius: 20px; + } + + + + + + + + + + +