Re-enabled Switch Instances
This commit is contained in:
parent
0bd336030f
commit
a0aaf46e42
|
@ -111,7 +111,8 @@ function redirect(url, type, initiator) {
|
|||
}
|
||||
|
||||
function switchInstance(url) {
|
||||
return new Promise(resolve => {
|
||||
return new Promise(async resolve => {
|
||||
await init();
|
||||
let protocolHost = utils.protocolHost(url);
|
||||
const all = [
|
||||
...mediumRedirects.scribe.tor,
|
||||
|
|
|
@ -100,7 +100,8 @@ function redirect(url, type, initiator) {
|
|||
}
|
||||
|
||||
function switchInstance(url) {
|
||||
return new Promise(resolve => {
|
||||
return new Promise(async resolve => {
|
||||
await init();
|
||||
const protocolHost = utils.protocolHost(url);
|
||||
if (!all().includes(protocolHost)) { resolve(); return; }
|
||||
|
||||
|
|
|
@ -78,7 +78,8 @@ function all() {
|
|||
}
|
||||
|
||||
function switchInstance(url) {
|
||||
return new Promise(resolve => {
|
||||
return new Promise(async resolve => {
|
||||
await init();
|
||||
const protocolHost = utils.protocolHost(url);
|
||||
if (!all().includes(protocolHost)) { resolve(); return; }
|
||||
if (url.pathname != '/') { resolve(); return; }
|
||||
|
|
|
@ -113,15 +113,16 @@ function reverse(url) {
|
|||
|
||||
function switchInstance(url) {
|
||||
return new Promise(async resolve => {
|
||||
await init();
|
||||
const protocolHost = utils.protocolHost(url);
|
||||
if (!all().includes(protocolHost)) { resolve; return; }
|
||||
if (!all().includes(protocolHost)) { resolve(); return; }
|
||||
let instancesList;
|
||||
if (twitterProtocol == 'normal') instancesList = [...nitterNormalRedirectsChecks, ...nitterNormalCustomRedirects];
|
||||
else if (twitterProtocol == 'tor') instancesList = [...nitterTorRedirectsChecks, ...nitterTorCustomRedirects];
|
||||
|
||||
let index = instancesList.indexOf(protocolHost);
|
||||
if (index > -1) instancesList.splice(index, 1);
|
||||
if (instancesList.length === 0) { resolve; return; }
|
||||
if (instancesList.length === 0) { resolve(); return; }
|
||||
|
||||
const randomInstance = utils.getRandomInstance(instancesList);
|
||||
resolve(`${randomInstance}${url.pathname}${url.search}`);
|
||||
|
|
|
@ -386,17 +386,17 @@ function switchInstance(test) {
|
|||
try { url = new URL(currTab.url); }
|
||||
catch { resolve(); return };
|
||||
let newUrl = await youtubeHelper.switchInstance(url);
|
||||
// if (!newUrl) newUrl = twitterHelper.switchInstance(url);
|
||||
// if (!newUrl) newUrl = instagramHelper.switchInstance(url);
|
||||
// if (!newUrl) newUrl = redditHelper.switchInstance(url);
|
||||
// if (!newUrl) newUrl = searchHelper.switchInstance(url);
|
||||
if (!newUrl) newUrl = await twitterHelper.switchInstance(url);
|
||||
if (!newUrl) newUrl = await instagramHelper.switchInstance(url);
|
||||
if (!newUrl) newUrl = await redditHelper.switchInstance(url);
|
||||
if (!newUrl) newUrl = await searchHelper.switchInstance(url);
|
||||
if (!newUrl) newUrl = await translateHelper.switchInstance(url);
|
||||
// if (!newUrl) newUrl = mediumHelper.switchInstance(url);
|
||||
// if (!newUrl) newUrl = sendTargetsHelper.switchInstance(url);
|
||||
// if (!newUrl) newUrl = peertubeHelper.switchInstance(url);
|
||||
// if (!newUrl) newUrl = lbryHelper.switchInstance(url);
|
||||
// if (!newUrl) newUrl = imgurHelper.switchInstance(url);
|
||||
// if (!newUrl) newUrl = wikipediaHelper.switchInstance(url);
|
||||
if (!newUrl) newUrl = await mediumHelper.switchInstance(url);
|
||||
if (!newUrl) newUrl = await sendTargetsHelper.switchInstance(url);
|
||||
if (!newUrl) newUrl = await peertubeHelper.switchInstance(url);
|
||||
if (!newUrl) newUrl = await lbryHelper.switchInstance(url);
|
||||
if (!newUrl) newUrl = await imgurHelper.switchInstance(url);
|
||||
if (!newUrl) newUrl = await wikipediaHelper.switchInstance(url);
|
||||
|
||||
if (newUrl) {
|
||||
if (!test)
|
||||
|
|
|
@ -163,8 +163,8 @@ function switchInstance(url) {
|
|||
...wikilessNormalCustomRedirects,
|
||||
...wikilessTorCustomRedirects,
|
||||
...wikilessI2pCustomRedirects
|
||||
]
|
||||
if (!wikipediaList.includes(protocolHost)) return;
|
||||
];
|
||||
if (!wikipediaList.includes(protocolHost)) { resolve(); return; }
|
||||
|
||||
let instancesList;
|
||||
if (wikipediaProtocol == 'normal') instancesList = [...wikilessNormalCustomRedirects, ...wikilessNormalRedirectsChecks];
|
||||
|
@ -173,10 +173,10 @@ function switchInstance(url) {
|
|||
|
||||
let index = instancesList.indexOf(protocolHost);
|
||||
if (index > -1) instancesList.splice(index, 1);
|
||||
if (instancesList.length === 0) return;
|
||||
if (instancesList.length === 0) { resolve(); return; }
|
||||
|
||||
const randomInstance = utils.getRandomInstance(instancesList);
|
||||
return `${randomInstance}${url.pathname}${url.search}`;
|
||||
resolve(`${randomInstance}${url.pathname}${url.search}`);
|
||||
})
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue