diff --git a/src/assets/images/ifunny-icon.svg b/src/assets/images/ifunny-icon.svg new file mode 100644 index 00000000..b8f37515 --- /dev/null +++ b/src/assets/images/ifunny-icon.svg @@ -0,0 +1,56 @@ + + + + diff --git a/src/assets/images/knowyourmeme-icon.svg b/src/assets/images/knowyourmeme-icon.svg new file mode 100644 index 00000000..9f249b08 --- /dev/null +++ b/src/assets/images/knowyourmeme-icon.svg @@ -0,0 +1,76 @@ + +TENOR_VECTORCreated with Sketch.TENOR_VECTOR diff --git a/src/assets/images/tenor-icon.svg b/src/assets/images/tenor-icon.svg new file mode 100644 index 00000000..8cdc1214 --- /dev/null +++ b/src/assets/images/tenor-icon.svg @@ -0,0 +1,51 @@ + +TENOR_VECTORCreated with Sketch. diff --git a/src/assets/javascripts/services.js b/src/assets/javascripts/services.js index 1a9c3f29..c7f12bc0 100644 --- a/src/assets/javascripts/services.js +++ b/src/assets/javascripts/services.js @@ -62,68 +62,21 @@ async function redirectAsync(url, type, initiator, forceRedirection) { } /** - * @param {URL} url - * @param {string} type - * @param {URL} initiator - * @param {boolean} forceRedirection - * @returns {string | undefined} + * @param url + * @param frontend + * @param randomInstance + * @returns {undefined|string} */ -function redirect(url, type, initiator, forceRedirection, incognito) { - if (type != "main_frame" && type != "sub_frame" && type != "image") return - let randomInstance - let frontend - if (!forceRedirection && options.redirectOnlyInIncognito == true && !incognito) return - for (const service in config.services) { - if (!forceRedirection && !options[service].enabled) continue - - frontend = options[service].frontend - - - if (config.services[service].frontends[frontend].desktopApp && type != "main_frame" && options[service].redirectType != "main_frame") - frontend = options[service].embedFrontend - - - if (!regexArray(service, url, config, frontend)) { - frontend = null - continue - } - - if ( - config.services[service].embeddable && - type != options[service].redirectType && options[service].redirectType != "both" - ) { - if (options[service].unsupportedUrls == 'block') return 'CANCEL' - return - } - - let instanceList = options[frontend] - if (instanceList === undefined) break - if (instanceList.length === 0) return null - - if ( - initiator - && - instanceList.includes(initiator.origin) - ) { - if (type != "main_frame") return null - else return "BYPASSTAB" - } - - randomInstance = utils.getRandomInstance(instanceList) - if (config.services[service].frontends[frontend].localhost && options[service].instance == "localhost") { - randomInstance = `http://${frontend}.localhost:8080` - } - break - } - if (!frontend) return - +function rewrite(url, frontend, randomInstance) { + if (!frontend || !randomInstance) return switch (frontend) { case "hyperpipe": { return `${randomInstance}${url.pathname}${url.search}`.replace(/\/search\?q=.*/, searchQuery => searchQuery.replace("?q=", "/")) } case "searx": - case "searxng": + case "searxng": { return `${randomInstance}/${url.search}` + } case "whoogle": { return `${randomInstance}/search${url.search}` } @@ -149,7 +102,6 @@ function redirect(url, type, initiator, forceRedirection, incognito) { case "freetubePwa": { return 'freetube://' + url.href } - case "poketube": { if (url.pathname.startsWith('/channel')) { const reg = /\/channel\/(.*)\/?$/.exec(url.pathname) @@ -415,7 +367,7 @@ function redirect(url, type, initiator, forceRedirection, incognito) { if (url.hostname.endsWith('bandcamp.com')) { const regex = /^(.*)\.bandcamp\.com/.exec(url.hostname) const artist = regex[1] - if (url.pathname == '/') { + if (url.pathname == '/' || url.pathname == '/music') { return `${randomInstance}/artist.php?name=${artist}` } else { const regex = /^\/(.*)\/(.*)/.exec(url.pathname) @@ -557,6 +509,60 @@ function redirect(url, type, initiator, forceRedirection, incognito) { } } +/** + * @param {URL} url + * @param {string} type + * @param {URL} initiator + * @param {boolean} forceRedirection + * @returns {string | undefined} + */ +function redirect(url, type, initiator, forceRedirection, incognito) { + if (type != "main_frame" && type != "sub_frame" && type != "image") return + let randomInstance + let frontend + if (!forceRedirection && options.redirectOnlyInIncognito == true && !incognito) return + for (const service in config.services) { + if (!forceRedirection && !options[service].enabled) continue + + frontend = options[service].frontend + + if (config.services[service].frontends[frontend].desktopApp && type != "main_frame" && options[service].redirectType != "main_frame") + frontend = options[service].embedFrontend + + if (!regexArray(service, url, config, frontend)) { + frontend = null + continue + } + + if ( + config.services[service].embeddable + && + type != options[service].redirectType && options[service].redirectType != "both" + ) { + if (options[service].unsupportedUrls == 'block') return 'CANCEL' + return + } + + let instanceList = options[frontend] + if (instanceList === undefined) break + if (instanceList.length === 0) return null + + if (initiator && instanceList.includes(initiator.origin)) { + if (type != "main_frame") return null + else return "BYPASSTAB" + } + + randomInstance = utils.getRandomInstance(instanceList) + if (config.services[service].frontends[frontend].localhost && options[service].instance == "localhost") { + randomInstance = `http://${frontend}.localhost:8080` + } + break + } + if (!frontend) return + + return rewrite(url, frontend, randomInstance) +} + /** * @param {URL} url * @param {*} returnFrontend @@ -711,6 +717,9 @@ const defaultInstances = { 'biblioReads': ['https://biblioreads.ml'], 'wikiless': ['https://wikiless.org'], 'suds': ['https://sd.vern.cc'], + 'unfunny': ['https://uf.vern.cc'], + 'soprano': ['https://sp.vern.cc'], + 'meme': ['https://mm.vern.cc'], 'waybackClassic': ['https://wayback-classic.net'], 'gothub': ['https://gh.odyssey346.dev'], 'mikuInvidious': ['https://mikuinv.resrv.org'], diff --git a/src/config.json b/src/config.json index 59424961..4288d2db 100644 --- a/src/config.json +++ b/src/config.json @@ -716,6 +716,66 @@ "imageType": "svg", "url": "https://www.snopes.com" }, + "ifunny": { + "frontends": { + "unfunny": { + "name": "UNfunny", + "instanceList": true, + "url": "https://git.vern.cc/cobra/UNfunny" + } + }, + "targets": [ + "^https?:\\/{2}(www\\.)?ifunny\\.co\\/" + ], + "name": "iFunny", + "options": { + "enabled": false, + "unsupportedUrls": "bypass", + "frontend": "unfunny" + }, + "imageType": "svg", + "url": "https://ifunny.co" + }, + "tenor": { + "frontends": { + "soprano": { + "name": "Soprano", + "instanceList": true, + "url": "https://git.vern.cc/cobra/Soprano" + } + }, + "targets": [ + "^https?:\\/{2}(www\\.)?tenor\\.com\\/" + ], + "name": "Tenor", + "options": { + "enabled": false, + "unsupportedUrls": "bypass", + "frontend": "soprano" + }, + "imageType": "svg", + "url": "https://tenor.com" + }, + "knowyourmeme": { + "frontends": { + "meme": { + "name": "MeMe", + "instanceList": true, + "url": "https://git.vern.cc/cobra/MeMe" + } + }, + "targets": [ + "^https?:\\/{2}(www\\.)?knowyourmeme\\.com\\/" + ], + "name": "KnowYourMeme", + "options": { + "enabled": false, + "unsupportedUrls": "bypass", + "frontend": "meme" + }, + "imageType": "svg", + "url": "https://knowyourmeme.com" + }, "urbanDictionary": { "frontends": { "ruralDictionary": { diff --git a/src/manifest.json b/src/manifest.json index 95c24bb1..13908f0e 100644 --- a/src/manifest.json +++ b/src/manifest.json @@ -1,7 +1,7 @@ { "name": "__MSG_extensionName__", "description": "__MSG_extensionDescription__", - "version": "2.8.2", + "version": "2.8.3", "manifest_version": 2, "browser_specific_settings": { "gecko": { diff --git a/src/pages/options/widgets/general.js b/src/pages/options/widgets/general.js index 6f2852a9..8322a378 100644 --- a/src/pages/options/widgets/general.js +++ b/src/pages/options/widgets/general.js @@ -112,13 +112,9 @@ redirectOnlyInIncognitoElement.addEventListener('change', event => { const bookmarksMenuElement = document.getElementById('bookmarksMenu') bookmarksMenuElement.addEventListener('change', async event => { if (event.target.checked) - bookmarksMenuElement.checked = await browser.permissions.request({ - permissions: ["bookmarks"] - }) + browser.permissions.request({ permissions: ["bookmarks"] }, r => bookmarksMenuElement.checked = r) else - bookmarksMenuElement.checked = !await browser.permissions.remove({ - permissions: ["bookmarks"] - }) + browser.permissions.remove({ permissions: ["bookmarks"] }, r => bookmarksMenuElement.checked = !r) }) let themeElement = document.getElementById("theme") @@ -149,7 +145,7 @@ let options = await utils.getOptions() themeElement.value = options.theme fetchInstancesElement.value = options.fetchInstances redirectOnlyInIncognitoElement.checked = options.redirectOnlyInIncognito -bookmarksMenuElement.checked = await browser.permissions.contains({ permissions: ["bookmarks"] }) +browser.permissions.contains({ permissions: ["bookmarks"] }, r => bookmarksMenuElement.checked = r) for (const service in config.services) document.getElementById(service).checked = options.popupServices.includes(service) instanceTypeElement.addEventListener("change", event => { diff --git a/src/pages/popup/popup.js b/src/pages/popup/popup.js index 0e5a3d4b..cfb7be27 100644 --- a/src/pages/popup/popup.js +++ b/src/pages/popup/popup.js @@ -7,15 +7,17 @@ import utils from "../../assets/javascripts/utils.js" document.getElementById("more-options").href = browser.runtime.getURL("pages/options/index.html") document.getElementById("more-options").setAttribute('target', '_blank') -const os = (await browser.runtime.getPlatformInfo()).os - -switch (os) { - case "fuchsia": - case "ios": - case "android": { - document.getElementsByTagName("html")[0].classList.add("mobile") +await browser.runtime.getPlatformInfo(r => { + switch (r.os) { + case "fuchsia": + case "ios": + case "android": { + document.getElementsByTagName("html")[0].classList.add("mobile") + } } } +) + const allSites = document.getElementById("all_sites") const currSite = document.getElementById("current_site") @@ -68,10 +70,12 @@ browser.tabs.query({ active: true, currentWindow: true }, async tabs => { // Set visibility of control buttons if (tabs[0].url) { + const hr = document.getElementById("hr") url = new URL(tabs[0].url) servicesHelper.switchInstance(url).then(r => { if (r) { document.getElementById("change_instance_div").style.display = "" + hr.style.display = "" document.getElementById("change_instance").addEventListener("click", async () => browser.tabs.update({ url: await servicesHelper.switchInstance(url) }) ) @@ -80,6 +84,7 @@ browser.tabs.query({ active: true, currentWindow: true }, async tabs => { servicesHelper.copyRaw(url, true).then(r => { if (r) { document.getElementById("copy_original_div").style.display = "" + hr.style.display = "" document.getElementById("copy_original").addEventListener("click", () => servicesHelper.copyRaw(url) ) @@ -88,6 +93,7 @@ browser.tabs.query({ active: true, currentWindow: true }, async tabs => { servicesHelper.reverse(url).then(r => { if (r) { document.getElementById("redirect_to_original_div").style.display = "" + hr.style.display = "" document.getElementById("redirect_to_original").addEventListener("click", () => browser.runtime.sendMessage("reverseTab") ) @@ -96,6 +102,7 @@ browser.tabs.query({ active: true, currentWindow: true }, async tabs => { servicesHelper.redirectAsync(url, "main_frame", null, true).then(r => { if (r) { document.getElementById("redirect_div").style.display = "" + hr.style.display = "" document.getElementById("redirect").addEventListener("click", () => browser.runtime.sendMessage("redirectTab") ) diff --git a/src/pages/popup/popup.pug b/src/pages/popup/popup.pug index d7ebdd49..ed4c7319 100644 --- a/src/pages/popup/popup.pug +++ b/src/pages/popup/popup.pug @@ -30,7 +30,7 @@ html(lang="en") svg(xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" preserveAspectRatio="xMinYMin meet" fill="currentColor") path(d="M 17,20 V 11 Q 17,10.175 16.412,9.587 15.825,9 15,9 H 6.8 L 8.4,7.4 7,6 3,10 7,14 8.4,12.6 6.8,11 H 15 v 9 z" id="path2") - hr + hr(id="hr" style="display: none") div(id="current_site") include /src/pages/popup/switches diff --git a/src/pages/stylesheets/styles.css b/src/pages/stylesheets/styles.css index 2aa52d57..e3212a66 100644 --- a/src/pages/stylesheets/styles.css +++ b/src/pages/stylesheets/styles.css @@ -131,7 +131,7 @@ section.links { flex-wrap: wrap; flex-direction: column; width: 350px; - max-height: 930px; + max-height: 970px; } section.links div { @@ -375,19 +375,27 @@ input:disabled { cursor: not-allowed; } - @media (max-width: 1250px) { body.option { flex-direction: column; - width: 750px; + width: 95vw; align-items: center; + padding: 40px 0px; } section.links { flex-direction: row; - width: 750px; + width: 95vw; padding: 0 55px; } + + section.block-option { + width: 95vw; + } + + div.checklist div x { + overflow: hidden; + } } html.mobile img, diff --git a/src/updates/updates.xml b/src/updates/updates.xml index ce342b3a..c6d151cc 100644 --- a/src/updates/updates.xml +++ b/src/updates/updates.xml @@ -1,6 +1,6 @@ - +