Re-enabled Switch Instances

This commit is contained in:
ManeraKai 2022-05-28 16:31:26 +03:00
parent 0bd336030f
commit a0aaf46e42
No known key found for this signature in database
GPG Key ID: 5ABC31FFD562E337
6 changed files with 23 additions and 19 deletions

View File

@ -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,

View File

@ -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; }

View File

@ -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; }

View File

@ -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}`);

View File

@ -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)

View File

@ -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}`);
})
}