From 57c978b6483cb5d0655fe6b1d898be816c4f36df Mon Sep 17 00:00:00 2001 From: Daniel Date: Sat, 11 Nov 2023 18:12:36 +0100 Subject: Add jsdoc types for some functions For VSCode completion --- src/pages/options/index.js | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'src/pages') diff --git a/src/pages/options/index.js b/src/pages/options/index.js index dd1a6ff8..fcc51298 100644 --- a/src/pages/options/index.js +++ b/src/pages/options/index.js @@ -17,6 +17,9 @@ for (const a of document.getElementById("links").getElementsByTagName("a")) { config = await utils.getConfig() options = await utils.getOptions() +/** + * @param {string} service + */ async function changeFrontendsSettings(service) { options = await utils.getOptions() const opacityDiv = document.getElementById(`${service}-opacity`) @@ -95,6 +98,9 @@ async function changeFrontendsSettings(service) { frontend_name_element.href = config.services[service].frontends[divs[service].frontend.value].url } +/** + * @param {string} path + */ async function loadPage(path) { options = await utils.getOptions() for (const section of document.getElementById("pages").getElementsByTagName("section")) section.style.display = "none" @@ -251,6 +257,13 @@ async function processCustomInstances(frontend, document) { }) } +/** + * @param {string} frontend + * @param {*} networks + * @param {*} document + * @param {*} redirects + * @param {*} blacklist + */ async function createList(frontend, networks, document, redirects, blacklist) { const pingCache = await utils.getPingCache() const options = await utils.getOptions() @@ -331,6 +344,9 @@ const r = window.location.href.match(/#(.*)/) if (r) loadPage(r[1]) else loadPage("general") +/** + * @param {string} frontend + */ async function ping(frontend) { const instanceElements = [ ...document.getElementById(frontend).getElementsByClassName("custom-checklist")[0].getElementsByTagName('x'), @@ -357,6 +373,9 @@ async function ping(frontend) { } } +/** + * @param {number} time + */ function processTime(time) { let text let color @@ -377,4 +396,4 @@ function processTime(time) { return { color, text } -} \ No newline at end of file +} -- cgit 1.4.1 From 1a0e640e3c90f170365de9fa13f97cd2387ce3d5 Mon Sep 17 00:00:00 2001 From: ManeraKai Date: Sun, 19 Nov 2023 17:42:01 +0300 Subject: Fixed a bug in upgrading popupServices settings https://github.com/libredirect/browser_extension/issues/829 --- package.json | 6 +++--- src/assets/javascripts/services.js | 9 ++++++++- src/pages/options/widgets/general.js | 2 +- 3 files changed, 12 insertions(+), 5 deletions(-) (limited to 'src/pages') diff --git a/package.json b/package.json index 76eb63eb..139d4773 100644 --- a/package.json +++ b/package.json @@ -23,8 +23,8 @@ }, "homepage": "https://libredirect.github.io", "devDependencies": { - "web-ext": "^7.2.0", - "pug-cli": "^1.0.0-alpha6" + "pug-cli": "^1.0.0-alpha6", + "web-ext": "^7.2.0" }, "webExt": { "sourceDir": "./src/", @@ -35,4 +35,4 @@ "overwriteDest": true } } -} \ No newline at end of file +} diff --git a/src/assets/javascripts/services.js b/src/assets/javascripts/services.js index 8265a82e..dbbe7c9f 100644 --- a/src/assets/javascripts/services.js +++ b/src/assets/javascripts/services.js @@ -551,7 +551,7 @@ function redirect(url, type, initiator, forceRedirection) { } return `${randomInstance}` } - case "twineo": + case "twineo": case "safetwitch": { if (url.hostname.startsWith("clips.")) { return `${randomInstance}/clip${url.pathname}${url.search}` @@ -804,6 +804,13 @@ function processUpdate() { delete options[frontend] } } + + for (const frontend of options.popupServices) { + if (!Object.keys(config.services).includes(frontend)) { + const i = options.popupServices.indexOf(frontend); + if (i > -1) options.popupServices.splice(i, 1); + } + } } browser.storage.local.set({ options }, () => { resolve() diff --git a/src/pages/options/widgets/general.js b/src/pages/options/widgets/general.js index ed61440b..08e073f5 100644 --- a/src/pages/options/widgets/general.js +++ b/src/pages/options/widgets/general.js @@ -99,7 +99,7 @@ resetSettings.addEventListener("click", async () => { location.reload() }) -let fetchInstancesElement = document.getElementById('fetch-instances') +const fetchInstancesElement = document.getElementById('fetch-instances') fetchInstancesElement.addEventListener('change', event => { setOption('fetchInstances', 'select', event) location.reload() -- cgit 1.4.1 From 4ed67a3f73a63e6d680be9c1f8eccbe8ff570b4e Mon Sep 17 00:00:00 2001 From: ManeraKai Date: Fri, 24 Nov 2023 21:22:43 +0300 Subject: Added Skyview https://github.com/libredirect/browser_extension/issues/834 --- src/assets/images/bluesky-icon.svg | 63 ++++++++++++++++++++++++++++++++++++++ src/assets/javascripts/services.js | 9 ++++++ src/config.json | 30 ++++++++++++++++++ src/pages/stylesheets/styles.css | 2 +- 4 files changed, 103 insertions(+), 1 deletion(-) create mode 100644 src/assets/images/bluesky-icon.svg (limited to 'src/pages') diff --git a/src/assets/images/bluesky-icon.svg b/src/assets/images/bluesky-icon.svg new file mode 100644 index 00000000..8e916784 --- /dev/null +++ b/src/assets/images/bluesky-icon.svg @@ -0,0 +1,63 @@ + + + + diff --git a/src/assets/javascripts/services.js b/src/assets/javascripts/services.js index dbbe7c9f..ac87cb67 100644 --- a/src/assets/javascripts/services.js +++ b/src/assets/javascripts/services.js @@ -166,6 +166,10 @@ function redirect(url, type, initiator, forceRedirection) { case "freetube": { return 'freetube://' + url.href } + case "freetubePwa": { + return 'freetube://' + url.href + } + case "poketube": { if (url.pathname.startsWith('/channel')) { const reg = /\/channel\/(.*)\/?$/.exec(url.pathname) @@ -561,6 +565,10 @@ function redirect(url, type, initiator, forceRedirection) { case "tekstoLibre": { return `${randomInstance}/?${url.pathname.slice(1)}`; } + case "skyview": { + if (url.pathname == '/') return randomInstance + return `${randomInstance}?url=${encodeURIComponent(url.href)}` + } default: { return `${randomInstance}${url.pathname}${url.search}` } @@ -731,6 +739,7 @@ const defaultInstances = { 'tuboYoutube': ['https://tubo.migalmoreno.com'], 'tuboSoundcloud': ['https://tubo.migalmoreno.com'], 'tekstoLibre': ['https://davilarek.github.io/TekstoLibre'], + 'skyview': ['https://skyview.social'], } function initDefaults() { diff --git a/src/config.json b/src/config.json index 6cc43776..f17ba8f5 100644 --- a/src/config.json +++ b/src/config.json @@ -97,6 +97,16 @@ "desktopApp": true, "instanceList": false, "url": "https://github.com/yattee/yattee" + }, + "freetubePwa": { + "excludeTargets": [ + 2, + 3 + ], + "name": "FreeTube PWA", + "embeddable": false, + "instanceList": false, + "url": "https://github.com/MarmadileManteater/FreeTubeCordova" } }, "targets": [ @@ -963,6 +973,26 @@ }, "imageType": "svg", "url": "https://www.tekstowo.pl" + }, + "bluesky": { + "frontends": { + "skyview": { + "name": "Skyview", + "instanceList": true, + "url": "https://github.com/badlogic/skyview" + } + }, + "targets": [ + "^https?:\\/{2}bsky\\.app\\/" + ], + "name": "Bluesky", + "options": { + "enabled": false, + "unsupportedUrls": "bypass", + "frontend": "skyview" + }, + "imageType": "svg", + "url": "https://bsky.app/" } } } \ No newline at end of file diff --git a/src/pages/stylesheets/styles.css b/src/pages/stylesheets/styles.css index 225023ec..2519a05f 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: 890px; + max-height: 930px; } section.links div { -- cgit 1.4.1 From 5e51ebd95a8c7f76a02f8180426ab18c9b22f7c0 Mon Sep 17 00:00:00 2001 From: ManeraKai Date: Fri, 24 Nov 2023 21:44:14 +0300 Subject: Added Redirect Only In Incognito https://github.com/libredirect/browser_extension/issues/858 --- src/assets/javascripts/services.js | 10 ++++++---- src/pages/background/background.js | 2 +- src/pages/options/widgets/general.js | 7 ++++++- src/pages/options/widgets/general.pug | 14 +++++++++----- 4 files changed, 22 insertions(+), 11 deletions(-) (limited to 'src/pages') diff --git a/src/assets/javascripts/services.js b/src/assets/javascripts/services.js index ac87cb67..5b5f42a6 100644 --- a/src/assets/javascripts/services.js +++ b/src/assets/javascripts/services.js @@ -68,10 +68,11 @@ async function redirectAsync(url, type, initiator, forceRedirection) { * @param {boolean} forceRedirection * @returns {string | undefined} */ -function redirect(url, type, initiator, forceRedirection) { +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 @@ -762,9 +763,10 @@ function initDefaults() { url: [], regex: [], } - options['theme'] = "detect" - options['popupServices'] = ["youtube", "twitter", "tiktok", "imgur", "reddit", "quora", "translate", "maps"] - options['fetchInstances'] = 'github' + options.theme = "detect" + options.popupServices = ["youtube", "twitter", "tiktok", "imgur", "reddit", "quora", "translate", "maps"] + options.fetchInstances = 'github' + options.redirectOnlyInIncognito = false options = { ...options, ...defaultInstances } diff --git a/src/pages/background/background.js b/src/pages/background/background.js index 542ef03b..4b8f1ca2 100644 --- a/src/pages/background/background.js +++ b/src/pages/background/background.js @@ -41,7 +41,7 @@ browser.webRequest.onBeforeRequest.addListener( return null } if (tabIdRedirects[details.tabId] == false) return null - let newUrl = servicesHelper.redirect(url, details.type, initiator, tabIdRedirects[details.tabId], details.tabId) + let newUrl = servicesHelper.redirect(url, details.type, initiator, tabIdRedirects[details.tabId], details.incognito) if (details.frameAncestors && details.frameAncestors.length > 0 && servicesHelper.isException(new URL(details.frameAncestors[0].url))) newUrl = null diff --git a/src/pages/options/widgets/general.js b/src/pages/options/widgets/general.js index 08e073f5..6d2d316c 100644 --- a/src/pages/options/widgets/general.js +++ b/src/pages/options/widgets/general.js @@ -64,7 +64,6 @@ importSettingsElement.addEventListener("change", () => { } }) - const exportSettingsSync = document.getElementById("export-settings-sync") const importSettingsSync = document.getElementById("import-settings-sync") const importSettingsSyncText = document.getElementById("import_settings_sync_text") @@ -105,6 +104,11 @@ fetchInstancesElement.addEventListener('change', event => { location.reload() }) +const redirectOnlyInIncognitoElement = document.getElementById('redirectOnlyInIncognito') +redirectOnlyInIncognitoElement.addEventListener('change', event => { + setOption('redirectOnlyInIncognito', 'checkbox', event) +}) + let themeElement = document.getElementById("theme") themeElement.addEventListener("change", event => { setOption("theme", "select", event) @@ -132,6 +136,7 @@ for (const service in config.services) { let options = await utils.getOptions() themeElement.value = options.theme fetchInstancesElement.value = options.fetchInstances +redirectOnlyInIncognitoElement.target.checked = options.redirectOnlyInIncognito for (const service in config.services) document.getElementById(service).checked = options.popupServices.includes(service) instanceTypeElement.addEventListener("change", event => { diff --git a/src/pages/options/widgets/general.pug b/src/pages/options/widgets/general.pug index 2e7c07da..6fa2a62b 100644 --- a/src/pages/options/widgets/general.pug +++ b/src/pages/options/widgets/general.pug @@ -17,6 +17,10 @@ section(class="block-option" id="general_page") option(value="codeberg") Codeberg option(value="disable" data-localise="__MSG_disable__") Disable + div(class="block block-option") + label(for='redirectOnlyInIncognito' data-localise="__MSG_redirectOnlyInIncognito__") Redirect Only in Incognito + input(id='redirectOnlyInIncognito' type="checkbox") + div(class="block block-option") label(data-localise="__MSG_excludeFromRedirecting__") Excluded from redirecting @@ -44,15 +48,15 @@ section(class="block-option" id="general_page") |  x(data-localise="__MSG_importSettings__") Import Settings input(id="import-settings" type="file" style="display: none") - + |   - + a(class="button button-inline" id="export-settings") svg(xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="currentColor") path(d="M10.09 15.59L11.5 17l5-5-5-5-1.41 1.41L12.67 11H3v2h9.67l-2.58 2.59zM19 3H5c-1.11 0-2 .9-2 2v4h2V5h14v14H5v-4H3v4c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2z") |  x(data-localise="__MSG_exportSettings__") Export Settings - + |   button(class="button button-inline" id="export-settings-sync") @@ -60,7 +64,7 @@ section(class="block-option" id="general_page") path(d="M10.09 15.59L11.5 17l5-5-5-5-1.41 1.41L12.67 11H3v2h9.67l-2.58 2.59zM19 3H5c-1.11 0-2 .9-2 2v4h2V5h14v14H5v-4H3v4c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2z") |  x() Export Settings to Sync - + |   button(class="button button-inline" id="import-settings-sync") @@ -70,7 +74,7 @@ section(class="block-option" id="general_page") x(id="import_settings_sync_text") Import Settings from Sync |   - + button(class="button button-inline" id="reset-settings") svg(xmlns="http://www.w3.org/2000/svg" enable-background="new 0 0 24 24" height="24px" viewBox="0 0 24 24" width="24px" fill="currentColor") path(d="M12,5V2L8,6l4,4V7c3.31,0,6,2.69,6,6c0,2.97-2.17,5.43-5,5.91v2.02c3.95-0.49,7-3.85,7-7.93C20,8.58,16.42,5,12,5z") -- cgit 1.4.1 From 0babf9719dccedde5164b203a72fdc517f914cdb Mon Sep 17 00:00:00 2001 From: ManeraKai Date: Sat, 9 Dec 2023 01:57:25 +0300 Subject: Added toggle for bookmarks menu in settings https://github.com/libredirect/browser_extension/issues/861 --- src/pages/options/widgets/general.js | 15 ++++++++++++++- src/pages/options/widgets/general.pug | 4 ++++ 2 files changed, 18 insertions(+), 1 deletion(-) (limited to 'src/pages') diff --git a/src/pages/options/widgets/general.js b/src/pages/options/widgets/general.js index 6d2d316c..6f2852a9 100644 --- a/src/pages/options/widgets/general.js +++ b/src/pages/options/widgets/general.js @@ -109,6 +109,18 @@ redirectOnlyInIncognitoElement.addEventListener('change', event => { setOption('redirectOnlyInIncognito', 'checkbox', event) }) +const bookmarksMenuElement = document.getElementById('bookmarksMenu') +bookmarksMenuElement.addEventListener('change', async event => { + if (event.target.checked) + bookmarksMenuElement.checked = await browser.permissions.request({ + permissions: ["bookmarks"] + }) + else + bookmarksMenuElement.checked = !await browser.permissions.remove({ + permissions: ["bookmarks"] + }) +}) + let themeElement = document.getElementById("theme") themeElement.addEventListener("change", event => { setOption("theme", "select", event) @@ -136,7 +148,8 @@ for (const service in config.services) { let options = await utils.getOptions() themeElement.value = options.theme fetchInstancesElement.value = options.fetchInstances -redirectOnlyInIncognitoElement.target.checked = options.redirectOnlyInIncognito +redirectOnlyInIncognitoElement.checked = options.redirectOnlyInIncognito +bookmarksMenuElement.checked = await browser.permissions.contains({ permissions: ["bookmarks"] }) for (const service in config.services) document.getElementById(service).checked = options.popupServices.includes(service) instanceTypeElement.addEventListener("change", event => { diff --git a/src/pages/options/widgets/general.pug b/src/pages/options/widgets/general.pug index 6fa2a62b..70316473 100644 --- a/src/pages/options/widgets/general.pug +++ b/src/pages/options/widgets/general.pug @@ -21,6 +21,10 @@ section(class="block-option" id="general_page") label(for='redirectOnlyInIncognito' data-localise="__MSG_redirectOnlyInIncognito__") Redirect Only in Incognito input(id='redirectOnlyInIncognito' type="checkbox") + div(class="block block-option") + label(for='bookmarksMenu' data-localise="__MSG_bookmarksMenu__") Bookmarks menu + input(id='bookmarksMenu' type="checkbox") + div(class="block block-option") label(data-localise="__MSG_excludeFromRedirecting__") Excluded from redirecting -- cgit 1.4.1