Finished options upgrading
This commit is contained in:
parent
6c8c304a0d
commit
c1af086c27
|
@ -1,12 +1,4 @@
|
||||||
import requests
|
|
||||||
import json
|
import json
|
||||||
from urllib.parse import urlparse
|
|
||||||
from bs4 import BeautifulSoup
|
|
||||||
import re
|
|
||||||
from colorama import Fore, Back, Style
|
|
||||||
from urllib.parse import urlparse
|
|
||||||
import socket
|
|
||||||
import subprocess
|
|
||||||
|
|
||||||
|
|
||||||
ar_json = {}
|
ar_json = {}
|
||||||
|
|
Before Width: | Height: | Size: 316 B After Width: | Height: | Size: 316 B |
|
@ -406,123 +406,115 @@ function computeService(url, returnFrontend) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// if (returnFrontend) return [null, null]
|
resolve()
|
||||||
// else return null
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
async function switchInstance(url) {
|
function switchInstance(url) {
|
||||||
fetch("/config/config.json")
|
return new Promise(async resolve => {
|
||||||
.then(response => response.text())
|
await init()
|
||||||
.then(configData => {
|
const protocolHost = utils.protocolHost(url)
|
||||||
const config = JSON.parse(configData)
|
for (const service in config.services) {
|
||||||
browser.storage.local.get(["redirects", "options"], r => {
|
if (!all(service, null, options, config, redirects).includes(protocolHost)) continue
|
||||||
const redirects = r.redirects
|
|
||||||
const options = r.options
|
|
||||||
const protocolHost = utils.protocolHost(url)
|
|
||||||
for (const service in config.services) {
|
|
||||||
if (!options[service].enabled) continue
|
|
||||||
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]
|
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]
|
if (instancesList.length === 0 && options.networkFallback) instancesList = [...options[options[service].frontend].clearnet.enabled, ...options[options[service].frontend].clearnet.custom]
|
||||||
|
|
||||||
let oldInstance
|
let oldInstance
|
||||||
const i = instancesList.indexOf(protocolHost)
|
const i = instancesList.indexOf(protocolHost)
|
||||||
if (i > -1) {
|
if (i > -1) {
|
||||||
oldInstance = instancesList[i]
|
oldInstance = instancesList[i]
|
||||||
instancesList.splice(i, 1)
|
instancesList.splice(i, 1)
|
||||||
}
|
}
|
||||||
if (instancesList.length === 0) return
|
if (instancesList.length === 0) {
|
||||||
const randomInstance = utils.getRandomInstance(instancesList)
|
resolve()
|
||||||
const oldUrl = `${oldInstance}${url.pathname}${url.search}`
|
return
|
||||||
// This is to make instance switching work when the instance depends on the pathname, eg https://darmarit.org/searx
|
}
|
||||||
// Doesn't work because of .includes array method, not a top priotiry atm
|
const randomInstance = utils.getRandomInstance(instancesList)
|
||||||
return oldUrl.replace(oldInstance, randomInstance)
|
const oldUrl = `${oldInstance}${url.pathname}${url.search}`
|
||||||
}
|
// This is to make instance switching work when the instance depends on the pathname, eg https://darmarit.org/searx
|
||||||
})
|
// Doesn't work because of .includes array method, not a top priotiry atm
|
||||||
})
|
resolve(oldUrl.replace(oldInstance, randomInstance))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
resolve()
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
async function reverse(url) {
|
function reverse(url) {
|
||||||
fetch("/config/config.json")
|
return new Promise(async resolve => {
|
||||||
.then(response => response.text())
|
await init()
|
||||||
.then(configData => {
|
let protocolHost = utils.protocolHost(url)
|
||||||
const config = JSON.parse(configData)
|
for (const service in config.services) {
|
||||||
browser.storage.local.get(["redirects", "options"], r => {
|
if (!all(service, null, options, config, redirects).includes(protocolHost)) continue
|
||||||
const redirects = r.redirects
|
|
||||||
const options = r.options
|
|
||||||
let protocolHost = utils.protocolHost(url)
|
|
||||||
for (const service in config.services) {
|
|
||||||
if (!all(service, null, options, config, redirects).includes(protocolHost)) continue
|
|
||||||
|
|
||||||
switch (service) {
|
switch (service) {
|
||||||
case "instagram":
|
case "instagram":
|
||||||
if (url.pathname.startsWith("/p")) return `https://instagram.com${url.pathname.replace("/p", "")}${url.search}`
|
if (url.pathname.startsWith("/p")) resolve(`https://instagram.com${url.pathname.replace("/p", "")}${url.search}`)
|
||||||
if (url.pathname.startsWith("/u")) return `https://instagram.com${url.pathname.replace("/u", "")}${url.search}`
|
if (url.pathname.startsWith("/u")) resolve(`https://instagram.com${url.pathname.replace("/u", "")}${url.search}`)
|
||||||
return config.services[service].url + url.pathname + url.search
|
resolve(config.services[service].url + url.pathname + url.search)
|
||||||
case "youtube":
|
return
|
||||||
case "imdb":
|
case "youtube":
|
||||||
case "imgur":
|
case "imdb":
|
||||||
case "tiktok":
|
case "imgur":
|
||||||
case "twitter":
|
case "tiktok":
|
||||||
case "reddit":
|
case "twitter":
|
||||||
return config.services[service].url + url.pathname + url.search
|
case "reddit":
|
||||||
default:
|
resolve(config.services[service].url + url.pathname + url.search)
|
||||||
return
|
return
|
||||||
}
|
default:
|
||||||
}
|
resolve()
|
||||||
})
|
return
|
||||||
})
|
}
|
||||||
|
}
|
||||||
|
resolve()
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
async function unifyPreferences(url, tabId) {
|
function unifyPreferences(url, tabId) {
|
||||||
fetch("/config/config.json")
|
return new Promise(async resolve => {
|
||||||
.then(response => response.text())
|
await init()
|
||||||
.then(configData => {
|
const protocolHost = utils.protocolHost(url)
|
||||||
const config = JSON.parse(configData)
|
for (const service in config.services) {
|
||||||
browser.storage.local.get(["options", "reidrects"], r => {
|
for (const frontend in config.services[service].frontends) {
|
||||||
const redirects = r.redirects
|
if (all(service, frontend, options, config, redirects).includes(protocolHost)) {
|
||||||
const options = r.options
|
let instancesList = [...options[frontend][options.network].enabled, ...options[frontend][options.network].custom]
|
||||||
const protocolHost = utils.protocolHost(url)
|
if (options.networkFallback && options.network != "clearnet") instancesList.push(...options[frontend].clearnet.enabled, ...options[frontend].clearnet.custom)
|
||||||
for (const service in config.services) {
|
|
||||||
for (const frontend in config.services[service].frontends) {
|
|
||||||
if (all(service, frontend, options, config, redirects).includes(protocolHost)) {
|
|
||||||
let instancesList = [...options[frontend][options.network].enabled, ...options[frontend][options.network].custom]
|
|
||||||
if (options.networkFallback && options.network != "clearnet") instancesList.push(...options[frontend].clearnet.enabled, ...options[frontend].clearnet.custom)
|
|
||||||
|
|
||||||
const frontend = config.services[service].frontends[frontend]
|
const frontendObject = config.services[service].frontends[frontend]
|
||||||
if ("cookies" in frontend.preferences) {
|
if ("cookies" in frontendObject.preferences) {
|
||||||
for (const cookie of frontend.preferences.cookies) {
|
for (const cookie of frontendObject.preferences.cookies) {
|
||||||
utils.copyCookie(frontend, url, instancesList, cookie)
|
utils.copyCookie(frontendObject, url, instancesList, cookie)
|
||||||
}
|
|
||||||
}
|
|
||||||
if ("localstorage" in frontend.preferences) {
|
|
||||||
browser.storage.local.set({ tmp: [frontend, frontend.preferences.localstorage] })
|
|
||||||
browser.tabs.executeScript(tabId, {
|
|
||||||
file: "/assets/javascripts/get-localstorage.js",
|
|
||||||
runAt: "document_start",
|
|
||||||
})
|
|
||||||
for (const instance of instancesList)
|
|
||||||
browser.tabs.create({ url: instance }, tab =>
|
|
||||||
browser.tabs.executeScript(tab.id, {
|
|
||||||
file: "/assets/javascripts/set-localstorage.js",
|
|
||||||
runAt: "document_start",
|
|
||||||
})
|
|
||||||
)
|
|
||||||
}
|
|
||||||
if ("indexeddb" in frontend.preferences) {
|
|
||||||
}
|
|
||||||
if ("token" in frontend.preferences) {
|
|
||||||
}
|
|
||||||
return true
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if ("localstorage" in frontendObject.preferences) {
|
||||||
|
browser.storage.local.set({ tmp: [frontend, frontendObject.preferences.localstorage] })
|
||||||
|
browser.tabs.executeScript(tabId, {
|
||||||
|
file: "/assets/javascripts/get-localstorage.js",
|
||||||
|
runAt: "document_start",
|
||||||
|
})
|
||||||
|
for (const instance of instancesList)
|
||||||
|
browser.tabs.create({ url: instance }, tab =>
|
||||||
|
browser.tabs.executeScript(tab.id, {
|
||||||
|
file: "/assets/javascripts/set-localstorage.js",
|
||||||
|
runAt: "document_start",
|
||||||
|
})
|
||||||
|
)
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
if ("indexeddb" in frontendObject.preferences) {
|
||||||
|
}
|
||||||
|
if ("token" in frontendObject.preferences) {
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
resolve(true)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
})
|
}
|
||||||
})
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
async function setRedirects(redirects) {
|
async function setRedirects(redirects) {
|
||||||
|
@ -612,46 +604,67 @@ function upgradeOptions() {
|
||||||
fetch("/config/config.json")
|
fetch("/config/config.json")
|
||||||
.then(response => response.text())
|
.then(response => response.text())
|
||||||
.then(configData => {
|
.then(configData => {
|
||||||
browser.storage.local.get(["options", "exceptions", "theme", "popupFrontends", "autoRedirect", "firstPartyIsolate"], r => {
|
browser.storage.local.get(null, r => {
|
||||||
let options = r.options
|
let options = r.options
|
||||||
let latency = {}
|
let latency = {}
|
||||||
const config = JSON.parse(configData)
|
const config = JSON.parse(configData)
|
||||||
options.exceptions = r.exceptions
|
options.exceptions = r.exceptions
|
||||||
if (r.theme != "DEFAULT") options.theme = r.theme
|
if (r.theme != "DEFAULT") options.theme = r.theme
|
||||||
options.popupServices = r.popupFrontends
|
options.popupServices = r.popupFrontends
|
||||||
|
let tmp = options.popupServices.indexOf("tikTok")
|
||||||
|
if (tmp > -1) {
|
||||||
|
options.popupServices.splice(tmp, 1)
|
||||||
|
options.popupServices.push("tiktok")
|
||||||
|
}
|
||||||
|
tmp = options.popupServices.indexOf("sendTarget")
|
||||||
|
if (tmp > -1) {
|
||||||
|
options.popupServices.splice(tmp, 1)
|
||||||
|
options.popupServices.push("sendFiles")
|
||||||
|
}
|
||||||
options.firstPartyIsolate = r.firstPartyIsolate
|
options.firstPartyIsolate = r.firstPartyIsolate
|
||||||
options.autoRedirect = r.autoRedirect
|
options.autoRedirect = r.autoRedirect
|
||||||
|
switch (r.onlyEmbeddedVideo) {
|
||||||
|
case "onlyNotEmbedded":
|
||||||
|
options.youtube.redirectType = "main_frame"
|
||||||
|
case "onlyEmbedded":
|
||||||
|
options.youtube.redirectType = "sub_frame"
|
||||||
|
case "both":
|
||||||
|
options.youtube.redirectType = "both"
|
||||||
|
}
|
||||||
for (const service in config.services) {
|
for (const service in config.services) {
|
||||||
browser.storage.local.get([`disable${utils.camelCase(service)}`, `${service}RedirectType`, `${service}Frontend`, `${service}Latency`, `${service}EmbedFrontend`], r => {
|
let oldService
|
||||||
if (r) {
|
switch (service) {
|
||||||
options[service].enabled = !r["disable" + utils.camelCase(service)]
|
case "tiktok":
|
||||||
if (r[service + "Frontend"]) {
|
oldService = "tikTok"
|
||||||
if (r[service + "Frontend"] == "yatte") options[service].frontend = "yattee"
|
break
|
||||||
else options[service].frontend = r[service + "Frontend"]
|
case "sendFiles":
|
||||||
}
|
oldService = "sendTarget"
|
||||||
if (r[service + "RedirectType"]) options[service].redirectType = r[service + "RedirectType"]
|
break
|
||||||
if (r[service + "EmbedFrontend"] && (service != "youtube" || r[service + "EmbedFrontend"] == "invidious" || "piped")) options[service].embedFrontend = r[service + "EmbedFrontend"]
|
default:
|
||||||
for (const frontend in config.services[service].frontends) {
|
oldService = service
|
||||||
browser.local.storage.get(`${frontend}Latency`, r => {
|
}
|
||||||
if (r) latency[frontend] = r[frontend + "Latency"]
|
options[service].enabled = !r["disable" + utils.camelCase(oldService)]
|
||||||
for (const network in config.networks) {
|
if (r[oldService + "Frontend"]) {
|
||||||
let protocol
|
if (r[oldService + "Frontend"] == "yatte") options[service].frontend = "yattee"
|
||||||
if (network == "clearnet") protocol = "normal"
|
else options[service].frontend = r[oldService + "Frontend"]
|
||||||
else protocol = network
|
}
|
||||||
browser.storage.local.get([`${frontend}${utils.camelCase(protocol)}RedirectsChecks`, `${frontend}${utils.camelCase(protocol)}CustomRedirects`], r => {
|
if (r[oldService + "RedirectType"]) options[service].redirectType = r[oldService + "RedirectType"]
|
||||||
if (r) {
|
if (r[oldService + "EmbedFrontend"] && (service != "youtube" || r[oldService + "EmbedFrontend"] == "invidious" || r[oldService + "EmbedFrontend"] == "piped"))
|
||||||
options[frontend][network].checks = r[frontend + utils.camelCase(protocol) + "RedirectsChecks"]
|
options[service].embedFrontend = r[oldService + "EmbedFrontend"]
|
||||||
options[frontend][network].custom = r[frontend + utils.camelCase(protocol) + "CustomRedirects"]
|
for (const frontend in config.services[service].frontends) {
|
||||||
}
|
if (r[frontend + "Latency"]) latency[frontend] = r[frontend + "Latency"]
|
||||||
})
|
for (const network in config.networks) {
|
||||||
}
|
let protocol
|
||||||
})
|
if (network == "clearnet") protocol = "normal"
|
||||||
|
else protocol = network
|
||||||
|
if (r[frontend + utils.camelCase(protocol) + "RedirectsChecks"]) {
|
||||||
|
options[frontend][network].enabled = r[frontend + utils.camelCase(protocol) + "RedirectsChecks"]
|
||||||
|
options[frontend][network].custom = r[frontend + utils.camelCase(protocol) + "CustomRedirects"]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
}
|
||||||
}
|
}
|
||||||
browser.storage.local.set({ options, latency })
|
browser.storage.local.set({ options, latency }, () => resolve())
|
||||||
resolve()
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
|
@ -342,7 +342,7 @@ function getPreferencesFromToken(frontend, targetUrl, urls, name, endpoint) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function copyRaw(test, copyRawElement, config) {
|
function copyRaw(test, copyRawElement) {
|
||||||
return new Promise(resolve => {
|
return new Promise(resolve => {
|
||||||
browser.tabs.query({ active: true, currentWindow: true }, async tabs => {
|
browser.tabs.query({ active: true, currentWindow: true }, async tabs => {
|
||||||
let currTab = tabs[0]
|
let currTab = tabs[0]
|
||||||
|
@ -355,7 +355,7 @@ function copyRaw(test, copyRawElement, config) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
let newUrl = servicesHelper.reverse(url, config)
|
const newUrl = await servicesHelper.reverse(url)
|
||||||
|
|
||||||
if (newUrl) {
|
if (newUrl) {
|
||||||
resolve(newUrl)
|
resolve(newUrl)
|
||||||
|
@ -387,9 +387,7 @@ function unify() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const result = await servicesHelper.unifyPreferences(url, currTab.id)
|
resolve(await servicesHelper.unifyPreferences(url, currTab.id))
|
||||||
|
|
||||||
resolve(result)
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
|
@ -22,7 +22,8 @@
|
||||||
"frontends": {
|
"frontends": {
|
||||||
"invidious": {
|
"invidious": {
|
||||||
"preferences": {
|
"preferences": {
|
||||||
"cookies": ["PREFS"]
|
"cookies": ["PREFS"],
|
||||||
|
"localstorage": ["dark_mode"]
|
||||||
},
|
},
|
||||||
"name": "Invidious",
|
"name": "Invidious",
|
||||||
"embeddable": true,
|
"embeddable": true,
|
||||||
|
@ -529,7 +530,7 @@
|
||||||
"embeddable": false,
|
"embeddable": false,
|
||||||
"url": "https://maps.libredirect.invalid"
|
"url": "https://maps.libredirect.invalid"
|
||||||
},
|
},
|
||||||
"uploadFiles": {
|
"sendFiles": {
|
||||||
"frontends": {
|
"frontends": {
|
||||||
"send": {
|
"send": {
|
||||||
"name": "Send",
|
"name": "Send",
|
||||||
|
|
|
@ -431,6 +431,7 @@ def peertube():
|
||||||
|
|
||||||
def isValid(url): # This code is contributed by avanitrachhadiya2155
|
def isValid(url): # This code is contributed by avanitrachhadiya2155
|
||||||
try:
|
try:
|
||||||
|
url.encode('ascii')
|
||||||
result = urlparse(url)
|
result = urlparse(url)
|
||||||
return all([result.scheme, result.netloc])
|
return all([result.scheme, result.netloc])
|
||||||
except Exception:
|
except Exception:
|
||||||
|
|
|
@ -84,7 +84,7 @@
|
||||||
<path d="M19.35 10.04C18.67 6.59 15.64 4 12 4 9.11 4 6.6 5.64 5.35 8.04 2.34 8.36 0 10.91 0 14c0 3.31 2.69 6 6 6h13c2.76 0 5-2.24 5-5 0-2.64-2.05-4.78-4.65-4.96zM14 13v4h-4v-4H7l5-5 5 5h-3z"></path>
|
<path d="M19.35 10.04C18.67 6.59 15.64 4 12 4 9.11 4 6.6 5.64 5.35 8.04 2.34 8.36 0 10.91 0 14c0 3.31 2.69 6 6 6h13c2.76 0 5-2.24 5-5 0-2.64-2.05-4.78-4.65-4.96zM14 13v4h-4v-4H7l5-5 5 5h-3z"></path>
|
||||||
</svg>
|
</svg>
|
||||||
|
|
||||||
<a href="#uploadFiles" data-localise="__MSG_uploadFiles__">Send Files</a></div>
|
<a href="#sendFiles" data-localise="__MSG_sendFiles__">Send Files</a></div>
|
||||||
<div class="title"><svg xmlns="http://www.w3.org/2000/svg" height="24" width="24" fill="currentColor">
|
<div class="title"><svg xmlns="http://www.w3.org/2000/svg" height="24" width="24" fill="currentColor">
|
||||||
<path d="M11 17h2v-6h-2Zm1-8q.425 0 .713-.288Q13 8.425 13 8t-.287-.713Q12.425 7 12 7t-.712.287Q11 7.575 11 8t.288.712Q11.575 9 12 9Zm0 13q-2.075 0-3.9-.788-1.825-.787-3.175-2.137-1.35-1.35-2.137-3.175Q2 14.075 2 12t.788-3.9q.787-1.825 2.137-3.175 1.35-1.35 3.175-2.138Q9.925 2 12 2t3.9.787q1.825.788 3.175 2.138 1.35 1.35 2.137 3.175Q22 9.925 22 12t-.788 3.9q-.787 1.825-2.137 3.175-1.35 1.35-3.175 2.137Q14.075 22 12 22Zm0-2q3.35 0 5.675-2.325Q20 15.35 20 12q0-3.35-2.325-5.675Q15.35 4 12 4 8.65 4 6.325 6.325 4 8.65 4 12q0 3a.35 2.325 5.675Q8.65 20 12 20Zm0-8Z"></path>
|
<path d="M11 17h2v-6h-2Zm1-8q.425 0 .713-.288Q13 8.425 13 8t-.287-.713Q12.425 7 12 7t-.712.287Q11 7.575 11 8t.288.712Q11.575 9 12 9Zm0 13q-2.075 0-3.9-.788-1.825-.787-3.175-2.137-1.35-1.35-2.137-3.175Q2 14.075 2 12t.788-3.9q.787-1.825 2.137-3.175 1.35-1.35 3.175-2.138Q9.925 2 12 2t3.9.787q1.825.788 3.175 2.138 1.35 1.35 2.137 3.175Q22 9.925 22 12t-.788 3.9q-.787 1.825-2.137 3.175-1.35 1.35-3.175 2.137Q14.075 22 12 22Zm0-2q3.35 0 5.675-2.325Q20 15.35 20 12q0-3.35-2.325-5.675Q15.35 4 12 4 8.65 4 6.325 6.325 4 8.65 4 12q0 3a.35 2.325 5.675Q8.65 20 12 20Zm0-8Z"></path>
|
||||||
</svg>
|
</svg>
|
||||||
|
@ -150,11 +150,6 @@
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
<div class="buttons buttons-inline"><a class="button button-inline" id="test">
|
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="currentColor">
|
|
||||||
<path d="M19 9h-4V3H9v6H5l7 7 7-7zM5 18v2h14v-2H5z"></path>
|
|
||||||
</svg>
|
|
||||||
Test Test Yes Yes</a> </div>
|
|
||||||
<div class="checklist" id="exceptions-custom-checklist"></div>
|
<div class="checklist" id="exceptions-custom-checklist"></div>
|
||||||
<div class="buttons buttons-inline"><a class="button button-inline" id="update-instances">
|
<div class="buttons buttons-inline"><a class="button button-inline" id="update-instances">
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="currentColor">
|
<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="currentColor">
|
||||||
|
@ -323,9 +318,9 @@
|
||||||
<path d="M19.35 10.04C18.67 6.59 15.64 4 12 4 9.11 4 6.6 5.64 5.35 8.04 2.34 8.36 0 10.91 0 14c0 3.31 2.69 6 6 6h13c2.76 0 5-2.24 5-5 0-2.64-2.05-4.78-4.65-4.96zM14 13v4h-4v-4H7l5-5 5 5h-3z"></path>
|
<path d="M19.35 10.04C18.67 6.59 15.64 4 12 4 9.11 4 6.6 5.64 5.35 8.04 2.34 8.36 0 10.91 0 14c0 3.31 2.69 6 6 6h13c2.76 0 5-2.24 5-5 0-2.64-2.05-4.78-4.65-4.96zM14 13v4h-4v-4H7l5-5 5 5h-3z"></path>
|
||||||
</svg>
|
</svg>
|
||||||
|
|
||||||
<x data-localise="__MSG_uploadFiles__">Send Files</x>
|
<x data-localise="__MSG_sendFiles__">Send Files</x>
|
||||||
</div>
|
</div>
|
||||||
<input id="uploadFiles" type="checkbox">
|
<input id="sendFiles" type="checkbox">
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
@ -3139,14 +3134,14 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</section>
|
</section>
|
||||||
<section class="option-block" id="uploadFiles_page">
|
<section class="option-block" id="sendFiles_page">
|
||||||
<div class="some-block option-block">
|
<div class="some-block option-block">
|
||||||
<h1 data-localise="__MSG_uploadFiles__">Send Files</h1>
|
<h1 data-localise="__MSG_sendFiles__">Send Files</h1>
|
||||||
</div>
|
</div>
|
||||||
<hr>
|
<hr>
|
||||||
<div class="some-block option-block">
|
<div class="some-block option-block">
|
||||||
<h4 data-localise="__MSG_enable__">Enable</h4>
|
<h4 data-localise="__MSG_enable__">Enable</h4>
|
||||||
<input id="uploadFiles-enabled" type="checkbox">
|
<input id="sendFiles-enabled" type="checkbox">
|
||||||
</div>
|
</div>
|
||||||
<hr>
|
<hr>
|
||||||
<div id="send">
|
<div id="send">
|
||||||
|
|
|
@ -49,16 +49,16 @@ function setOption(option, multiChoice, event) {
|
||||||
let exportSettingsElement = document.getElementById("export-settings")
|
let exportSettingsElement = document.getElementById("export-settings")
|
||||||
|
|
||||||
function exportSettings() {
|
function exportSettings() {
|
||||||
browser.storage.local.get(null, result => {
|
browser.storage.local.get("options", result => {
|
||||||
let resultString = JSON.stringify(result, null, " ")
|
result.options.version = browser.runtime.getManifest().version
|
||||||
exportSettingsElement.href = "data:application/json;base64," + btoa(encodeURI(resultString))
|
let resultString = JSON.stringify(result.options, null, " ")
|
||||||
|
exportSettingsElement.href = "data:application/json;base64," + btoa(resultString)
|
||||||
exportSettingsElement.download = "libredirect-settings.json"
|
exportSettingsElement.download = "libredirect-settings.json"
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
exportSettings()
|
exportSettings()
|
||||||
|
|
||||||
document.getElementById("general_page").addEventListener("click", exportSettings)
|
document.getElementById("general_page").addEventListener("click", exportSettings)
|
||||||
document.getElementById("test").addEventListener("click", servicesHelper.upgradeOptions)
|
|
||||||
|
|
||||||
let importSettingsElement = document.getElementById("import-settings")
|
let importSettingsElement = document.getElementById("import-settings")
|
||||||
let importSettingsElementText = document.getElementById("import_settings_text")
|
let importSettingsElementText = document.getElementById("import_settings_text")
|
||||||
|
@ -70,7 +70,22 @@ importSettingsElement.addEventListener("change", () => {
|
||||||
reader.onload = async () => {
|
reader.onload = async () => {
|
||||||
const data = JSON.parse(reader.result)
|
const data = JSON.parse(reader.result)
|
||||||
if ("theme" in data && "disableImgur" in data && "imgurRedirects" in data) {
|
if ("theme" in data && "disableImgur" in data && "imgurRedirects" in data) {
|
||||||
browser.storage.local.clear(() => browser.storage.local.set({ ...data }, () => location.reload()))
|
browser.storage.local.clear(() =>
|
||||||
|
browser.storage.local.set({ ...data }, () => {
|
||||||
|
fetch("/instances/blacklist.json")
|
||||||
|
.then(response => response.text())
|
||||||
|
.then(async data => {
|
||||||
|
browser.storage.local.set({ blacklists: JSON.parse(data) }, async () => {
|
||||||
|
await generalHelper.initDefaults()
|
||||||
|
await servicesHelper.initDefaults()
|
||||||
|
await servicesHelper.upgradeOptions()
|
||||||
|
location.reload()
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
)
|
||||||
|
} else if ("version" in data) {
|
||||||
|
browser.storage.local.clear(() => browser.storage.local.set({ options: data }, () => location.reload()))
|
||||||
} else {
|
} else {
|
||||||
console.log("incompatible settings")
|
console.log("incompatible settings")
|
||||||
importError()
|
importError()
|
||||||
|
|
|
@ -107,13 +107,13 @@
|
||||||
<h4 data-localise="__MSG_maps__">Maps</h4></a>
|
<h4 data-localise="__MSG_maps__">Maps</h4></a>
|
||||||
<input class="maps-enabled" type="checkbox"/>
|
<input class="maps-enabled" type="checkbox"/>
|
||||||
</div>
|
</div>
|
||||||
<div class="uploadFiles some-block"><a class="title" href="https://send.libredirect.invalid">
|
<div class="sendFiles some-block"><a class="title" href="https://send.libredirect.invalid">
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="currentColor">
|
<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="currentColor">
|
||||||
<path d="M19.35 10.04C18.67 6.59 15.64 4 12 4 9.11 4 6.6 5.64 5.35 8.04 2.34 8.36 0 10.91 0 14c0 3.31 2.69 6 6 6h13c2.76 0 5-2.24 5-5 0-2.64-2.05-4.78-4.65-4.96zM14 13v4h-4v-4H7l5-5 5 5h-3z"></path>
|
<path d="M19.35 10.04C18.67 6.59 15.64 4 12 4 9.11 4 6.6 5.64 5.35 8.04 2.34 8.36 0 10.91 0 14c0 3.31 2.69 6 6 6h13c2.76 0 5-2.24 5-5 0-2.64-2.05-4.78-4.65-4.96zM14 13v4h-4v-4H7l5-5 5 5h-3z"></path>
|
||||||
</svg>
|
</svg>
|
||||||
|
|
||||||
<h4 data-localise="__MSG_uploadFiles__">Send Files</h4></a>
|
<h4 data-localise="__MSG_sendFiles__">Send Files</h4></a>
|
||||||
<input class="uploadFiles-enabled" type="checkbox"/>
|
<input class="sendFiles-enabled" type="checkbox"/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="current_site_divider">
|
<div id="current_site_divider">
|
||||||
|
@ -220,13 +220,13 @@
|
||||||
<h4 data-localise="__MSG_maps__">Maps</h4></a>
|
<h4 data-localise="__MSG_maps__">Maps</h4></a>
|
||||||
<input class="maps-enabled" type="checkbox"/>
|
<input class="maps-enabled" type="checkbox"/>
|
||||||
</div>
|
</div>
|
||||||
<div class="uploadFiles some-block"><a class="title" href="https://send.libredirect.invalid">
|
<div class="sendFiles some-block"><a class="title" href="https://send.libredirect.invalid">
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="currentColor">
|
<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="currentColor">
|
||||||
<path d="M19.35 10.04C18.67 6.59 15.64 4 12 4 9.11 4 6.6 5.64 5.35 8.04 2.34 8.36 0 10.91 0 14c0 3.31 2.69 6 6 6h13c2.76 0 5-2.24 5-5 0-2.64-2.05-4.78-4.65-4.96zM14 13v4h-4v-4H7l5-5 5 5h-3z"></path>
|
<path d="M19.35 10.04C18.67 6.59 15.64 4 12 4 9.11 4 6.6 5.64 5.35 8.04 2.34 8.36 0 10.91 0 14c0 3.31 2.69 6 6 6h13c2.76 0 5-2.24 5-5 0-2.64-2.05-4.78-4.65-4.96zM14 13v4h-4v-4H7l5-5 5 5h-3z"></path>
|
||||||
</svg>
|
</svg>
|
||||||
|
|
||||||
<h4 data-localise="__MSG_uploadFiles__">Send Files</h4></a>
|
<h4 data-localise="__MSG_sendFiles__">Send Files</h4></a>
|
||||||
<input class="uploadFiles-enabled" type="checkbox"/>
|
<input class="sendFiles-enabled" type="checkbox"/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -26,7 +26,7 @@ utils.switchInstance(true).then(r => {
|
||||||
else document.getElementById("change_instance").addEventListener("click", () => utils.switchInstance(false))
|
else document.getElementById("change_instance").addEventListener("click", () => utils.switchInstance(false))
|
||||||
})
|
})
|
||||||
|
|
||||||
utils.copyRaw(true, null, config).then(r => {
|
utils.copyRaw(true).then(r => {
|
||||||
if (!r) document.getElementById("copy_raw_div").style.display = "none"
|
if (!r) document.getElementById("copy_raw_div").style.display = "none"
|
||||||
else {
|
else {
|
||||||
const copy_raw = document.getElementById("copy_raw")
|
const copy_raw = document.getElementById("copy_raw")
|
||||||
|
@ -81,13 +81,13 @@ browser.storage.local.get("options", r => {
|
||||||
let service = await serviceHelper.computeService(url, true)
|
let service = await serviceHelper.computeService(url, true)
|
||||||
let frontend
|
let frontend
|
||||||
if (service) {
|
if (service) {
|
||||||
if (service[1]) {
|
if (service[0]) {
|
||||||
frontend = service[1]
|
frontend = service[1]
|
||||||
service = service[0]
|
service = service[0]
|
||||||
}
|
}
|
||||||
divs[service].current.classList.remove("hide")
|
divs[service].current.classList.remove("hide")
|
||||||
divs[service].all.classList.add("hide")
|
divs[service].all.classList.add("hide")
|
||||||
if (config.services[service].frontends[frontend].preferences && !config.services[service].frontends[frontend].preferences.token) {
|
if (frontend && config.services[service].frontends[frontend].preferences && !config.services[service].frontends[frontend].preferences.token) {
|
||||||
const unify = document.getElementById("unify")
|
const unify = document.getElementById("unify")
|
||||||
const textElement = document.getElementById("unify").getElementsByTagName("h4")[0]
|
const textElement = document.getElementById("unify").getElementsByTagName("h4")[0]
|
||||||
unify.addEventListener("click", () => {
|
unify.addEventListener("click", () => {
|
||||||
|
|
Loading…
Reference in New Issue