From f454ced9490309f37199c2a47dcd8cbc7e976798 Mon Sep 17 00:00:00 2001 From: ManeraKai Date: Wed, 7 Dec 2022 10:51:43 +0300 Subject: [PATCH 01/17] Removed LatencyTest, AutoRedirect, Unify, DisableInstance --- Privacy-Policy.md | 1 - src/assets/javascripts/general.js | 2 - src/assets/javascripts/services.js | 53 +----- src/assets/javascripts/utils.js | 205 +-------------------- src/config/config.json | 237 ------------------------- src/instances/get_instances.py | 19 -- src/manifest.json | 8 +- src/pages/background/background.js | 55 +----- src/pages/errors/instance_offline.html | 39 ---- src/pages/errors/instance_offline.js | 20 --- src/pages/options/widgets/general.ejs | 31 ---- src/pages/options/widgets/general.js | 36 ---- src/pages/options/widgets/services.ejs | 10 -- src/pages/options/widgets/services.js | 1 - src/pages/popup/popup.ejs | 102 ++++++----- src/pages/popup/popup.js | 43 ----- 16 files changed, 62 insertions(+), 800 deletions(-) delete mode 100644 src/pages/errors/instance_offline.html delete mode 100644 src/pages/errors/instance_offline.js diff --git a/Privacy-Policy.md b/Privacy-Policy.md index d2878c7..8618092 100644 --- a/Privacy-Policy.md +++ b/Privacy-Policy.md @@ -6,7 +6,6 @@ OpenStreetMap (OSM) reverse geocoding, done via the [OSM Nomantim API](https://nominatim.org/release-docs/develop/api/Overview/), used as part of OSM redirects, which can be disabled by toggling the OSM redirects. - It also connects to [this url](https://raw.githubusercontent.com/libredirect/libredirect/master/src/instances/data.json) to update the Instances List. Though this only gets triggered when the user presses the `Update Instances` button. -- For bibliogram instances. To set a cookie you should send an HTTP request to the server as the server stores settings values itself and gives you a token to access them. ## Future Changes diff --git a/src/assets/javascripts/general.js b/src/assets/javascripts/general.js index 9e490c4..7b8f9da 100644 --- a/src/assets/javascripts/general.js +++ b/src/assets/javascripts/general.js @@ -32,10 +32,8 @@ async function initDefaults() { }, theme: "detect", popupServices: ["youtube", "twitter", "instagram", "tiktok", "imgur", "reddit", "quora", "translate", "maps"], - autoRedirect: false, network: "clearnet", networkFallback: true, - latencyThreshold: 1000, }, }, () => resolve() diff --git a/src/assets/javascripts/services.js b/src/assets/javascripts/services.js index a8d9907..5463bfc 100644 --- a/src/assets/javascripts/services.js +++ b/src/assets/javascripts/services.js @@ -550,50 +550,6 @@ function reverse(url, urlString) { }) } -function unifyPreferences(url, tabId) { - return new Promise(async resolve => { - await init() - const protocolHost = utils.protocolHost(url) - for (const service in config.services) { - for (const frontend in config.services[service].frontends) { - if (all(service, frontend, options, config, redirects).includes(protocolHost)) { - let instancesList = [...options[frontend][options.network].enabled, ...options[frontend][options.network].custom] - if (options.networkFallback && options.network != "clearnet") instancesList.push(...options[frontend].clearnet.enabled, ...options[frontend].clearnet.custom) - - const frontendObject = config.services[service].frontends[frontend] - if ("cookies" in frontendObject.preferences) { - for (const cookie of frontendObject.preferences.cookies) { - await utils.copyCookie(url, instancesList, cookie) - } - } - if ("localstorage" in frontendObject.preferences) { - browser.storage.local.set({ tmp: [frontend, frontendObject.preferences.localstorage] }) - browser.tabs.executeScript(tabId, { - file: "/assets/javascripts/get-localstorage.js", - runAt: "document_start", - }) - for (const instance of instancesList) - browser.tabs.create({ url: instance }, tab => - browser.tabs.executeScript(tab.id, { - file: "/assets/javascripts/set-localstorage.js", - runAt: "document_start", - }) - ) - } - /* - if ("indexeddb" in frontendObject.preferences) { - } - if ("token" in frontendObject.preferences) { - } - */ - resolve(true) - return - } - } - } - }) -} - function setRedirects(passedRedirects) { return new Promise(resolve => { fetch("/config/config.json") @@ -662,7 +618,6 @@ function initDefaults() { let targets = {} let config = JSON.parse(configData) const localstorage = {} - const latency = {} for (const service in config.services) { options[service] = {} if (config.services[service].targets == "datajson") { @@ -687,7 +642,7 @@ function initDefaults() { } } } - browser.storage.local.set({ redirects, options, targets, latency, localstorage }) + browser.storage.local.set({ redirects, options, targets, localstorage }) resolve() }) }) @@ -702,7 +657,6 @@ function upgradeOptions() { .then(configData => { browser.storage.local.get(null, r => { let options = r.options - let latency = {} const config = JSON.parse(configData) options.exceptions = r.exceptions if (r.theme != "DEFAULT") options.theme = r.theme @@ -717,7 +671,6 @@ function upgradeOptions() { options.popupServices.splice(tmp, 1) options.popupServices.push("sendFiles") } - options.autoRedirect = r.autoRedirect switch (r.onlyEmbeddedVideo) { case "onlyNotEmbedded": options.youtube.redirectType = "main_frame" @@ -747,7 +700,6 @@ function upgradeOptions() { if (r[oldService + "EmbedFrontend"] && (service != "youtube" || r[oldService + "EmbedFrontend"] == "invidious" || r[oldService + "EmbedFrontend"] == "piped")) options[service].embedFrontend = r[oldService + "EmbedFrontend"] for (const frontend in config.services[service].frontends) { - if (r[frontend + "Latency"]) latency[frontend] = r[frontend + "Latency"] for (const network in config.networks) { let protocol if (network == "clearnet") protocol = "normal" @@ -763,7 +715,7 @@ function upgradeOptions() { } } } - browser.storage.local.set({ options, latency }, () => resolve()) + browser.storage.local.set({ options }, () => resolve()) }) }) }) @@ -870,7 +822,6 @@ export default { computeService, switchInstance, reverse, - unifyPreferences, setRedirects, initDefaults, upgradeOptions, diff --git a/src/assets/javascripts/utils.js b/src/assets/javascripts/utils.js index b176967..4dd537f 100644 --- a/src/assets/javascripts/utils.js +++ b/src/assets/javascripts/utils.js @@ -13,7 +13,6 @@ function camelCase(str) { let cloudflareBlackList = [] let authenticateBlackList = [] -let offlineBlackList = [] async function initBlackList() { return new Promise(resolve => { fetch("/instances/blacklist.json") @@ -21,7 +20,6 @@ async function initBlackList() { .then(data => { cloudflareBlackList = JSON.parse(data).cloudflare authenticateBlackList = JSON.parse(data).authenticate - offlineBlackList = JSON.parse(data).offline resolve() }) }) @@ -60,7 +58,6 @@ function protocolHost(url) { } async function processDefaultCustomInstances(service, frontend, network, document) { - let instancesLatency let frontendNetworkElement = document.getElementById(frontend).getElementsByClassName(network)[0] let frontendCustomInstances = [] @@ -74,11 +71,10 @@ async function processDefaultCustomInstances(service, frontend, network, documen async function getFromStorage() { return new Promise(async resolve => - browser.storage.local.get(["options", "redirects", "latency"], r => { + browser.storage.local.get(["options", "redirects",], r => { frontendDefaultRedirects = r.options[frontend][network].enabled frontendCustomInstances = r.options[frontend][network].custom options = r.options - instancesLatency = r.latency[frontend] ?? [] redirects = r.redirects resolve() }) @@ -106,27 +102,17 @@ async function processDefaultCustomInstances(service, frontend, network, documen Toggle All `, - ...redirects[frontend][network].map(x => { - const cloudflare = cloudflareBlackList.includes(x) ? ' cloudflare' : "" - const authenticate = authenticateBlackList.includes(x) ? ' authenticate' : "" - const offline = offlineBlackList.includes(x) ? ' offline' : "" + ...redirects[frontend][network] + .map(x => { + const cloudflare = cloudflareBlackList.includes(x) ? ' cloudflare' : "" + const authenticate = authenticateBlackList.includes(x) ? ' authenticate' : "" - let ms = instancesLatency[x] - let latencyColor = ms == -1 ? "red" : ms <= 1000 ? "green" : ms <= 2000 ? "orange" : "red" - let latencyLimit - if (ms == 5000) latencyLimit = "5000ms+" - else if (ms > 5000) latencyLimit = `ERROR: ${ms - 5000}` - else if (ms == -1) latencyLimit = "Server not found" - else latencyLimit = ms + "ms" - - const latency = x in instancesLatency ? '' + latencyLimit + "" : "" - - let warnings = [cloudflare, authenticate, offline, latency].join(" ") - return `
+ let warnings = [cloudflare, authenticate].join(" ") + return `
${x}${warnings}
` - }), + }), ].join("\n
\n") localise.localisePage() @@ -211,133 +197,6 @@ async function processDefaultCustomInstances(service, frontend, network, documen }) } -function ping(href) { - return new Promise(async resolve => { - let average = 0 - let time - for (let i = 0; i < 3; i++) { - time = await pingOnce(href) - if (i == 0) continue - if (time >= 5000) { - resolve(time) - return - } - average += time - } - average = parseInt(average / 3) - resolve(average) - }) -} - -function pingOnce(href) { - return new Promise(async resolve => { - let started - let http = new XMLHttpRequest() - http.timeout = 5000 - http.ontimeout = () => resolve(5000) - http.onerror = () => resolve() - http.onreadystatechange = () => { - if (http.readyState == 2) { - if (http.status == 200) { - let ended = new Date().getTime() - http.abort() - resolve(ended - started) - } else { - resolve(5000 + http.status) - } - } - } - http.open("GET", `${href}?_=${new Date().getTime()}`, true) - started = new Date().getTime() - http.send(null) - }) -} - -async function testLatency(element, instances, frontend) { - return new Promise(async resolve => { - let myList = {} - let latencyThreshold, options - browser.storage.local.get(["options"], r => { - latencyThreshold = r.options.latencyThreshold - options = r.options - }) - for (const href of instances) { - await ping(href).then(time => { - let color - if (time) { - myList[href] = time - if (time <= 1000) color = "green" - else if (time <= 2000) color = "orange" - else color = "red" - - if (time > latencyThreshold && options[frontend].clearnet.enabled.includes(href)) { - options[frontend].clearnet.enabled.splice(options[frontend].clearnet.enabled.indexOf(href), 1) - } - - let text - if (time == 5000) text = "5000ms+" - else if (time > 5000) text = `ERROR: ${time - 5000}` - else text = `${time}ms` - element.innerHTML = `${href}: ${text}` - } else { - myList[href] = -1 - color = "red" - element.innerHTML = `${href}: Server not found` - if (options[frontend].clearnet.enabled.includes(href)) options[frontend].clearnet.enabled.splice(options[frontend].clearnet.enabled.indexOf(href), 1) - } - }) - } - browser.storage.local.set({ options }) - resolve(myList) - }) -} - -function copyCookie(targetUrl, urls, name) { - return new Promise(resolve => { - const query = { - url: protocolHost(targetUrl), - name: name, - } - browser.cookies.getAll(query, async cookies => { - for (const cookie of cookies) - if (cookie.name == name) { - for (const url of urls) { - const setQuery = { - url: url, - name: name, - value: cookie.value, - secure: true, - expirationDate: cookie.expirationDate, - } - browser.cookies.set(setQuery) - } - break - } - resolve() - }) - }) -} - -function getPreferencesFromToken(frontend, targetUrl, urls, name, endpoint) { - return new Promise(resolve => { - const http = new XMLHttpRequest() - const url = `${targetUrl}${endpoint}` - http.open("GET", url, false) - //http.setRequestHeader("Cookie", `${name}=${cookie.value}`) - http.send(null) - const preferences = JSON.parse(http.responseText) - let formdata = new FormData() - for (var key in preferences) formdata.append(key, preferences[key]) - for (const url of urls) { - const http = new XMLHttpRequest() - http.open("POST", `${url}/settings/stay`, false) - http.send(null) - } - resolve() - return - }) -} - function copyRaw(test, copyRawElement) { return new Promise(resolve => { browser.tabs.query({ active: true, currentWindow: true }, async tabs => { @@ -370,25 +229,6 @@ function copyRaw(test, copyRawElement) { }) } -function unify() { - return new Promise(resolve => { - browser.tabs.query({ active: true, currentWindow: true }, async tabs => { - let currTab = tabs[0] - if (currTab) { - let url - try { - url = new URL(currTab.url) - } catch { - resolve() - return - } - - resolve(await servicesHelper.unifyPreferences(url, currTab.id)) - } - }) - }) -} - function switchInstance(test) { return new Promise(resolve => { browser.tabs.query({ active: true, currentWindow: true }, async tabs => { @@ -412,41 +252,12 @@ function switchInstance(test) { }) } -function latency(service, frontend, document, location) { - let latencyElement = document.getElementById(`latency-${frontend}`) - let latencyLabel = document.getElementById(`latency-${frontend}-label`) - latencyElement.addEventListener("click", async () => { - let reloadWindow = () => location.reload() - latencyElement.addEventListener("click", reloadWindow) - browser.storage.local.get("redirects", r => { - let redirects = r.redirects - const oldHtml = latencyLabel.innerHTML - latencyLabel.innerHTML = "..." - testLatency(latencyLabel, redirects[frontend].clearnet, frontend).then(r => { - const frontendLatency = r - browser.storage.local.get("latency", r => { - let latency = r.latency - latency[frontend] = frontendLatency - browser.storage.local.set({ latency }) - latencyLabel.innerHTML = oldHtml - processDefaultCustomInstances(service, frontend, "clearnet", document) - latencyElement.removeEventListener("click", reloadWindow) - }) - }) - }) - }) -} - export default { getRandomInstance, updateInstances, protocolHost, processDefaultCustomInstances, - latency, - copyCookie, - getPreferencesFromToken, switchInstance, copyRaw, - unify, camelCase, } diff --git a/src/config/config.json b/src/config/config.json index 011347f..31940b2 100644 --- a/src/config/config.json +++ b/src/config/config.json @@ -21,14 +21,6 @@ "youtube": { "frontends": { "invidious": { - "preferences": { - "cookies": [ - "PREFS" - ], - "localstorage": [ - "dark_mode" - ] - }, "name": "Invidious", "embeddable": true, "instanceList": true @@ -38,29 +30,6 @@ 1, 2 ], - "preferences": { - "localstorage": [ - "bufferGoal", - "comments", - "disableLBRY", - "enabledCodecs", - "hl", - "homepage", - "instance", - "listen", - "minimizeDescription", - "playerAutoPlay", - "proxyLBRY", - "quality", - "region", - "selectedSkip", - "sponsorblock", - "theme", - "volume", - "watchHistory", - "localSubscriptions" - ] - }, "name": "Piped", "embeddable": true, "instanceList": true @@ -70,21 +39,11 @@ 1, 2 ], - "preferences": { - "localstorage": [ - "PREFERENCES" - ] - }, "name": "Piped-Material", "embeddable": false, "instanceList": true }, "cloudtube": { - "preferences": { - "token": "token", - "fetchEndpoint": "/api/settings", - "setEndpoint": "/settings" - }, "name": "CloudTube", "embeddable": false, "instanceList": true @@ -130,30 +89,10 @@ "youtubeMusic": { "frontends": { "beatbump": { - "preferences": { - "localstorage": [ - "settings" - ], - "indexeddb": "beatbump" - }, "name": "Beatbump", "instanceList": true }, "hyperpipe": { - "preferences": { - "localstorage": [ - "api", - "authapi", - "codec", - "locale", - "next", - "pipedapi", - "quality", - "theme", - "vol" - ], - "indexeddb": "hyperpipedb" - }, "name": "Hyperpipe", "instanceList": true } @@ -173,27 +112,6 @@ "twitter": { "frontends": { "nitter": { - "preferences": { - "cookies": [ - "autoplayGifs", - "bidiSupport", - "hideBanner", - "hidePins", - "hideReplies", - "hideTweetStats", - "hlsPlayback", - "infiniteScroll", - "mp4Playback", - "muteVideos", - "proxyVideos", - "replaceInstagram", - "replaceReddit", - "replaceTwitter", - "replaceYouTube", - "squareAvatars", - "theme" - ] - }, "name": "Nitter", "embeddable": true, "instanceList": true @@ -217,11 +135,6 @@ "instagram": { "frontends": { "bibliogram": { - "preferences": { - "token": "token", - "fetchEndpoint": "/settings.json", - "setEndpoint": "/applysettings" - }, "name": "Bibliogram", "instanceList": true } @@ -240,12 +153,6 @@ "tiktok": { "frontends": { "proxiTok": { - "preferences": { - "cookies": [ - "api-test_endpoints", - "theme" - ] - }, "name": "ProxiTok", "instanceList": true } @@ -264,46 +171,10 @@ "reddit": { "frontends": { "libreddit": { - "preferences": { - "cookies": [ - "theme", - "front_page", - "layout", - "wide", - "post_sort", - "comment_sort", - "show_nsfw", - "autoplay_videos", - "use_hls", - "hide_hls_notification", - "subscriptions", - "filters" - ] - }, "name": "Libreddit", "instanceList": true }, "teddit": { - "preferences": { - "cookies": [ - "collapse_child_comments", - "default_comment_sort", - "domain_instagram", - "domain_twitter", - "domain_youtube", - "flairs", - "highlight_controversial", - "nsfw_enabled", - "post_media_max_height", - "prefer_frontpage", - "show_large_gallery_images", - "show_upvoted_percentage", - "show_upvotes", - "subbed_subreddits", - "theme", - "videos_muted" - ] - }, "name": "Teddit", "instanceList": true } @@ -343,12 +214,6 @@ "wikipedia": { "frontends": { "wikiless": { - "preferences": { - "cookies": [ - "theme", - "default_lang" - ] - }, "name": "Wikiless", "instanceList": true } @@ -402,11 +267,6 @@ "quora": { "frontends": { "quetre": { - "preferences": { - "localstorage": [ - "theme" - ] - }, "name": "Quetre", "instanceList": true } @@ -425,11 +285,6 @@ "imdb": { "frontends": { "libremdb": { - "preferences": { - "localstorage": [ - "theme" - ] - }, "name": "libremdb", "instanceList": true } @@ -500,20 +355,6 @@ "lbry": { "frontends": { "librarian": { - "preferences": { - "cookies": [ - "nsfw", - "theme" - ], - "localstorage": [ - "autoplay", - "autoplayNextVid", - "collapseComments", - "plyr", - "sb_categories", - "showRelated" - ] - }, "name": "Librarian", "embeddable": true, "instanceList": true @@ -542,55 +383,10 @@ "search": { "frontends": { "searx": { - "preferences": { - "cookies": [ - "advanced_search", - "autocomplete", - "categories", - "disabled_engines", - "disabled_plugins", - "doi_resolver", - "enabled_engines", - "enabled_plugins", - "image_proxy", - "language", - "locale", - "method", - "oscar-style", - "results_on_new_tab", - "safesearch", - "theme", - "tokens" - ] - }, "name": "SearX", "instanceList": true }, "searxng": { - "preferences": { - "cookies": [ - "autocomplete", - "categories", - "center_alignment", - "disabled_engines", - "disabled_plugins", - "doi_resolver", - "enabled_plugins", - "enabled_engines", - "image_proxy", - "infinite_scroll", - "language", - "locale", - "maintab", - "method", - "query_in_title", - "results_on_new_tab", - "safesearch", - "simple_style", - "theme", - "tokens" - ] - }, "name": "SearXNG", "instanceList": true }, @@ -599,20 +395,6 @@ "instanceList": true }, "librex": { - "preferences": { - "cookies": [ - "bibliogram", - "disable_frontends", - " disable_special", - "invidious", - "libreddit", - "nitter", - "proxitok", - "save", - "theme", - "wikiless" - ] - }, "name": "LibreX", "instanceList": true } @@ -632,26 +414,10 @@ "translate": { "frontends": { "simplyTranslate": { - "preferences": { - "cookies": [ - "from_lang", - "to_lang", - "tts_enabled", - "use_text_fields" - ] - }, "name": "SimplyTranslate", "instanceList": true }, "lingva": { - "preferences": { - "localstorage": [ - "isauto", - "source", - "target", - "chakra-ui-color-mode" - ] - }, "name": "Lingva Translate", "instanceList": true }, @@ -743,9 +509,6 @@ }, "authenticate": { "color": "orange" - }, - "offline": { - "color": "grey" } } } \ No newline at end of file diff --git a/src/instances/get_instances.py b/src/instances/get_instances.py index 913ee1c..65b1fc4 100755 --- a/src/instances/get_instances.py +++ b/src/instances/get_instances.py @@ -117,21 +117,6 @@ def is_authenticate(url): return False return False - -def is_offline(url): - try: - r = requests.get(url, timeout=5, headers=headers) - if r.status_code >= 400: - print(url + ' is ' + Fore.RED + 'offline' + Style.RESET_ALL) - print("Status code") - print(r.status_code) - return True - else: - return False - except Exception: - return False - - def fetchCache(frontend, name): try: with open('./src/instances/data.json') as file: @@ -524,7 +509,6 @@ mightyList = idnaEncode(mightyList) cloudflare = [] authenticate = [] -offline = [] for k1, v1 in mightyList.items(): if type(mightyList[k1]) is dict: for k2, v2 in mightyList[k1].items(): @@ -537,15 +521,12 @@ for k1, v1 in mightyList.items(): cloudflare.append(instance) if not instance.endswith('.onion') and not instance.endswith('.i2p') and not instance.endswith('.loki') and is_authenticate(instance): authenticate.append(instance) - elif not instance.endswith('.onion') and not instance.endswith('.i2p') and not instance.endswith('.loki') and is_offline(instance): - offline.append(instance) peertube() blacklist = { 'cloudflare': cloudflare, 'authenticate': authenticate, - 'offline': offline } # Writing to file diff --git a/src/manifest.json b/src/manifest.json index 00c5016..2730d16 100644 --- a/src/manifest.json +++ b/src/manifest.json @@ -19,7 +19,7 @@ "48": "assets/images/libredirect-48.png", "128": "assets/images/libredirect-128.png" }, - "permissions": ["webRequest", "webRequestBlocking", "storage", "unlimitedStorage", "cookies", "clipboardWrite", "contextMenus", ""], + "permissions": ["webRequest", "webRequestBlocking", "storage", "unlimitedStorage", "clipboardWrite", "contextMenus", ""], "browser_action": { "default_title": "__MSG_extensionName__", "browser_style": false, @@ -58,12 +58,6 @@ "default": "Alt+Shift+C" }, "description": "Copies the original link. Ex: Copies the original twitter link while in the nitter website" - }, - "unify": { - "suggested_key": { - "default": "Alt+Shift+U" - }, - "description": "Copies the preferences (cookies, localStorage) from the current opened instance and copy them to all the other selected instances" } }, "default_locale": "en", diff --git a/src/pages/background/background.js b/src/pages/background/background.js index 3a69504..2db6dc0 100644 --- a/src/pages/background/background.js +++ b/src/pages/background/background.js @@ -89,47 +89,9 @@ browser.tabs.onRemoved.addListener(tabId => { } }) -async function redirectOfflineInstance(url, tabId) { - let newUrl = await servicesHelper.switchInstance(url, true) - - if (newUrl) { - if (counter >= 5) { - browser.tabs.update(tabId, { - url: `/pages/errors/instance_offline.html?url=${encodeURIComponent(newUrl)}`, - }) - counter = 0 - } else { - browser.tabs.update(tabId, { url: newUrl }) - counter++ - } - } -} -let counter = 0 - -function isAutoRedirect() { - return new Promise(resolve => browser.storage.local.get("options", r => resolve(r.options.autoRedirect == true))) -} - -browser.webRequest.onResponseStarted.addListener( - async details => { - if (!(await isAutoRedirect())) return null - if (details.type == "main_frame" && details.statusCode >= 500) redirectOfflineInstance(new URL(details.url), details.tabId) - }, - { urls: [""] } -) - -browser.webRequest.onErrorOccurred.addListener( - async details => { - if (!(await isAutoRedirect())) return - if (details.type == "main_frame") redirectOfflineInstance(new URL(details.url), details.tabId) - }, - { urls: [""] } -) - browser.commands.onCommand.addListener(command => { if (command === "switchInstance") utils.switchInstance() else if (command == "copyRaw") utils.copyRaw() - else if (command == "unify") utils.unify() }) browser.contextMenus.create({ @@ -150,12 +112,6 @@ browser.contextMenus.create({ contexts: ["browser_action"], }) -browser.contextMenus.create({ - id: "unify", - title: browser.i18n.getMessage("unifySettings"), - contexts: ["browser_action"], -}) - try { browser.contextMenus.create({ id: "toggleTab", @@ -207,10 +163,6 @@ browser.contextMenus.onClicked.addListener((info, tab) => { utils.copyRaw() resolve() return - case "unify": - utils.unify() - resolve() - return case "toggleTab": if (tabIdRedirects[tab.id] != undefined) { tabIdRedirects[tab.id] = !tabIdRedirects[tab.id] @@ -253,9 +205,4 @@ browser.webRequest.onHeadersReceived.addListener( }, { urls: [""] }, ["blocking", "responseHeaders"] -) - -browser.runtime.onMessage.addListener((message, sender, sendResponse) => { - if (message.function === "unify") utils.unify(false).then(r => sendResponse({ response: r })) - return true -}) +) \ No newline at end of file diff --git a/src/pages/errors/instance_offline.html b/src/pages/errors/instance_offline.html deleted file mode 100644 index a74caec..0000000 --- a/src/pages/errors/instance_offline.html +++ /dev/null @@ -1,39 +0,0 @@ - - - - - - - Instance is offline - - - - - -
-

- This instance is offline, you'll be redirected after - 2 seconds -

- -
- - - - diff --git a/src/pages/errors/instance_offline.js b/src/pages/errors/instance_offline.js deleted file mode 100644 index fadb768..0000000 --- a/src/pages/errors/instance_offline.js +++ /dev/null @@ -1,20 +0,0 @@ -import localise from "../../assets/javascripts/localise.js" - -const params = new Proxy(new URLSearchParams(window.location.search), { - get: (searchParams, prop) => searchParams.get(prop), -}) - -let number = document.getElementById("number") -setTimeout(() => (number.innerHTML = "1"), 1000) -setTimeout(() => { - number.innerHTML = "0" - if (!isCanceled) window.location = params.url -}, 2000) - -let isCanceled = false -document.getElementById("cancel").addEventListener("click", () => { - isCanceled = true - document.getElementById("message").innerHTML = browser.i18n.getMessage("redirectionCanceled") -}) - -localise.localisePage() diff --git a/src/pages/options/widgets/general.ejs b/src/pages/options/widgets/general.ejs index fef052d..6bb15bc 100644 --- a/src/pages/options/widgets/general.ejs +++ b/src/pages/options/widgets/general.ejs @@ -13,37 +13,6 @@
-
-

Network

- -
- -
-
-

Fallback to clearnet if no instances are available for the current network

- -
-
- -
-

- -
- -
-
-

Latency Threshold

- - -
-
- -
-

Excluded from redirecting

diff --git a/src/pages/options/widgets/general.js b/src/pages/options/widgets/general.js index d55f8f0..a8eb11f 100644 --- a/src/pages/options/widgets/general.js +++ b/src/pages/options/widgets/general.js @@ -121,37 +121,12 @@ resetSettings.addEventListener("click", async () => { }) }) -let autoRedirectElement = document.getElementById("auto-redirect") -autoRedirectElement.addEventListener("change", event => { - setOption("autoRedirect", "checkbox", event) -}) - let themeElement = document.getElementById("theme") themeElement.addEventListener("change", event => { setOption("theme", "select", event) location.reload() }) -let networkElement = document.getElementById("network") -networkElement.addEventListener("change", event => { - setOption("network", "select", event) - location.reload() -}) - -let networkFallbackCheckbox = document.getElementById("network-fallback-checkbox") -networkFallbackCheckbox.addEventListener("change", event => { - setOption("networkFallback", "checkbox", event) -}) - -let latencyOutput = document.getElementById("latency-output") -let latencyInput = document.getElementById("latency-input") -latencyInput.addEventListener("change", event => { - setOption("latencyThreshold", "range", event) -}) -latencyInput.addEventListener("input", event => { - latencyOutput.value = event.target.value -}) - let nameCustomInstanceInput = document.getElementById("exceptions-custom-instance") let instanceTypeElement = document.getElementById("exceptions-custom-instance-type") let instanceType = "url" @@ -173,20 +148,9 @@ for (const service in config.services) { } browser.storage.local.get("options", r => { - autoRedirectElement.checked = r.options.autoRedirect themeElement.value = r.options.theme - networkElement.value = r.options.network - networkFallbackCheckbox.checked = r.options.networkFallback - latencyOutput.value = r.options.latencyThreshold let options = r.options - //let networkFallbackElement = document.getElementById("network-fallback") - if (networkElement.value == "clearnet") { - networkFallbackCheckbox.disabled = true - } else { - networkFallbackCheckbox.disabled = false - } - instanceTypeElement.addEventListener("change", event => { instanceType = event.target.options[instanceTypeElement.selectedIndex].value if (instanceType == "url") { diff --git a/src/pages/options/widgets/services.ejs b/src/pages/options/widgets/services.ejs index 109f668..ea93b1c 100644 --- a/src/pages/options/widgets/services.ejs +++ b/src/pages/options/widgets/services.ejs @@ -44,16 +44,6 @@ <% for (const frontend in config.services[service].frontends) { -%> <% if (config.services[service].frontends[frontend].instanceList) { _%>
<% for (const network in config.networks) { -%> -
- - -

Default Instances

diff --git a/src/pages/options/widgets/services.js b/src/pages/options/widgets/services.js index 1290413..351d45e 100644 --- a/src/pages/options/widgets/services.js +++ b/src/pages/options/widgets/services.js @@ -108,7 +108,6 @@ for (const service in config.services) { for (const network in config.networks) { utils.processDefaultCustomInstances(service, frontend, network, document) } - utils.latency(service, frontend, document, location) } } } diff --git a/src/pages/popup/popup.ejs b/src/pages/popup/popup.ejs index e6cc6fc..72c96d6 100644 --- a/src/pages/popup/popup.ejs +++ b/src/pages/popup/popup.ejs @@ -1,55 +1,53 @@ - - - - - - - -
- - <%- include('src/pages/widgets/switches', {services: services}) -%> -
-
-
+ + + + + + + + + +
+ <%- include('src/pages/widgets/switches', {services: services}) -%> +
+
-
- <%- include('src/pages/widgets/switches', {services: services}) -%> -
-
- - - - - -
- - - - +
+
+ <%- include('src/pages/widgets/switches', {services: services}) -%> +
+
+ + + + +
+ + + + + \ No newline at end of file diff --git a/src/pages/popup/popup.js b/src/pages/popup/popup.js index 88c1433..1ac804d 100644 --- a/src/pages/popup/popup.js +++ b/src/pages/popup/popup.js @@ -39,7 +39,6 @@ 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 = {} @@ -58,7 +57,6 @@ const currentSiteIsFrontend = document.getElementById("current_site_divider") 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") @@ -75,7 +73,6 @@ browser.storage.local.get(["options", "redirects"], r => { url = new URL(tabs[0].url) } catch { currentSiteIsFrontend.classList.add("hide") - document.getElementById("unify_div").style.display = "none" return } @@ -89,51 +86,11 @@ browser.storage.local.get(["options", "redirects"], r => { service = service[0] let isCustom = false for (const network in config.networks) if (r.options[frontend][network].custom.indexOf(instance) > -1) isCustom = true - if (!isCustom) { - 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 available 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") - if (frontend && config.services[service].frontends[frontend].preferences && !config.services[service].frontends[frontend].preferences.token) { - const unify = document.getElementById("unify") - const textElement = document.getElementById("unify").getElementsByTagName("h4")[0] - unify.addEventListener("click", () => { - const oldHtml = textElement.innerHTML - textElement.innerHTML = "..." - browser.runtime.sendMessage({ function: "unify" }, response => { - if (response && response.response) textElement.innerHTML = oldHtml - }) - }) - } else { - document.getElementById("unify_div").style.display = "none" - } } else { currentSiteIsFrontend.classList.add("hide") - document.getElementById("unify_div").style.display = "none" } }) }) From decc32e7e6fc729e2aec7adc46949b0f63bc3a04 Mon Sep 17 00:00:00 2001 From: ManeraKai Date: Wed, 7 Dec 2022 10:52:08 +0300 Subject: [PATCH 02/17] Sorted the instances out https://github.com/libredirect/libredirect/issues/537 --- src/assets/javascripts/utils.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/assets/javascripts/utils.js b/src/assets/javascripts/utils.js index 4dd537f..2b69e9a 100644 --- a/src/assets/javascripts/utils.js +++ b/src/assets/javascripts/utils.js @@ -103,6 +103,11 @@ async function processDefaultCustomInstances(service, frontend, network, documen
`, ...redirects[frontend][network] + .sort((a, b) => + (cloudflareBlackList.includes(a) && !cloudflareBlackList.includes(b)) + || + (authenticateBlackList.includes(a) && !authenticateBlackList.includes(b)) + ) .map(x => { const cloudflare = cloudflareBlackList.includes(x) ? ' cloudflare' : "" const authenticate = authenticateBlackList.includes(x) ? ' authenticate' : "" From 3d0e12cd4ca2910ed2d03f0439f61bbce6180af3 Mon Sep 17 00:00:00 2001 From: Jacob Parnell Date: Wed, 7 Dec 2022 19:02:58 -0600 Subject: [PATCH 03/17] Fix instance fetching for BreezeWiki --- src/instances/get_instances.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/instances/get_instances.py b/src/instances/get_instances.py index 65b1fc4..8121cea 100755 --- a/src/instances/get_instances.py +++ b/src/instances/get_instances.py @@ -442,9 +442,7 @@ def libreTranslate(): def breezeWiki(): - fetchRegexList('breezeWiki', 'BreezeWiki', 'https://gitdab.com/cadence/breezewiki-docs/raw/branch/main/docs.scrbl', - r"\(\"[^\n\s\r\t\f\v\"]+\" \"https?:\/{2}(?:[^\s\/]+\.)+[a-zA-Z0-9]+(?:\/[^\s\/]+)*\" \"(https?:\/{2}(?:[^\s\/]+\.)+[a-zA-Z0-9]+(?:\/[^\s\/]+)*)\"\)") - + fetchJsonList('breezeWiki', 'BreezeWiki', 'https://docs.breezewiki.com/files/instances.json', 'instance', False) def privateBin(): fetchJsonList('privateBin', 'PrivateBin', From d7e835ba0bfbd7e8d74f8704a6bc43cfb0bb847f Mon Sep 17 00:00:00 2001 From: ManeraKai Date: Thu, 8 Dec 2022 11:43:16 +0300 Subject: [PATCH 04/17] removed ToggleTab from the contextMenu https://github.com/libredirect/libredirect/issues/474 --- src/pages/background/background.js | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/src/pages/background/background.js b/src/pages/background/background.js index 2db6dc0..33f0d40 100644 --- a/src/pages/background/background.js +++ b/src/pages/background/background.js @@ -112,20 +112,6 @@ browser.contextMenus.create({ contexts: ["browser_action"], }) -try { - browser.contextMenus.create({ - id: "toggleTab", - title: browser.i18n.getMessage("toggleTab"), - contexts: ["page", "tab"], - }) -} catch { - browser.contextMenus.create({ - id: "toggleTab", - title: browser.i18n.getMessage("toggleTab"), - contexts: ["page"], - }) -} - browser.contextMenus.create({ id: "redirectLink", title: browser.i18n.getMessage("redirectLink"), From e7f3b7d1c1c1c09b119e3de6796f0bfb39b3e1ae Mon Sep 17 00:00:00 2001 From: ManeraKai Date: Thu, 8 Dec 2022 11:59:06 +0300 Subject: [PATCH 05/17] Keeping the other url parameters in Search redirections https://github.com/libredirect/libredirect/issues/523 --- src/assets/javascripts/services.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/assets/javascripts/services.js b/src/assets/javascripts/services.js index 5463bfc..0f92d93 100644 --- a/src/assets/javascripts/services.js +++ b/src/assets/javascripts/services.js @@ -138,11 +138,11 @@ function redirect(url, type, initiator, forceRedirection) { else return `${randomInstance}${url.pathname}/` case "searx": case "searxng": - return `${randomInstance}/?q=${encodeURIComponent(url.searchParams.get("q"))}` + return `${randomInstance}/${url.search}` case "whoogle": - return `${randomInstance}/search?q=${encodeURIComponent(url.searchParams.get("q"))}` + return `${randomInstance}/search${url.search}` case "librex": - return `${randomInstance}/search.php?q=${encodeURIComponent(url.searchParams.get("q"))}` + return `${randomInstance}/search.php${url.search}` case "send": return randomInstance case "nitter": From 79a768d7422f7a7e31dea3e18a5b71bb6529f3b1 Mon Sep 17 00:00:00 2001 From: ManeraKai Date: Thu, 8 Dec 2022 12:31:43 +0300 Subject: [PATCH 06/17] Added reddit search to redirections https://github.com/libredirect/libredirect/issues/522 --- src/config/config.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/config/config.json b/src/config/config.json index 31940b2..a7d2014 100644 --- a/src/config/config.json +++ b/src/config/config.json @@ -180,7 +180,7 @@ } }, "targets": [ - "^https?:\\/{2}(www\\.|old\\.|np\\.|new\\.|amp\\.|)reddit\\.com(?=\\/u(ser)?\\/|\\/r\\/|\\/?$)", + "^https?:\\/{2}(www\\.|old\\.|np\\.|new\\.|amp\\.|)reddit\\.com(?=\\/u(ser)?\\/|\\/r\\/|\\/search|\\/?$)", "^https?:\\/{2}(i|(external-)?preview)\\.redd\\.it" ], "name": "Reddit", From ee4ee90e1aa8418926cdafbf951624b0e8a53799 Mon Sep 17 00:00:00 2001 From: ManeraKai Date: Thu, 8 Dec 2022 12:47:07 +0300 Subject: [PATCH 07/17] Fixed PeerTube redirections https://github.com/libredirect/libredirect/issues/545 --- src/assets/javascripts/services.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/assets/javascripts/services.js b/src/assets/javascripts/services.js index 0f92d93..c59e434 100644 --- a/src/assets/javascripts/services.js +++ b/src/assets/javascripts/services.js @@ -47,7 +47,9 @@ function all(service, frontend, options, config, redirects) { function regexArray(service, url, config, frontend) { if (config.services[service].targets == "datajson") { - if (targets[service].startsWith(utils.protocolHost(url))) return true + for (const instance of targets[service]) { + if (instance.startsWith(utils.protocolHost(url))) return true + } } else { const targetList = config.services[service].targets if (frontend && config.services[service].frontends[frontend].excludeTargets) @@ -443,8 +445,10 @@ function redirect(url, type, initiator, forceRedirection) { else return `${randomInstance}${url.pathname}${url.search}&teddit_proxy=${url.hostname}` } return `${randomInstance}${url.pathname}${url.search}` + case "simpleertube": + return `${randomInstance}/${url.hostname}${url.pathname}${url.search}` default: - return `${randomInstance}${url.pathname}${url.search}` + return `${randomInstance}${url.pathname}${url.search} ` } } @@ -506,7 +510,7 @@ function switchInstance(url) { return } const randomInstance = utils.getRandomInstance(instancesList) - const oldUrl = `${oldInstance}${url.pathname}${url.search}` + const oldUrl = `${oldInstance}${url.pathname}${url.search} ` // This is to make instance switching work when the instance depends on the pathname, eg https://darmarit.org/searx // Doesn't work because of .includes array method, not a top priotiry atm resolve(oldUrl.replace(oldInstance, randomInstance)) From c702c1d469abfde8465b9864b88fda35f3c134f8 Mon Sep 17 00:00:00 2001 From: ManeraKai Date: Thu, 8 Dec 2022 12:48:55 +0300 Subject: [PATCH 08/17] converted the search keyword from 'libredirect' to '@libredirect' https://github.com/libredirect/libredirect/issues/546 --- src/manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/manifest.json b/src/manifest.json index 2730d16..a1b8e8d 100644 --- a/src/manifest.json +++ b/src/manifest.json @@ -39,7 +39,7 @@ "chrome_settings_overrides": { "search_provider": { "name": "__MSG_extensionName__", - "keyword": "libredirect", + "keyword": "@libredirect", "favicon_url": "https://raw.githubusercontent.com/libredirect/libredirect/master/src/assets/images/libredirect-16.png", "search_url": "https://search.libredirect.invalid/?q={searchTerms}", "encoding": "UTF-8", From 2a738e883c5c48207a1f9e737feb3ce53fdd969b Mon Sep 17 00:00:00 2001 From: ManeraKai Date: Thu, 8 Dec 2022 20:59:52 +0300 Subject: [PATCH 09/17] Added Url Parameters support for Invidious, Piped https://github.com/libredirect/libredirect/issues/491 --- src/assets/javascripts/services.js | 9 +++++++-- src/assets/javascripts/utils.js | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/assets/javascripts/services.js b/src/assets/javascripts/services.js index c59e434..0b418f9 100644 --- a/src/assets/javascripts/services.js +++ b/src/assets/javascripts/services.js @@ -97,6 +97,9 @@ function redirect(url, type, initiator, forceRedirection) { break } if (!frontend || !randomInstance) return + let randomInstanceURL = new URL(randomInstance); + let allParams = randomInstanceURL.searchParams + url.searchParams.forEach((value, key) => allParams.append(key, value)) // Here is a (temperory) space for defining constants required in 2 or more switch cases. // When possible, try have the two switch cases share all their code as done with searx and searxng. @@ -116,7 +119,6 @@ function redirect(url, type, initiator, forceRedirection) { } return [zoom, lon, lat] } - console.log(frontend) switch (frontend) { // This is where all instance-specific code must be ran to convert the service url to one that can be understood by the frontend. case "beatbump": @@ -447,8 +449,11 @@ function redirect(url, type, initiator, forceRedirection) { return `${randomInstance}${url.pathname}${url.search}` case "simpleertube": return `${randomInstance}/${url.hostname}${url.pathname}${url.search}` + case "invidious": + case "piped": + return `${utils.protocolHost(randomInstanceURL)}${url.pathname}?${allParams.toString()}` default: - return `${randomInstance}${url.pathname}${url.search} ` + return `${randomInstance}${url.pathname}${url.search}` } } diff --git a/src/assets/javascripts/utils.js b/src/assets/javascripts/utils.js index 2b69e9a..dce7f34 100644 --- a/src/assets/javascripts/utils.js +++ b/src/assets/javascripts/utils.js @@ -188,7 +188,7 @@ async function processDefaultCustomInstances(service, frontend, network, documen event.preventDefault() let frontendCustomInstanceInput = frontendNetworkElement.getElementsByClassName("custom-instance")[0] let url = new URL(frontendCustomInstanceInput.value) - let protocolHostVar = protocolHost(url) + let protocolHostVar = url.href if (frontendCustomInstanceInput.validity.valid && !redirects[frontend][network].includes(protocolHostVar)) { if (!frontendCustomInstances.includes(protocolHostVar)) { frontendCustomInstances.push(protocolHostVar) From ad4c00e663d8451557a4b77520c97b656fb23439 Mon Sep 17 00:00:00 2001 From: ManeraKai Date: Sat, 10 Dec 2022 10:48:21 +0300 Subject: [PATCH 10/17] Revert "Added Url Parameters support for Invidious, Piped https://github.com/libredirect/libredirect/issues/491" This reverts commit 2a738e883c5c48207a1f9e737feb3ce53fdd969b. --- src/assets/javascripts/services.js | 9 ++------- src/assets/javascripts/utils.js | 2 +- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/src/assets/javascripts/services.js b/src/assets/javascripts/services.js index 0b418f9..c59e434 100644 --- a/src/assets/javascripts/services.js +++ b/src/assets/javascripts/services.js @@ -97,9 +97,6 @@ function redirect(url, type, initiator, forceRedirection) { break } if (!frontend || !randomInstance) return - let randomInstanceURL = new URL(randomInstance); - let allParams = randomInstanceURL.searchParams - url.searchParams.forEach((value, key) => allParams.append(key, value)) // Here is a (temperory) space for defining constants required in 2 or more switch cases. // When possible, try have the two switch cases share all their code as done with searx and searxng. @@ -119,6 +116,7 @@ function redirect(url, type, initiator, forceRedirection) { } return [zoom, lon, lat] } + console.log(frontend) switch (frontend) { // This is where all instance-specific code must be ran to convert the service url to one that can be understood by the frontend. case "beatbump": @@ -449,11 +447,8 @@ function redirect(url, type, initiator, forceRedirection) { return `${randomInstance}${url.pathname}${url.search}` case "simpleertube": return `${randomInstance}/${url.hostname}${url.pathname}${url.search}` - case "invidious": - case "piped": - return `${utils.protocolHost(randomInstanceURL)}${url.pathname}?${allParams.toString()}` default: - return `${randomInstance}${url.pathname}${url.search}` + return `${randomInstance}${url.pathname}${url.search} ` } } diff --git a/src/assets/javascripts/utils.js b/src/assets/javascripts/utils.js index dce7f34..2b69e9a 100644 --- a/src/assets/javascripts/utils.js +++ b/src/assets/javascripts/utils.js @@ -188,7 +188,7 @@ async function processDefaultCustomInstances(service, frontend, network, documen event.preventDefault() let frontendCustomInstanceInput = frontendNetworkElement.getElementsByClassName("custom-instance")[0] let url = new URL(frontendCustomInstanceInput.value) - let protocolHostVar = url.href + let protocolHostVar = protocolHost(url) if (frontendCustomInstanceInput.validity.valid && !redirects[frontend][network].includes(protocolHostVar)) { if (!frontendCustomInstances.includes(protocolHostVar)) { frontendCustomInstances.push(protocolHostVar) From c19491edc01b9e7cd009bc8f63bf8b1dcd95605e Mon Sep 17 00:00:00 2001 From: ManeraKai Date: Sat, 10 Dec 2022 11:59:28 +0300 Subject: [PATCH 11/17] Added partial BreezWiki Copy Raw support https://github.com/libredirect/libredirect/issues/513 --- src/assets/javascripts/services.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/assets/javascripts/services.js b/src/assets/javascripts/services.js index c59e434..8bba127 100644 --- a/src/assets/javascripts/services.js +++ b/src/assets/javascripts/services.js @@ -413,7 +413,7 @@ function redirect(url, type, initiator, forceRedirection) { if (url.hostname.match(/^[a-zA-Z0-9-]+\.fandom\.com/)) { wiki = url.hostname.match(/^[a-zA-Z0-9-]+(?=\.fandom\.com)/) if (wiki == "www" || !wiki) wiki = "" - else wiki = "/" + wiki + else wiki = `/${wiki}`; urlpath = url.pathname } else { wiki = url.pathname.match(/(?<=wiki\/w:c:)[a-zA-Z0-9-]+(?=:)/) @@ -545,6 +545,14 @@ function reverse(url, urlString) { if (!urlString) resolve(config.services[service].url + url.pathname + url.search) else resolve(url.replace(/https?:\/{2}(?:[^\s\/]+\.)+[a-zA-Z0-9]+/, config.services[service].url)) return + case "fandom": + let regex = url.pathname.match(/^\/([a-zA-Z0-9-]+)\/wiki\/([a-zA-Z0-9-]+)/) + if (regex) { + resolve(`https://${regex[1]}.fandom.com/wiki/${regex[2]}`) + return + } + resolve() + return default: resolve() return From 0d0ea9d2a4199e905432bc435fbf4373702a3d53 Mon Sep 17 00:00:00 2001 From: ManeraKai Date: Sat, 10 Dec 2022 12:06:28 +0300 Subject: [PATCH 12/17] Fixed Isntagram reels not redirecting https://github.com/libredirect/libredirect/issues/559 --- src/assets/javascripts/services.js | 3 ++- src/config/config.json | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/assets/javascripts/services.js b/src/assets/javascripts/services.js index 8bba127..01523d5 100644 --- a/src/assets/javascripts/services.js +++ b/src/assets/javascripts/services.js @@ -130,7 +130,8 @@ function redirect(url, type, initiator, forceRedirection) { case "bibliogram": const reservedPaths = ["u", "p", "privacy"] if (url.pathname === "/" || reservedPaths.includes(url.pathname.split("/")[1])) return `${randomInstance}${url.pathname}${url.search}` - if (url.pathname.startsWith("/reel") || url.pathname.startsWith("/tv")) return `${randomInstance}/p${url.pathname.replace(/\/reel|\/tv/i, "")}${url.search}` + if (url.pathname.startsWith("/reel")) return `${randomInstance}${url.pathname}` + if (url.pathname.startsWith("/tv")) return `${randomInstance}/p${url.pathname.replace(/\/tv/i, "")}${url.search}` else return `${randomInstance}/u${url.pathname}${url.search}` // Likely a user profile, redirect to '/u/...' case "lbryDesktop": return url.href.replace(/^https?:\/{2}odysee\.com\//, "lbry://").replace(/:(?=[a-zA-Z0-9])/g, "#") diff --git a/src/config/config.json b/src/config/config.json index a7d2014..cb0ed50 100644 --- a/src/config/config.json +++ b/src/config/config.json @@ -140,7 +140,7 @@ } }, "targets": [ - "^https?:\\/{2}(www\\.)?instagram\\.com\\/?(p\\/|$)" + "^https?:\\/{2}(www\\.)?instagram\\.com\\/?(p\\/|reel\\/|$)" ], "name": "Instagram", "options": { From d17377e6a54ca4490c14d6ad2b617fd9311f2efb Mon Sep 17 00:00:00 2001 From: ManeraKai Date: Sat, 10 Dec 2022 12:44:40 +0300 Subject: [PATCH 13/17] Reverting back to Github + other stuff. Correcting http => https https://github.com/libredirect/libredirect/pull/482 --- src/assets/javascripts/utils.js | 2 +- src/pages/options/widgets/about.ejs | 8 ++++---- src/pages/options/widgets/general.js | 2 +- src/pages/popup/popup.ejs | 6 ------ 4 files changed, 6 insertions(+), 12 deletions(-) diff --git a/src/assets/javascripts/utils.js b/src/assets/javascripts/utils.js index 2b69e9a..b38277a 100644 --- a/src/assets/javascripts/utils.js +++ b/src/assets/javascripts/utils.js @@ -159,7 +159,7 @@ async function processDefaultCustomInstances(service, frontend, network, documen x => `
${x} diff --git a/src/pages/options/widgets/about.ejs b/src/pages/options/widgets/about.ejs index a90e8b9..c6f8a58 100644 --- a/src/pages/options/widgets/about.ejs +++ b/src/pages/options/widgets/about.ejs @@ -10,22 +10,22 @@
diff --git a/src/pages/options/widgets/general.js b/src/pages/options/widgets/general.js index a8eb11f..a73ac85 100644 --- a/src/pages/options/widgets/general.js +++ b/src/pages/options/widgets/general.js @@ -168,7 +168,7 @@ browser.storage.local.get("options", r => { x => `
${x}
-
From 9bca5e8a3c7aa75013925de63c455fa6d627d55d Mon Sep 17 00:00:00 2001 From: Ikel Atomig Date: Mon, 26 Dec 2022 03:00:16 +0000 Subject: [PATCH 14/17] Update README --- README.md | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 4d57cf5..4fb497b 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,8 @@ A web extension that redirects YouTube, Twitter, Instagram... requests to altern [![Firefox users Badge](https://img.shields.io/amo/users/libredirect?label=Firefox%20users)](https://addons.mozilla.org/firefox/addon/libredirect/) [![LibrePay Badge](https://img.shields.io/liberapay/gives/libredirect?label=Liberapay)](https://liberapay.com/LibRedirect) +[![OpenCollective Badge](https://opencollective.com/libredirect/tiers/badge.svg)](https://opencollective.com/libredirect#category-CONTRIBUTE) + [![Firefox Add-on](./img/badge-amo.png)](https://addons.mozilla.org/firefox/addon/libredirect/)  @@ -31,7 +33,7 @@ A web extension that redirects YouTube, Twitter, Instagram... requests to altern - LBRY/Odysee => [Librarian](https://codeberg.org/librarian/librarian), [LBRY Desktop](https://lbry.com/get) - Search => [SearXNG](https://github.com/searxng/searxng), [SearX](https://searx.github.io/searx/), [Whoogle](https://benbusby.com/projects/whoogle-search/), [LibreX](https://github.com/hnhx/librex/) - Translate => [SimplyTranslate](https://git.sr.ht/~metalune/simplytranslate_web), [LingvaTranslate](https://github.com/TheDavidDelta/lingva-translate), [LibreTranslate](https://github.com/LibreTranslate/LibreTranslate) -- Maps => [OpenStreetMap](https://www.openstreetmap.org/), [FacilMap](https://github.com/FacilMap/facilmap) +- Google Maps => [OpenStreetMap](https://www.openstreetmap.org/), [FacilMap](https://github.com/FacilMap/facilmap) - Send Files => [Send](https://gitlab.com/timvisee/send) **Note**: The Extension will be using random instances by default. You can modify this and add custom instances too. @@ -43,10 +45,8 @@ A web extension that redirects YouTube, Twitter, Instagram... requests to altern [![Liberapay](./img/liberapay.svg)](https://liberapay.com/LibRedirect)  [![Patreon](./img/patreon.svg)](https://patreon.com/LibRedirect)  [![Buy me a coffee](./img/bmc.svg)](https://www.buymeacoffee.com/libredirect)  - + -- BTC: `bc1qrhue0frps6p2vkg978u9ayethnwprtmfug827q` -- BCH: `qqz5vfnrngk0tjy73q2688qzw4wnllnuzqfndflhl8` - ETH: `0x896E5796Da76E49A400A9186E1c459CD2C64b4E8` - XMR: `4AM5CVfaGsnEXQQjZSzJvaWufe7pT86ubcZPr83fCjb2Hn3iwcForTWFy2Z3ugXcufUwHaGcucfPMFgPXBFSYGFvNrmV5XR` @@ -117,5 +117,8 @@ npm run start 3. select `load unpacked extension` 4. select `src` folder +--- + [Privacy Policy](Privacy-Policy.md)\ Forked from [Privacy Redirect](https://github.com/SimonBrazell/privacy-redirect) + From 05acfaf7097d92b9872b5df26e1b6aa4f9299c37 Mon Sep 17 00:00:00 2001 From: Ikel Atomig Date: Mon, 26 Dec 2022 03:01:30 +0000 Subject: [PATCH 15/17] Fix badge size --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 4fb497b..8606f99 100644 --- a/README.md +++ b/README.md @@ -45,7 +45,7 @@ A web extension that redirects YouTube, Twitter, Instagram... requests to altern [![Liberapay](./img/liberapay.svg)](https://liberapay.com/LibRedirect)  [![Patreon](./img/patreon.svg)](https://patreon.com/LibRedirect)  [![Buy me a coffee](./img/bmc.svg)](https://www.buymeacoffee.com/libredirect)  - + - ETH: `0x896E5796Da76E49A400A9186E1c459CD2C64b4E8` - XMR: `4AM5CVfaGsnEXQQjZSzJvaWufe7pT86ubcZPr83fCjb2Hn3iwcForTWFy2Z3ugXcufUwHaGcucfPMFgPXBFSYGFvNrmV5XR` From ca4a90aecd1a4a6a4f73a52b4bdd57a372592911 Mon Sep 17 00:00:00 2001 From: Ikel Atomig Date: Mon, 26 Dec 2022 03:01:57 +0000 Subject: [PATCH 16/17] Re fix badge size --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 8606f99..07b13bb 100644 --- a/README.md +++ b/README.md @@ -45,7 +45,7 @@ A web extension that redirects YouTube, Twitter, Instagram... requests to altern [![Liberapay](./img/liberapay.svg)](https://liberapay.com/LibRedirect)  [![Patreon](./img/patreon.svg)](https://patreon.com/LibRedirect)  [![Buy me a coffee](./img/bmc.svg)](https://www.buymeacoffee.com/libredirect)  - + - ETH: `0x896E5796Da76E49A400A9186E1c459CD2C64b4E8` - XMR: `4AM5CVfaGsnEXQQjZSzJvaWufe7pT86ubcZPr83fCjb2Hn3iwcForTWFy2Z3ugXcufUwHaGcucfPMFgPXBFSYGFvNrmV5XR` From 9ad0edf1814ff21ac4aa43a47ead24693c23107b Mon Sep 17 00:00:00 2001 From: Ikel Atomig Date: Mon, 26 Dec 2022 07:16:32 +0000 Subject: [PATCH 17/17] Shift to OpenCollective --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 07b13bb..52aedc2 100644 --- a/README.md +++ b/README.md @@ -45,11 +45,11 @@ A web extension that redirects YouTube, Twitter, Instagram... requests to altern [![Liberapay](./img/liberapay.svg)](https://liberapay.com/LibRedirect)  [![Patreon](./img/patreon.svg)](https://patreon.com/LibRedirect)  [![Buy me a coffee](./img/bmc.svg)](https://www.buymeacoffee.com/libredirect)  - + -- ETH: `0x896E5796Da76E49A400A9186E1c459CD2C64b4E8` - XMR: `4AM5CVfaGsnEXQQjZSzJvaWufe7pT86ubcZPr83fCjb2Hn3iwcForTWFy2Z3ugXcufUwHaGcucfPMFgPXBFSYGFvNrmV5XR` +Note : We have removed our addresses for BTC and ETH. If you want to donate via Crypto use OpenCollective. We still have XMR as OpenCollective doesn't support it. ## Mirror Repos [![Codeberg](https://raw.githubusercontent.com/ManeraKai/manerakai/main/icons/codeberg.svg)](https://codeberg.org/LibRedirect/libredirect)