diff options
Diffstat (limited to 'src/pages')
-rw-r--r-- | src/pages/background/background.js | 1 | ||||
-rw-r--r-- | src/pages/popup/popup.ejs | 6 | ||||
-rw-r--r-- | src/pages/popup/popup.html | 12 | ||||
-rw-r--r-- | src/pages/popup/popup.js | 31 | ||||
-rw-r--r-- | src/pages/popup/style.css | 40 |
5 files changed, 85 insertions, 5 deletions
diff --git a/src/pages/background/background.js b/src/pages/background/background.js index d252e580..dd8f1715 100644 --- a/src/pages/background/background.js +++ b/src/pages/background/background.js @@ -232,7 +232,6 @@ browser.contextMenus.onClicked.addListener((info, tab) => { } } case "redirectLink": - console.log(info.linkUrl) const tmpUrl = new URL(info.linkUrl) const newUrl = servicesHelper.redirect(tmpUrl, "main_frame", null, true) if (newUrl) browser.tabs.create({ url: newUrl }) diff --git a/src/pages/popup/popup.ejs b/src/pages/popup/popup.ejs index e862e0cb..e6cc6fca 100644 --- a/src/pages/popup/popup.ejs +++ b/src/pages/popup/popup.ejs @@ -8,6 +8,12 @@ </head> <body dir="auto"> <div class="current_site"> + <div class="some-block" id="instance-div"><a class="title prevent"> + <%- include('src/assets/images/instance-icon.svg', {services: services}) -%> + <h4 id="instance"></h4> + </a> + <span id="end"><input type="checkbox" id="instance-enabled"/></span> + </div> <%- include('src/pages/widgets/switches', {services: services}) -%> <div id="current_site_divider"> <hr> diff --git a/src/pages/popup/popup.html b/src/pages/popup/popup.html index 2dcc12bc..6dc48478 100644 --- a/src/pages/popup/popup.html +++ b/src/pages/popup/popup.html @@ -8,6 +8,14 @@ </head> <body dir="auto"> <div class="current_site"> + <div class="some-block" id="instance-div"><a class="title prevent"> + <svg xmlns="http://www.w3.org/2000/svg" enable-background="new 0 0 24 24" height="26px" viewBox="0 0 24 24" width="26px" fill="currentColor"> + <path d="M11.99 2C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zm6.93 6h-2.95c-.32-1.25-.78-2.45-1.38-3.56 1.84.63 3.37 1.91 4.33 3.56zM12 4.04c.83 1.2 1.48 2.53 1.91 3.96h-3.82c.43-1.43 1.08-2.76 1.91-3.96zM4.26 14C4.1 13.36 4 12.69 4 12s.1-1.36.26-2h3.38c-.08.66-.14 1.32-.14 2 0 .68.06 1.34.14 2H4.26zm.82 2h2.95c.32 1.25.78 2.45 1.38 3.56-1.84-.63-3.37-1.9-4.33-3.56zm2.95-8H5.08c.96-1.66 2.49-2.93 4.33-3.56C8.81 5.55 8.35 6.75 8.03 8zM12 19.96c-.83-1.2-1.48-2.53-1.91-3.96h3.82c-.43 1.43-1.08 2.76-1.91 3.96zM14.34 14H9.66c-.09-.66-.16-1.32-.16-2 0-.68.07-1.35.16-2h4.68c.09.65.16 1.32.16 2 0 .68-.07 1.34-.16 2zm.25 5.56c.6-1.11 1.06-2.31 1.38-3.56h2.95c-.96 1.65-2.49 2.93-4.33 3.56zM16.36 14c.08-.66.14-1.32.14-2 0-.68-.06-1.34-.14-2h3.38c.16.64.26 1.31.26 2s-.1 1.36-.26 2h-3.38z"></path> +</svg> + <h4 id="instance"></h4> + </a> + <span id="end"><input type="checkbox" id="instance-enabled"/></span> + </div> <div class="youtube some-block"><a class="title" href="https://youtube.com"> <img src="../../assets/images/youtube-icon.png"/> <h4 data-localise="__MSG_youtube__">Youtube</h4></a> @@ -78,7 +86,7 @@ <h4 data-localise="__MSG_fandom__">Fandom</h4></a> <input class="fandom-enabled" type="checkbox"/> </div> -<div class="peertube some-block"><a class="title" href="https://search.joinpeertube.org"> +<div class="peertube some-block"><a class="title" href="https://joinpeertube.org"> <img src="../../assets/images/peertube-icon.svg"/> <h4 data-localise="__MSG_peertube__">PeerTube</h4></a> <input class="peertube-enabled" type="checkbox"/> @@ -196,7 +204,7 @@ <h4 data-localise="__MSG_fandom__">Fandom</h4></a> <input class="fandom-enabled" type="checkbox"/> </div> -<div class="peertube some-block"><a class="title" href="https://search.joinpeertube.org"> +<div class="peertube some-block"><a class="title" href="https://joinpeertube.org"> <img src="../../assets/images/peertube-icon.svg"/> <h4 data-localise="__MSG_peertube__">PeerTube</h4></a> <input class="peertube-enabled" type="checkbox"/> diff --git a/src/pages/popup/popup.js b/src/pages/popup/popup.js index a4b73093..78e50004 100644 --- a/src/pages/popup/popup.js +++ b/src/pages/popup/popup.js @@ -2,7 +2,6 @@ window.browser = window.browser || window.chrome import utils from "../../assets/javascripts/utils.js" -// import generalHelper from "../../assets/javascripts/general.js" import serviceHelper from "../../assets/javascripts/services.js" let config, @@ -40,6 +39,7 @@ const currSite = document.getElementsByClassName("current_site")[0] function setDivs() { return new Promise(resolve => { + divs.instance = document.getElementById("instance") for (const service in config.services) { divs[service] = {} divs[service].toggle = {} @@ -56,8 +56,9 @@ await setDivs() const currentSiteIsFrontend = document.getElementById("current_site_divider") -browser.storage.local.get("options", r => { +browser.storage.local.get(["options", "redirects"], r => { browser.tabs.query({ active: true, currentWindow: true }, async tabs => { + document.getElementById("instance-div").classList.add("hide") for (const service in config.services) { if (!r.options.popupServices.includes(service)) allSites.getElementsByClassName(service)[0].classList.add("hide") else allSites.getElementsByClassName(service)[0].classList.remove("hide") @@ -80,10 +81,36 @@ browser.storage.local.get("options", r => { let service = await serviceHelper.computeService(url, true) let frontend + let instance if (service) { if (typeof service != "string") { + instance = service[2] frontend = service[1] service = service[0] + divs.instance.innerHTML = instance.replace(/https?:\/{2}/, "") + let tmp + let instanceNetwork + for (const network in config.networks) { + tmp = r.redirects[frontend][network].indexOf(instance) + if (tmp > -1) { + const instanceDiv = document.getElementById("instance-enabled") + tmp = r.options[frontend][network].enabled.indexOf(instance) + if (tmp > -1) instanceDiv.checked = true + else instanceDiv.checked = false + instanceNetwork = network + instanceDiv.addEventListener("change", () => { + browser.storage.local.get("options", r => { + // Although options would be avaliable in this context, it is fetched again to make sure it is up to date + let options = r.options + if (instanceDiv.checked) options[frontend][instanceNetwork].enabled.push(instance) + else options[frontend][instanceNetwork].enabled.splice(options[frontend][instanceNetwork].enabled.indexOf(instance), 1) + browser.storage.local.set({ options }) + }) + }) + break + } + } + document.getElementById("instance-div").classList.remove("hide") } divs[service].current.classList.remove("hide") divs[service].all.classList.add("hide") diff --git a/src/pages/popup/style.css b/src/pages/popup/style.css index 0cb27912..3b409be8 100644 --- a/src/pages/popup/style.css +++ b/src/pages/popup/style.css @@ -22,3 +22,43 @@ body { .space { height: 10px; } + +input { + height: 23px; + width: 46px; +} + +#instance { + max-width: 110px; + max-height: 22px; + overflow-x: scroll; + white-space: nowrap; + scrollbar-width: none; + -ms-overflow-style: none; +} + +#instance::-webkit-scrollbar { + display: none; +} + +#instance::before { + background-image: linear-gradient(to right, rgba(0, 0, 0, 1), rgba(0, 0, 0, 0)); + position: absolute; + width: 5px; + height: 22px; + content: ""; + display: block; + pointer-events: none; +} + +#end::before { + background-image: linear-gradient(to left, rgba(0, 0, 0, 1), rgba(0, 0, 0, 0)); + position: absolute; + width: 5px; + height: 22px; + content: ""; + display: block; + pointer-events: none; + top: 13px; + left: 157.4px; +} |