Added support for i.stack.imgur.com and rimgo embeds
Closes https://codeberg.org/LibRedirect/libredirect/issues/18
This commit is contained in:
parent
12b6f9cdbb
commit
beaaeb1d30
|
@ -61,6 +61,7 @@ function regexArray(service, url, config) {
|
|||
}
|
||||
|
||||
function redirect(url, type, initiator) {
|
||||
if (type != "main_frame" && type != "sub_frame") return
|
||||
let randomInstance
|
||||
let frontend
|
||||
for (const service in config.services) {
|
||||
|
@ -392,6 +393,9 @@ function redirect(url, type, initiator) {
|
|||
else wiki = "/" + wiki
|
||||
if (url.href.search(/Special:Search\?query/) > -1) return `${randomInstance}${wiki}${url.pathname}${url.search}`.replace(/Special:Search\?query/, "search?q").replace(/\/wiki/, "")
|
||||
else return `${randomInstance}${wiki}${url.pathname}${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}`
|
||||
default:
|
||||
return `${randomInstance}${url.pathname}${url.search}`
|
||||
}
|
||||
|
@ -440,8 +444,16 @@ function switchInstance(url) {
|
|||
for (const service in config.services) {
|
||||
if (!all(service, null, options, config, redirects).includes(protocolHost)) continue
|
||||
|
||||
let instancesList = [...options[options[service].frontend][options.network].enabled, ...options[options[service].frontend][options.network].custom]
|
||||
if (instancesList.length === 0 && options.networkFallback) instancesList = [...options[options[service].frontend].clearnet.enabled, ...options[options[service].frontend].clearnet.custom]
|
||||
let instancesList
|
||||
if (Object.keys(config.services[service].frontends).length == 1) {
|
||||
const frontend = Object.keys(config.services[service].frontends)[0]
|
||||
instancesList = [...options[frontend][options.network].enabled, ...options[frontend][options.network].custom]
|
||||
if (instancesList.length === 0 && options.networkFallback) instancesList = [...options[frontend].clearnet.enabled, ...options[frontend].clearnet.custom]
|
||||
} else {
|
||||
const frontend = options[service].frontend
|
||||
instancesList = [...options[frontend][options.network].enabled, ...options[frontend][options.network].custom]
|
||||
if (instancesList.length === 0 && options.networkFallback) instancesList = [...options[frontend].clearnet.enabled, ...options[frontend].clearnet.custom]
|
||||
}
|
||||
|
||||
let oldInstance
|
||||
const i = instancesList.indexOf(protocolHost)
|
||||
|
|
|
@ -254,14 +254,18 @@
|
|||
"frontends": {
|
||||
"rimgo": {
|
||||
"name": "rimgo",
|
||||
"embeddable": true,
|
||||
"instanceList": true
|
||||
}
|
||||
},
|
||||
"targets": ["^https?:\\/{2}([im]\\.)?imgur\\.(com|io)(\\/|$)"],
|
||||
"targets": ["^https?:\\/{2}([im]\\.)?(stack\\.)?imgur\\.(com|io)(\\/|$)"],
|
||||
"name": "Imgur",
|
||||
"options": { "enabled": true },
|
||||
"options": {
|
||||
"enabled": true,
|
||||
"redirectType": "both"
|
||||
},
|
||||
"imageType": "png",
|
||||
"embeddable": false,
|
||||
"embeddable": true,
|
||||
"url": "https://imgur.com"
|
||||
},
|
||||
"wikipedia": {
|
||||
|
|
|
@ -1574,7 +1574,15 @@
|
|||
<h4 data-localise="__MSG_enable__">Enable</h4>
|
||||
<input id="imgur-enabled" type="checkbox">
|
||||
</div>
|
||||
<hr>
|
||||
<div class="some-block option-block">
|
||||
<h4 data-localise="__MSG_redirectType__">Redirect Type</h4>
|
||||
<select id="imgur-redirectType">
|
||||
<option value="both" data-localise="__MSG_both__">both</option>
|
||||
<option value="sub_frame" data-localise="__MSG_onlyEmbedded__">Only Embedded</option>
|
||||
<option value="main_frame" data-localise="__MSG_onlyNotEmbedded__">Only Not Embedded</option>
|
||||
</select>
|
||||
</div>
|
||||
<hr>
|
||||
<div id="rimgo">
|
||||
<div class="clearnet">
|
||||
<div class="some-block option-block">
|
||||
|
|
Loading…
Reference in New Issue