Added a option for unsupported links https://github.com/libredirect/libredirect/issues/575
This commit is contained in:
parent
b91ae8e816
commit
c5184b277f
|
@ -49,8 +49,6 @@ function redirect(url, type, initiator, forceRedirection) {
|
|||
let frontend
|
||||
for (const service in config.services) {
|
||||
if (!forceRedirection && !options[service].enabled) continue
|
||||
if (config.services[service].embeddable && type != options[service].redirectType && options[service].redirectType != "both") continue
|
||||
if (!config.services[service].embeddable && type != "main_frame") continue
|
||||
|
||||
frontend = options[service].frontend ?? Object.keys(config.services[service].frontends)[0]
|
||||
|
||||
|
@ -59,6 +57,15 @@ function redirect(url, type, initiator, forceRedirection) {
|
|||
continue
|
||||
}
|
||||
|
||||
if (
|
||||
(config.services[service].embeddable && type != options[service].redirectType && options[service].redirectType != "both")
|
||||
||
|
||||
(!config.services[service].embeddable && type != "main_frame")
|
||||
) {
|
||||
if (options[service].unsupportedUrls == 'block') return 'CANCEL'
|
||||
return
|
||||
}
|
||||
|
||||
let instanceList = options[frontend]
|
||||
if (instanceList === undefined) break
|
||||
if (instanceList.length === 0) return
|
||||
|
@ -390,12 +397,16 @@ function redirect(url, type, initiator, forceRedirection) {
|
|||
urlpath = url.pathname.match(/(?<=wiki\/w:c:[a-zA-Z0-9-]+:).+/)
|
||||
}
|
||||
}
|
||||
if (url.href.search(/Special:Search\?query/) > -1) return `${randomInstance}${wiki}${urlpath}${url.search}`.replace(/Special:Search\?query/, "search?q").replace(/\/wiki/, "")
|
||||
else return `${randomInstance}${wiki}${urlpath}${url.search}`
|
||||
if (url.href.search(/Special:Search\?query/) > -1) {
|
||||
return `${randomInstance}${wiki}${urlpath}${url.search}`.replace(/Special:Search\?query/, "search?q").replace(/\/wiki/, "")
|
||||
}
|
||||
return `${randomInstance}${wiki}${urlpath}${url.search}`
|
||||
}
|
||||
case "rimgo": {
|
||||
if (url.href.search(/^https?:\/{2}(?:[im]\.)?stack\./) > -1) return `${randomInstance}/stack${url.pathname}${url.search}`
|
||||
else return `${randomInstance}${url.pathname}${url.search}`
|
||||
if (url.href.search(/^https?:\/{2}(?:[im]\.)?stack\./) > -1) {
|
||||
return `${randomInstance}/stack${url.pathname}${url.search}`
|
||||
}
|
||||
return `${randomInstance}${url.pathname}${url.search}`
|
||||
}
|
||||
case "libreddit": {
|
||||
const subdomain = url.hostname.match(/^(?:(?:external-)?preview|i)(?=\.redd\.it)/)
|
||||
|
@ -408,6 +419,7 @@ function redirect(url, type, initiator, forceRedirection) {
|
|||
case "i":
|
||||
return `${randomInstance}/img${url.pathname}`
|
||||
}
|
||||
return randomInstance
|
||||
}
|
||||
case "teddit": {
|
||||
if (/^(?:(?:external-)?preview|i)\.redd\.it/.test(url.hostname)) {
|
||||
|
@ -424,7 +436,9 @@ function redirect(url, type, initiator, forceRedirection) {
|
|||
return `${randomInstance}${p}`
|
||||
}
|
||||
case "dumb": {
|
||||
if (url.pathname.endsWith('-lyrics')) return `${randomInstance}${url.pathname}`
|
||||
if (url.pathname.endsWith('-lyrics')) {
|
||||
return `${randomInstance}${url.pathname}`
|
||||
}
|
||||
}
|
||||
case "ruralDictionary": {
|
||||
if (!url.pathname.includes('/define.php') && !url.pathname.includes('/random.php') && url.pathname != '/') return
|
||||
|
@ -632,11 +646,16 @@ function initDefaults() {
|
|||
function upgradeOptions() {
|
||||
return new Promise(async resolve => {
|
||||
const oldOptions = await utils.getOptions()
|
||||
const config = await utils.getConfig()
|
||||
|
||||
let options = {}
|
||||
options = [...oldOptions]
|
||||
options.fetchInstances = 'github'
|
||||
|
||||
for (service in config.services) {
|
||||
options[service].unsupportedUrls = 'bypass'
|
||||
}
|
||||
|
||||
browser.storage.local.clear(() => {
|
||||
browser.storage.local.set({ options }, () => {
|
||||
resolve()
|
||||
|
|
|
@ -96,7 +96,8 @@
|
|||
"options": {
|
||||
"enabled": false,
|
||||
"redirectType": "main_frame",
|
||||
"frontend": "invidious"
|
||||
"frontend": "invidious",
|
||||
"unsupportedUrls": "bypass"
|
||||
},
|
||||
"imageType": "png",
|
||||
"embeddable": true,
|
||||
|
@ -121,7 +122,8 @@
|
|||
"name": "YT Music",
|
||||
"options": {
|
||||
"enabled": false,
|
||||
"frontend": "beatbump"
|
||||
"frontend": "beatbump",
|
||||
"unsupportedUrls": "bypass"
|
||||
},
|
||||
"imageType": "png",
|
||||
"embeddable": false,
|
||||
|
@ -145,7 +147,8 @@
|
|||
"name": "Twitter",
|
||||
"options": {
|
||||
"enabled": false,
|
||||
"redirectType": "main_frame"
|
||||
"redirectType": "main_frame",
|
||||
"unsupportedUrls": "bypass"
|
||||
},
|
||||
"imageType": "png",
|
||||
"embeddable": true,
|
||||
|
@ -164,7 +167,8 @@
|
|||
],
|
||||
"name": "TikTok",
|
||||
"options": {
|
||||
"enabled": false
|
||||
"enabled": false,
|
||||
"unsupportedUrls": "bypass"
|
||||
},
|
||||
"imageType": "png",
|
||||
"embeddable": false,
|
||||
|
@ -190,7 +194,8 @@
|
|||
"name": "Reddit",
|
||||
"options": {
|
||||
"enabled": false,
|
||||
"frontend": "libreddit"
|
||||
"frontend": "libreddit",
|
||||
"unsupportedUrls": "bypass"
|
||||
},
|
||||
"imageType": "png",
|
||||
"embeddable": false,
|
||||
|
@ -210,7 +215,8 @@
|
|||
"name": "Imgur",
|
||||
"options": {
|
||||
"enabled": false,
|
||||
"redirectType": "main_frame"
|
||||
"redirectType": "main_frame",
|
||||
"unsupportedUrls": "bypass"
|
||||
},
|
||||
"imageType": "png",
|
||||
"embeddable": true,
|
||||
|
@ -253,7 +259,8 @@
|
|||
"name": "Medium",
|
||||
"options": {
|
||||
"frontend": "scribe",
|
||||
"enabled": false
|
||||
"enabled": false,
|
||||
"unsupportedUrls": "bypass"
|
||||
},
|
||||
"imageType": "svg",
|
||||
"embeddable": false,
|
||||
|
@ -272,7 +279,8 @@
|
|||
],
|
||||
"name": "Quora",
|
||||
"options": {
|
||||
"enabled": false
|
||||
"enabled": false,
|
||||
"unsupportedUrls": "bypass"
|
||||
},
|
||||
"imageType": "png",
|
||||
"embeddable": false,
|
||||
|
@ -291,7 +299,8 @@
|
|||
],
|
||||
"name": "IMDb",
|
||||
"options": {
|
||||
"enabled": false
|
||||
"enabled": false,
|
||||
"unsupportedUrls": "bypass"
|
||||
},
|
||||
"imageType": "svg",
|
||||
"embeddable": false,
|
||||
|
@ -310,7 +319,8 @@
|
|||
],
|
||||
"name": "Fandom",
|
||||
"options": {
|
||||
"enabled": false
|
||||
"enabled": false,
|
||||
"unsupportedUrls": "bypass"
|
||||
},
|
||||
"imageType": "svg",
|
||||
"embeddable": false,
|
||||
|
@ -339,7 +349,8 @@
|
|||
"options": {
|
||||
"enabled": false,
|
||||
"frontend": "librarian",
|
||||
"redirectType": "main_frame"
|
||||
"redirectType": "main_frame",
|
||||
"unsupportedUrls": "bypass"
|
||||
},
|
||||
"imageType": "png",
|
||||
"embeddable": true,
|
||||
|
@ -374,7 +385,8 @@
|
|||
"name": "Search",
|
||||
"options": {
|
||||
"enabled": false,
|
||||
"frontend": "searxng"
|
||||
"frontend": "searxng",
|
||||
"unsupportedUrls": "bypass"
|
||||
},
|
||||
"imageType": "svgMono",
|
||||
"embeddable": false,
|
||||
|
@ -405,7 +417,8 @@
|
|||
"name": "Translate",
|
||||
"options": {
|
||||
"enabled": false,
|
||||
"frontend": "simplyTranslate"
|
||||
"frontend": "simplyTranslate",
|
||||
"unsupportedUrls": "bypass"
|
||||
},
|
||||
"imageType": "svgMono",
|
||||
"embeddable": false,
|
||||
|
@ -431,7 +444,8 @@
|
|||
"name": "Maps",
|
||||
"options": {
|
||||
"enabled": false,
|
||||
"frontend": "osm"
|
||||
"frontend": "osm",
|
||||
"unsupportedUrls": "bypass"
|
||||
},
|
||||
"imageType": "svgMono",
|
||||
"embeddable": false,
|
||||
|
@ -452,7 +466,8 @@
|
|||
],
|
||||
"name": "Send Files",
|
||||
"options": {
|
||||
"enabled": false
|
||||
"enabled": false,
|
||||
"unsupportedUrls": "bypass"
|
||||
},
|
||||
"imageType": "svgMono",
|
||||
"embeddable": false,
|
||||
|
@ -471,7 +486,8 @@
|
|||
],
|
||||
"name": "Paste Text",
|
||||
"options": {
|
||||
"enabled": false
|
||||
"enabled": false,
|
||||
"unsupportedUrls": "bypass"
|
||||
},
|
||||
"imageType": "svgMono",
|
||||
"embeddable": false,
|
||||
|
@ -490,7 +506,8 @@
|
|||
],
|
||||
"name": "Reuters",
|
||||
"options": {
|
||||
"enabled": false
|
||||
"enabled": false,
|
||||
"unsupportedUrls": "bypass"
|
||||
},
|
||||
"imageType": "svg",
|
||||
"embeddable": false,
|
||||
|
@ -509,7 +526,8 @@
|
|||
],
|
||||
"name": "Genius",
|
||||
"options": {
|
||||
"enabled": false
|
||||
"enabled": false,
|
||||
"unsupportedUrls": "bypass"
|
||||
},
|
||||
"imageType": "svg",
|
||||
"embeddable": false,
|
||||
|
@ -528,7 +546,8 @@
|
|||
],
|
||||
"name": "Urban Dictionary",
|
||||
"options": {
|
||||
"enabled": false
|
||||
"enabled": false,
|
||||
"unsupportedUrls": "bypass"
|
||||
},
|
||||
"imageType": "svg",
|
||||
"embeddable": false,
|
||||
|
@ -547,7 +566,8 @@
|
|||
],
|
||||
"name": "Stack Overflow",
|
||||
"options": {
|
||||
"enabled": false
|
||||
"enabled": false,
|
||||
"unsupportedUrls": "bypass"
|
||||
},
|
||||
"imageType": "svgMono",
|
||||
"embeddable": false,
|
||||
|
@ -566,7 +586,8 @@
|
|||
],
|
||||
"name": "Goodreads",
|
||||
"options": {
|
||||
"enabled": false
|
||||
"enabled": false,
|
||||
"unsupportedUrls": "bypass"
|
||||
},
|
||||
"imageType": "svgMono",
|
||||
"embeddable": false,
|
||||
|
@ -585,7 +606,8 @@
|
|||
],
|
||||
"name": "Wikipedia",
|
||||
"options": {
|
||||
"enabled": false
|
||||
"enabled": false,
|
||||
"unsupportedUrls": "bypass"
|
||||
},
|
||||
"imageType": "svg",
|
||||
"embeddable": false,
|
||||
|
@ -604,7 +626,8 @@
|
|||
],
|
||||
"name": "Snopes",
|
||||
"options": {
|
||||
"enabled": false
|
||||
"enabled": false,
|
||||
"unsupportedUrls": "bypass"
|
||||
},
|
||||
"imageType": "svg",
|
||||
"embeddable": false,
|
||||
|
|
|
@ -34,6 +34,11 @@ each val, service in services
|
|||
option(value="sub_frame" data-localise="__MSG_onlyEmbedded__") Only Embedded
|
||||
option(value="main_frame" data-localise="__MSG_onlyNotEmbedded__") Only Not Embedded
|
||||
|
||||
div(class="some-block option-block")
|
||||
h4 Unsupported paths handling
|
||||
select(id=service+"-unsupportedUrls")
|
||||
option(value="bypass") bypass
|
||||
option(value="block") block
|
||||
hr
|
||||
|
||||
each val, frontend in services[service].frontends
|
||||
|
|
Loading…
Reference in New Issue