Re-added EmbedFrontend https://github.com/libredirect/browser_extension/issues/624
This commit is contained in:
parent
a44ba0effe
commit
39a19e56cc
|
@ -56,22 +56,31 @@ function redirect(url, type, initiator, forceRedirection) {
|
||||||
for (const service in config.services) {
|
for (const service in config.services) {
|
||||||
if (!forceRedirection && !options[service].enabled) continue
|
if (!forceRedirection && !options[service].enabled) continue
|
||||||
|
|
||||||
frontend = options[service].frontend
|
frontend = options[service]
|
||||||
|
|
||||||
if (!regexArray(service, url, config, frontend)) {
|
|
||||||
frontend = null
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
if (
|
if (
|
||||||
(config.services[service].embeddable && type != options[service].redirectType && options[service].redirectType != "both")
|
config.services[service].embeddable &&
|
||||||
||
|
type != options[service].redirectType &&
|
||||||
(!config.services[service].embeddable && type != "main_frame")
|
options[service].redirectType != "both"
|
||||||
) {
|
) {
|
||||||
if (options[service].unsupportedUrls == 'block') return 'CANCEL'
|
if (options[service].unsupportedUrls == 'block') return 'CANCEL'
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
config.services[service].embeddable
|
||||||
|
&&
|
||||||
|
type != "main_frame"
|
||||||
|
&&
|
||||||
|
options[service].redirectType != "main_frame"
|
||||||
|
&&
|
||||||
|
options[service].embedFrontend != "disabled"
|
||||||
|
) frontend = options[service].embedFrontend
|
||||||
|
|
||||||
|
if (!regexArray(service, url, config, frontend)) {
|
||||||
|
frontend = null
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
let instanceList = options[frontend]
|
let instanceList = options[frontend]
|
||||||
if (instanceList === undefined) break
|
if (instanceList === undefined) break
|
||||||
if (instanceList.length === 0) return null
|
if (instanceList.length === 0) return null
|
||||||
|
|
|
@ -69,6 +69,7 @@
|
||||||
],
|
],
|
||||||
"name": "FreeTube",
|
"name": "FreeTube",
|
||||||
"embeddable": false,
|
"embeddable": false,
|
||||||
|
"desktopApp": true,
|
||||||
"instanceList": false,
|
"instanceList": false,
|
||||||
"url": "https://github.com/FreeTubeApp/FreeTube"
|
"url": "https://github.com/FreeTubeApp/FreeTube"
|
||||||
},
|
},
|
||||||
|
@ -79,6 +80,7 @@
|
||||||
],
|
],
|
||||||
"name": "Yattee",
|
"name": "Yattee",
|
||||||
"embeddable": false,
|
"embeddable": false,
|
||||||
|
"desktopApp": true,
|
||||||
"instanceList": false,
|
"instanceList": false,
|
||||||
"url": "https://github.com/yattee/yattee"
|
"url": "https://github.com/yattee/yattee"
|
||||||
}
|
}
|
||||||
|
@ -97,6 +99,7 @@
|
||||||
"enabled": false,
|
"enabled": false,
|
||||||
"redirectType": "main_frame",
|
"redirectType": "main_frame",
|
||||||
"frontend": "invidious",
|
"frontend": "invidious",
|
||||||
|
"embedFrontend": "disabled",
|
||||||
"unsupportedUrls": "bypass"
|
"unsupportedUrls": "bypass"
|
||||||
},
|
},
|
||||||
"imageType": "png",
|
"imageType": "png",
|
||||||
|
@ -126,7 +129,6 @@
|
||||||
"unsupportedUrls": "bypass"
|
"unsupportedUrls": "bypass"
|
||||||
},
|
},
|
||||||
"imageType": "png",
|
"imageType": "png",
|
||||||
"embeddable": false,
|
|
||||||
"url": "https://music.youtube.com"
|
"url": "https://music.youtube.com"
|
||||||
},
|
},
|
||||||
"twitter": {
|
"twitter": {
|
||||||
|
@ -177,7 +179,6 @@
|
||||||
"instance": "public"
|
"instance": "public"
|
||||||
},
|
},
|
||||||
"imageType": "png",
|
"imageType": "png",
|
||||||
"embeddable": false,
|
|
||||||
"url": "https://tiktok.com"
|
"url": "https://tiktok.com"
|
||||||
},
|
},
|
||||||
"reddit": {
|
"reddit": {
|
||||||
|
@ -207,7 +208,6 @@
|
||||||
"instance": "public"
|
"instance": "public"
|
||||||
},
|
},
|
||||||
"imageType": "png",
|
"imageType": "png",
|
||||||
"embeddable": false,
|
|
||||||
"url": "https://reddit.com"
|
"url": "https://reddit.com"
|
||||||
},
|
},
|
||||||
"imgur": {
|
"imgur": {
|
||||||
|
@ -253,7 +253,6 @@
|
||||||
"frontend": "pixivFe"
|
"frontend": "pixivFe"
|
||||||
},
|
},
|
||||||
"imageType": "svg",
|
"imageType": "svg",
|
||||||
"embeddable": false,
|
|
||||||
"url": "https://www.pixiv.net"
|
"url": "https://www.pixiv.net"
|
||||||
},
|
},
|
||||||
"medium": {
|
"medium": {
|
||||||
|
@ -297,7 +296,6 @@
|
||||||
"unsupportedUrls": "bypass"
|
"unsupportedUrls": "bypass"
|
||||||
},
|
},
|
||||||
"imageType": "svg",
|
"imageType": "svg",
|
||||||
"embeddable": false,
|
|
||||||
"url": "https://medium.com"
|
"url": "https://medium.com"
|
||||||
},
|
},
|
||||||
"quora": {
|
"quora": {
|
||||||
|
@ -320,7 +318,6 @@
|
||||||
"instance": "public"
|
"instance": "public"
|
||||||
},
|
},
|
||||||
"imageType": "png",
|
"imageType": "png",
|
||||||
"embeddable": false,
|
|
||||||
"url": "https://quora.com"
|
"url": "https://quora.com"
|
||||||
},
|
},
|
||||||
"imdb": {
|
"imdb": {
|
||||||
|
@ -343,7 +340,6 @@
|
||||||
"instance": "public"
|
"instance": "public"
|
||||||
},
|
},
|
||||||
"imageType": "svg",
|
"imageType": "svg",
|
||||||
"embeddable": false,
|
|
||||||
"url": "https://imdb.com"
|
"url": "https://imdb.com"
|
||||||
},
|
},
|
||||||
"fandom": {
|
"fandom": {
|
||||||
|
@ -365,7 +361,6 @@
|
||||||
"frontend": "breezeWiki"
|
"frontend": "breezeWiki"
|
||||||
},
|
},
|
||||||
"imageType": "svg",
|
"imageType": "svg",
|
||||||
"embeddable": false,
|
|
||||||
"url": "https://fandom.com"
|
"url": "https://fandom.com"
|
||||||
},
|
},
|
||||||
"pinterest": {
|
"pinterest": {
|
||||||
|
@ -427,7 +422,6 @@
|
||||||
"instance": "public"
|
"instance": "public"
|
||||||
},
|
},
|
||||||
"imageType": "svgMono",
|
"imageType": "svgMono",
|
||||||
"embeddable": false,
|
|
||||||
"url": "https://search.libredirect.invalid"
|
"url": "https://search.libredirect.invalid"
|
||||||
},
|
},
|
||||||
"translate": {
|
"translate": {
|
||||||
|
@ -462,7 +456,6 @@
|
||||||
"instance": "public"
|
"instance": "public"
|
||||||
},
|
},
|
||||||
"imageType": "svgMono",
|
"imageType": "svgMono",
|
||||||
"embeddable": false,
|
|
||||||
"url": "https://translate.libredirect.invalid"
|
"url": "https://translate.libredirect.invalid"
|
||||||
},
|
},
|
||||||
"maps": {
|
"maps": {
|
||||||
|
@ -489,7 +482,6 @@
|
||||||
"unsupportedUrls": "bypass"
|
"unsupportedUrls": "bypass"
|
||||||
},
|
},
|
||||||
"imageType": "svgMono",
|
"imageType": "svgMono",
|
||||||
"embeddable": false,
|
|
||||||
"url": "https://maps.libredirect.invalid"
|
"url": "https://maps.libredirect.invalid"
|
||||||
},
|
},
|
||||||
"sendFiles": {
|
"sendFiles": {
|
||||||
|
@ -512,7 +504,6 @@
|
||||||
"frontend": "send"
|
"frontend": "send"
|
||||||
},
|
},
|
||||||
"imageType": "svgMono",
|
"imageType": "svgMono",
|
||||||
"embeddable": false,
|
|
||||||
"url": "https://send.libredirect.invalid"
|
"url": "https://send.libredirect.invalid"
|
||||||
},
|
},
|
||||||
"textStorage": {
|
"textStorage": {
|
||||||
|
@ -533,7 +524,6 @@
|
||||||
"frontend": "privateBin"
|
"frontend": "privateBin"
|
||||||
},
|
},
|
||||||
"imageType": "svgMono",
|
"imageType": "svgMono",
|
||||||
"embeddable": false,
|
|
||||||
"url": "https://paste.libredirect.invalid"
|
"url": "https://paste.libredirect.invalid"
|
||||||
},
|
},
|
||||||
"reuters": {
|
"reuters": {
|
||||||
|
@ -554,7 +544,6 @@
|
||||||
"frontend": "neuters"
|
"frontend": "neuters"
|
||||||
},
|
},
|
||||||
"imageType": "svg",
|
"imageType": "svg",
|
||||||
"embeddable": false,
|
|
||||||
"url": "https://reuters.com"
|
"url": "https://reuters.com"
|
||||||
},
|
},
|
||||||
"genius": {
|
"genius": {
|
||||||
|
@ -583,7 +572,6 @@
|
||||||
"instance": "public"
|
"instance": "public"
|
||||||
},
|
},
|
||||||
"imageType": "svg",
|
"imageType": "svg",
|
||||||
"embeddable": false,
|
|
||||||
"url": "https://genius.com"
|
"url": "https://genius.com"
|
||||||
},
|
},
|
||||||
"urbanDictionary": {
|
"urbanDictionary": {
|
||||||
|
@ -604,7 +592,6 @@
|
||||||
"frontend": "ruralDictionary"
|
"frontend": "ruralDictionary"
|
||||||
},
|
},
|
||||||
"imageType": "svg",
|
"imageType": "svg",
|
||||||
"embeddable": false,
|
|
||||||
"url": "https://urbandictionary.com"
|
"url": "https://urbandictionary.com"
|
||||||
},
|
},
|
||||||
"stackOverflow": {
|
"stackOverflow": {
|
||||||
|
@ -628,7 +615,6 @@
|
||||||
"instance": "public"
|
"instance": "public"
|
||||||
},
|
},
|
||||||
"imageType": "svgMono",
|
"imageType": "svgMono",
|
||||||
"embeddable": false,
|
|
||||||
"url": "https://stackoverflow.com/"
|
"url": "https://stackoverflow.com/"
|
||||||
},
|
},
|
||||||
"goodreads": {
|
"goodreads": {
|
||||||
|
@ -651,7 +637,6 @@
|
||||||
"instance": "public"
|
"instance": "public"
|
||||||
},
|
},
|
||||||
"imageType": "svgMono",
|
"imageType": "svgMono",
|
||||||
"embeddable": false,
|
|
||||||
"url": "https://goodreads.com/"
|
"url": "https://goodreads.com/"
|
||||||
},
|
},
|
||||||
"wikipedia": {
|
"wikipedia": {
|
||||||
|
@ -672,7 +657,6 @@
|
||||||
"frontend": "wikiless"
|
"frontend": "wikiless"
|
||||||
},
|
},
|
||||||
"imageType": "svg",
|
"imageType": "svg",
|
||||||
"embeddable": false,
|
|
||||||
"url": "https://wikipedia.org"
|
"url": "https://wikipedia.org"
|
||||||
},
|
},
|
||||||
"snopes": {
|
"snopes": {
|
||||||
|
@ -693,7 +677,6 @@
|
||||||
"frontend": "suds"
|
"frontend": "suds"
|
||||||
},
|
},
|
||||||
"imageType": "svg",
|
"imageType": "svg",
|
||||||
"embeddable": false,
|
|
||||||
"url": "https://www.snopes.com"
|
"url": "https://www.snopes.com"
|
||||||
},
|
},
|
||||||
"waybackMachine": {
|
"waybackMachine": {
|
||||||
|
@ -714,7 +697,6 @@
|
||||||
"frontend": "waybackClassic"
|
"frontend": "waybackClassic"
|
||||||
},
|
},
|
||||||
"imageType": "svgMono",
|
"imageType": "svgMono",
|
||||||
"embeddable": false,
|
|
||||||
"url": "https://web.archive.org"
|
"url": "https://web.archive.org"
|
||||||
},
|
},
|
||||||
"github": {
|
"github": {
|
||||||
|
@ -735,7 +717,6 @@
|
||||||
"frontend": "gothub"
|
"frontend": "gothub"
|
||||||
},
|
},
|
||||||
"imageType": "svgMono",
|
"imageType": "svgMono",
|
||||||
"embeddable": false,
|
|
||||||
"url": "https://github.com"
|
"url": "https://github.com"
|
||||||
},
|
},
|
||||||
"bilibili": {
|
"bilibili": {
|
||||||
|
@ -757,7 +738,6 @@
|
||||||
"frontend": "mikuInvidious"
|
"frontend": "mikuInvidious"
|
||||||
},
|
},
|
||||||
"imageType": "svgMono",
|
"imageType": "svgMono",
|
||||||
"embeddable": false,
|
|
||||||
"url": "https://bilibili.com/"
|
"url": "https://bilibili.com/"
|
||||||
},
|
},
|
||||||
"bandcamp": {
|
"bandcamp": {
|
||||||
|
@ -779,7 +759,6 @@
|
||||||
"frontend": "tent"
|
"frontend": "tent"
|
||||||
},
|
},
|
||||||
"imageType": "svg",
|
"imageType": "svg",
|
||||||
"embeddable": false,
|
|
||||||
"url": "https://bandcamp.com"
|
"url": "https://bandcamp.com"
|
||||||
},
|
},
|
||||||
"gitlab": {
|
"gitlab": {
|
||||||
|
@ -802,7 +781,6 @@
|
||||||
"frontend": "laboratory"
|
"frontend": "laboratory"
|
||||||
},
|
},
|
||||||
"imageType": "svg",
|
"imageType": "svg",
|
||||||
"embeddable": false,
|
|
||||||
"url": "https://gitlab.com/"
|
"url": "https://gitlab.com/"
|
||||||
},
|
},
|
||||||
"wolframAlpha": {
|
"wolframAlpha": {
|
||||||
|
@ -823,7 +801,6 @@
|
||||||
"frontend": "wolfreeAlpha"
|
"frontend": "wolfreeAlpha"
|
||||||
},
|
},
|
||||||
"imageType": "svg",
|
"imageType": "svg",
|
||||||
"embeddable": false,
|
|
||||||
"url": "https://www.wolframalpha.com"
|
"url": "https://www.wolframalpha.com"
|
||||||
},
|
},
|
||||||
"speedTest": {
|
"speedTest": {
|
||||||
|
@ -846,7 +823,6 @@
|
||||||
"frontend": "libreSpeed"
|
"frontend": "libreSpeed"
|
||||||
},
|
},
|
||||||
"imageType": "svgMono",
|
"imageType": "svgMono",
|
||||||
"embeddable": false,
|
|
||||||
"url": "https://speedtest.libredirect.invalid"
|
"url": "https://speedtest.libredirect.invalid"
|
||||||
},
|
},
|
||||||
"meet": {
|
"meet": {
|
||||||
|
@ -867,7 +843,6 @@
|
||||||
"frontend": "jitsi"
|
"frontend": "jitsi"
|
||||||
},
|
},
|
||||||
"imageType": "svgMono",
|
"imageType": "svgMono",
|
||||||
"embeddable": false,
|
|
||||||
"url": "https://meet.libredirect.invalid"
|
"url": "https://meet.libredirect.invalid"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,7 +33,11 @@ async function changeFrontendsSettings(service) {
|
||||||
if (config.services[service].frontends[frontend].instanceList) {
|
if (config.services[service].frontends[frontend].instanceList) {
|
||||||
const frontendDiv = document.getElementById(frontend)
|
const frontendDiv = document.getElementById(frontend)
|
||||||
if (typeof divs[service].frontend !== "undefined") {
|
if (typeof divs[service].frontend !== "undefined") {
|
||||||
if (frontend == divs[service].frontend.value) {
|
if (
|
||||||
|
frontend == divs[service].frontend.value
|
||||||
|
||
|
||||||
|
(!config.services[service].frontends[divs[service].frontend.value].embeddable && divs[service].embedFrontend && frontend == divs[service].embedFrontend.value)
|
||||||
|
) {
|
||||||
frontendDiv.style.display = ""
|
frontendDiv.style.display = ""
|
||||||
if (config.services[service].frontends[frontend].localhost === true) {
|
if (config.services[service].frontends[frontend].localhost === true) {
|
||||||
document.getElementById(`${service}-instance-div`).style.display = ""
|
document.getElementById(`${service}-instance-div`).style.display = ""
|
||||||
|
@ -52,19 +56,24 @@ async function changeFrontendsSettings(service) {
|
||||||
}
|
}
|
||||||
if (document.getElementById(`${service}-redirectType`)) {
|
if (document.getElementById(`${service}-redirectType`)) {
|
||||||
const frontend = options[service].frontend
|
const frontend = options[service].frontend
|
||||||
if (config.services[service].frontends[frontend].embeddable) {
|
if (config.services[service].frontends[frontend].embeddable || config.services[service].frontends[frontend].desktopApp) {
|
||||||
document.getElementById(`${service}-redirectType`).innerHTML = `
|
document.getElementById(`${service}-redirectType`).innerHTML = `
|
||||||
<option value="both" data-localise="__MSG_both__">both</options>
|
<option value="both" data-localise="__MSG_both__">both</options>
|
||||||
<option value="sub_frame" data-localise="__MSG_onlyEmbedded__">Only Embedded</option>
|
<option value="sub_frame" data-localise="__MSG_onlyEmbedded__">Only Embedded</option>
|
||||||
<option value="main_frame" data-localise="__MSG_onlyNotEmbedded__">Only Not Embedded</option>
|
<option value="main_frame" data-localise="__MSG_onlyNotEmbedded__">Only Not Embedded</option>
|
||||||
`
|
`
|
||||||
document.getElementById(`${service}-redirectType`).value = options[frontend].redirectType = options[service].redirectType
|
document.getElementById(`${service}-redirectType`).value = options[service].redirectType
|
||||||
} else {
|
} else {
|
||||||
document.getElementById(`${service}-redirectType`).innerHTML =
|
document.getElementById(`${service}-redirectType`).innerHTML =
|
||||||
'<option value="main_frame" data-localise="__MSG_onlyNotEmbedded__">Only Not Embedded</option>'
|
'<option value="main_frame" data-localise="__MSG_onlyNotEmbedded__">Only Not Embedded</option>'
|
||||||
options[service].redirectType = "main_frame"
|
options[service].redirectType = "main_frame"
|
||||||
browser.storage.local.set({ options })
|
browser.storage.local.set({ options })
|
||||||
}
|
}
|
||||||
|
if (config.services[service].frontends[frontend].desktopApp) {
|
||||||
|
document.getElementById(`${service}-embedFrontend-div`).style.display = ''
|
||||||
|
} else {
|
||||||
|
document.getElementById(`${service}-embedFrontend-div`).style.display = 'none'
|
||||||
|
}
|
||||||
}
|
}
|
||||||
const frontend_name_element = document.getElementById(`${service}_page`).getElementsByClassName("frontend_name")[0]
|
const frontend_name_element = document.getElementById(`${service}_page`).getElementsByClassName("frontend_name")[0]
|
||||||
frontend_name_element.href = config.services[service].frontends[divs[service].frontend.value].url
|
frontend_name_element.href = config.services[service].frontends[divs[service].frontend.value].url
|
||||||
|
|
|
@ -29,10 +29,19 @@ each val, service in services
|
||||||
option(value="localhost") localhost
|
option(value="localhost") localhost
|
||||||
option(value="public") public instances
|
option(value="public") public instances
|
||||||
|
|
||||||
if services[service].embeddable
|
div(class="some-block option-block")
|
||||||
div(class="some-block option-block")
|
h4(data-localise="__MSG_redirectType__") Redirect Type
|
||||||
h4(data-localise="__MSG_redirectType__") Redirect Type
|
select(id=service+"-redirectType")
|
||||||
select(id=service+"-redirectType")
|
|
||||||
|
|
||||||
|
div(id=service+"-embedFrontend-div" class="some-block option-block")
|
||||||
|
h4(data-localise="__MSG_embedFrontend__") Embed Frontend
|
||||||
|
select(id=service+"-embedFrontend")
|
||||||
|
option(value="disabled") Disabled
|
||||||
|
each val, frontend in services[service].frontends
|
||||||
|
if services[service].frontends[frontend].embeddable && services[service].frontends[frontend].instanceList
|
||||||
|
option(value=frontend)=services[service].frontends[frontend].name
|
||||||
|
|
||||||
|
|
||||||
div(class="some-block option-block")
|
div(class="some-block option-block")
|
||||||
h4 Unsupported iframes handling
|
h4 Unsupported iframes handling
|
||||||
|
|
Loading…
Reference in New Issue