Added reverse for wikiless

このコミットが含まれているのは:
ManeraKai 2023-06-01 12:34:49 +03:00
コミット 57a664afe1
この署名に対応する既知のキーがデータベースに存在しません
GPGキーID: 5ABC31FFD562E337
1個のファイルの変更38行の追加41行の削除

ファイルの表示

@ -461,13 +461,13 @@ function redirect(url, type, initiator, forceRedirection) {
} }
case "wikiless": { case "wikiless": {
let hostSplit = url.host.split(".") let hostSplit = url.host.split(".")
// wikiless doesn't have mobile view support yet
if (hostSplit[0] != "wikipedia" && hostSplit[0] != "www") { if (hostSplit[0] != "wikipedia" && hostSplit[0] != "www") {
// wikiless doesn't have mobile view support yet
if (hostSplit[0] == "m") url.searchParams.append("mobileaction", "toggle_view_mobile") if (hostSplit[0] == "m") url.searchParams.append("mobileaction", "toggle_view_mobile")
else url.searchParams.append("lang", hostSplit[0]) else url.searchParams.append("lang", hostSplit[0])
if (hostSplit[1] == "m") url.searchParams.append("mobileaction", "toggle_view_mobile") if (hostSplit[1] == "m") url.searchParams.append("mobileaction", "toggle_view_mobile")
} }
return `${randomInstance}${url.pathname}${GETArguments.toString()}${url.hash}` return `${randomInstance}${url.pathname}${url.search}${url.hash}`
} }
case "proxiTok": { case "proxiTok": {
if (url.pathname.startsWith('/email')) return randomInstance if (url.pathname.startsWith('/email')) return randomInstance
@ -609,47 +609,44 @@ function switchInstance(url) {
}) })
} }
function reverse(url) { async function reverse(url) {
return new Promise(async resolve => { let options = await utils.getOptions()
let options = await utils.getOptions() let config = await utils.getConfig()
let config = await utils.getConfig() let protocolHost = utils.protocolHost(url)
for (const service in config.services) {
let protocolHost = utils.protocolHost(url) let frontend = options[service].frontend
for (const service in config.services) { if (options[frontend] == undefined) continue
let frontend = options[service].frontend if (!options[frontend].includes(protocolHost)) continue
if (options[frontend] == undefined) continue switch (service) {
if (!options[frontend].includes(protocolHost)) continue case "youtube":
case "imdb":
switch (service) { case "imgur":
case "youtube": case "tiktok":
case "imdb": case "twitter":
case "imgur": case "reddit":
case "tiktok": case "imdb":
case "twitter": case "snopes":
case "reddit": case "urbanDictionary":
case "imdb": case "quora":
case "snopes": case "medium":
case "urbanDictionary": return `${config.services[service].url}${url.pathname}${url.search}`
case "quora": case "fandom":
case "medium": let regex = url.pathname.match(/^\/([a-zA-Z0-9-]+)\/wiki\/(.*)/)
resolve(config.services[service].url + url.pathname + url.search) if (regex) return `https://${regex[1]}.fandom.com/wiki/${regex[2]}`
return return
case "fandom": case "wikipedia": {
let regex = url.pathname.match(/^\/([a-zA-Z0-9-]+)\/wiki\/(.*)/) const lang = url.searchParams.get("lang")
if (regex) { if (lang != null) {
resolve(`https://${regex[1]}.fandom.com/wiki/${regex[2]}`) url.searchParams.delete("lang")
return return `https://${lang}.wikipedia.org${url.pathname}${url.search}${url.hash}`
} }
resolve() return `https://wikipedia.org${url.pathname}${url.search}${url.hash}`
return
default:
resolve()
return
} }
default:
return
} }
resolve() }
return return
})
} }
const defaultInstances = { const defaultInstances = {