This commit is contained in:
ManeraKai 2023-11-24 21:44:14 +03:00
parent 928d5f9da1
commit 5e51ebd95a
No known key found for this signature in database
GPG Key ID: 5ABC31FFD562E337
4 changed files with 22 additions and 11 deletions

View File

@ -68,10 +68,11 @@ async function redirectAsync(url, type, initiator, forceRedirection) {
* @param {boolean} forceRedirection * @param {boolean} forceRedirection
* @returns {string | undefined} * @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 if (type != "main_frame" && type != "sub_frame" && type != "image") return
let randomInstance let randomInstance
let frontend let frontend
if (!forceRedirection && options.redirectOnlyInIncognito == true && !incognito) return
for (const service in config.services) { for (const service in config.services) {
if (!forceRedirection && !options[service].enabled) continue if (!forceRedirection && !options[service].enabled) continue
@ -762,9 +763,10 @@ function initDefaults() {
url: [], url: [],
regex: [], regex: [],
} }
options['theme'] = "detect" options.theme = "detect"
options['popupServices'] = ["youtube", "twitter", "tiktok", "imgur", "reddit", "quora", "translate", "maps"] options.popupServices = ["youtube", "twitter", "tiktok", "imgur", "reddit", "quora", "translate", "maps"]
options['fetchInstances'] = 'github' options.fetchInstances = 'github'
options.redirectOnlyInIncognito = false
options = { ...options, ...defaultInstances } options = { ...options, ...defaultInstances }

View File

@ -41,7 +41,7 @@ browser.webRequest.onBeforeRequest.addListener(
return null return null
} }
if (tabIdRedirects[details.tabId] == false) 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 if (details.frameAncestors && details.frameAncestors.length > 0 && servicesHelper.isException(new URL(details.frameAncestors[0].url))) newUrl = null

View File

@ -64,7 +64,6 @@ importSettingsElement.addEventListener("change", () => {
} }
}) })
const exportSettingsSync = document.getElementById("export-settings-sync") const exportSettingsSync = document.getElementById("export-settings-sync")
const importSettingsSync = document.getElementById("import-settings-sync") const importSettingsSync = document.getElementById("import-settings-sync")
const importSettingsSyncText = document.getElementById("import_settings_sync_text") const importSettingsSyncText = document.getElementById("import_settings_sync_text")
@ -105,6 +104,11 @@ fetchInstancesElement.addEventListener('change', event => {
location.reload() location.reload()
}) })
const redirectOnlyInIncognitoElement = document.getElementById('redirectOnlyInIncognito')
redirectOnlyInIncognitoElement.addEventListener('change', event => {
setOption('redirectOnlyInIncognito', 'checkbox', event)
})
let themeElement = document.getElementById("theme") let themeElement = document.getElementById("theme")
themeElement.addEventListener("change", event => { themeElement.addEventListener("change", event => {
setOption("theme", "select", event) setOption("theme", "select", event)
@ -132,6 +136,7 @@ for (const service in config.services) {
let options = await utils.getOptions() let options = await utils.getOptions()
themeElement.value = options.theme themeElement.value = options.theme
fetchInstancesElement.value = options.fetchInstances fetchInstancesElement.value = options.fetchInstances
redirectOnlyInIncognitoElement.target.checked = options.redirectOnlyInIncognito
for (const service in config.services) document.getElementById(service).checked = options.popupServices.includes(service) for (const service in config.services) document.getElementById(service).checked = options.popupServices.includes(service)
instanceTypeElement.addEventListener("change", event => { instanceTypeElement.addEventListener("change", event => {

View File

@ -17,6 +17,10 @@ section(class="block-option" id="general_page")
option(value="codeberg") Codeberg option(value="codeberg") Codeberg
option(value="disable" data-localise="__MSG_disable__") Disable 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") div(class="block block-option")
label(data-localise="__MSG_excludeFromRedirecting__") Excluded from redirecting label(data-localise="__MSG_excludeFromRedirecting__") Excluded from redirecting