Made networks mixed https://github.com/libredirect/libredirect/issues/486
This commit is contained in:
parent
1e75b3cc62
commit
c099e1a75f
@ -32,8 +32,6 @@ async function initDefaults() {
|
||||
},
|
||||
theme: "detect",
|
||||
popupServices: ["youtube", "twitter", "instagram", "tiktok", "imgur", "reddit", "quora", "translate", "maps"],
|
||||
network: "clearnet",
|
||||
networkFallback: true,
|
||||
},
|
||||
},
|
||||
() => resolve()
|
||||
|
@ -1,15 +0,0 @@
|
||||
window.browser = window.browser || window.chrome
|
||||
|
||||
browser.storage.local.get(["localstorage", "tmp"], r => {
|
||||
let localstorageJson = r.localstorage
|
||||
const frontend = r.tmp[0]
|
||||
const items = r.tmp[1]
|
||||
localstorageJson[frontend] = {}
|
||||
|
||||
for (const item of items) {
|
||||
let tmp = localStorage.getItem(item)
|
||||
if (tmp) localstorageJson[frontend][item] = tmp
|
||||
}
|
||||
|
||||
browser.storage.local.set({ localstorage: localstorageJson })
|
||||
})
|
@ -89,8 +89,10 @@ function redirect(url, type, initiator, forceRedirection) {
|
||||
if (initiator && all(service, null, options, config, redirects).includes(initiator.origin)) return "BYPASSTAB"
|
||||
|
||||
if (config.services[service].frontends[frontend].instanceList) {
|
||||
let instanceList = [...options[frontend][options.network].enabled, ...options[frontend][options.network].custom]
|
||||
if (instanceList.length === 0 && options.networkFallback) instanceList = [...options[frontend].clearnet.enabled, ...options[frontend].clearnet.custom]
|
||||
let instanceList = []
|
||||
for (const network in options[frontend]) {
|
||||
instanceList.push(...[...options[frontend][network].enabled, ...options[frontend][network].custom])
|
||||
}
|
||||
if (instanceList.length === 0) return
|
||||
randomInstance = utils.getRandomInstance(instanceList)
|
||||
} else if (config.services[service].frontends[frontend].singleInstance) randomInstance = config.services[service].frontends[frontend].singleInstance
|
||||
@ -489,15 +491,17 @@ function switchInstance(url) {
|
||||
for (const service in config.services) {
|
||||
if (!all(service, null, options, config, redirects).includes(protocolHost)) continue
|
||||
|
||||
let instancesList
|
||||
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]
|
||||
for (const network in options[frontend]) {
|
||||
instancesList.push(...[...options[frontend][network].enabled, ...options[frontend][network].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]
|
||||
for (const network in options[frontend]) {
|
||||
instancesList.push(...[...options[frontend][network].enabled, ...options[frontend][network].custom])
|
||||
}
|
||||
}
|
||||
|
||||
let oldInstance
|
||||
|
@ -1,13 +0,0 @@
|
||||
window.browser = window.browser || window.chrome
|
||||
|
||||
browser.storage.local.get(["localstorage", "tmp"], r => {
|
||||
const localstorageJson = r.localstorage
|
||||
const frontend = r.tmp[0]
|
||||
const items = localstorageJson[frontend]
|
||||
|
||||
for (const item in items) {
|
||||
localStorage.setItem(item, items[item])
|
||||
}
|
||||
|
||||
window.close()
|
||||
})
|
@ -46,28 +46,29 @@
|
||||
<% for (const network in config.networks) { -%>
|
||||
<div class="<%= network %>">
|
||||
<div class="some-block option-block">
|
||||
<h4 data-localise="__MSG_defaultInstances__">Default Instances</h4>
|
||||
<h4><%= network.charAt(0).toUpperCase() + network.slice(1) %></h4>
|
||||
</div>
|
||||
<div class="checklist"></div>
|
||||
<hr />
|
||||
<div class="some-block option-block">
|
||||
<h4 data-localise="__MSG_customInstances__">Custom Instances</h4>
|
||||
</div>
|
||||
<form class="custom-instance-form">
|
||||
<div class="some-block option-block">
|
||||
<input class="custom-instance" placeholder="http://<%= frontend %>.<%= config.networks[network].tld %>" type="url" />
|
||||
<button class="add add-instance" type="submit">
|
||||
<svg xmlns="https://www.w3.org/2000/svg" height="20px" viewBox="0 0 24 24" width="20px" fill="currentColor">
|
||||
<path d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"></path>
|
||||
</svg>
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<div class="checklist custom-checklist"></div>
|
||||
<% if (network=="clearnet" ) { _%>
|
||||
<% } _%>
|
||||
</div>
|
||||
<% } %>
|
||||
<div class="some-block option-block">
|
||||
<h4 data-localise="__MSG_customInstances__">Custom Instances</h4>
|
||||
</div>
|
||||
<form class="custom-instance-form">
|
||||
<div class="some-block option-block">
|
||||
<input class="custom-instance" placeholder="http://<%= frontend %>.com" type="url" />
|
||||
<button class="add add-instance" type="submit">
|
||||
<svg xmlns="https://www.w3.org/2000/svg" height="20px" viewBox="0 0 24 24" width="20px" fill="currentColor">
|
||||
<path d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"></path>
|
||||
</svg>
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<% } _%> <% } %>
|
||||
</section>
|
||||
|
@ -60,25 +60,6 @@ function changeFrontendsSettings(service) {
|
||||
}
|
||||
}
|
||||
|
||||
function changeNetworkSettings() {
|
||||
for (const service in config.services) {
|
||||
for (const frontend in config.services[service].frontends) {
|
||||
if (config.services[service].frontends[frontend].instanceList) {
|
||||
const frontendDiv = document.getElementById(frontend)
|
||||
for (const network in config.networks) {
|
||||
const networkDiv = frontendDiv.getElementsByClassName(network)[0]
|
||||
if (network == options.network) {
|
||||
networkDiv.style.display = "block"
|
||||
} else {
|
||||
networkDiv.style.display = "none"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
changeNetworkSettings()
|
||||
for (const service in config.services) {
|
||||
divs[service] = {}
|
||||
//divs[service].page = document.getElementById(`${service}_page`)
|
||||
|
Loading…
x
Reference in New Issue
Block a user