Skip to content

Commit

Permalink
Fixed infinite loop #38
Browse files Browse the repository at this point in the history
  • Loading branch information
ManeraKai committed Feb 16, 2022
1 parent b157cc8 commit 9f91997
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 21 deletions.
9 changes: 4 additions & 5 deletions src/assets/javascripts/helpers/medium.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,10 @@ function setRedirects(val) {
redirects.scribe = val;
browser.storage.sync.set({ mediumRedirects: redirects })
console.log("mediumRedirects: ", val)
for (const item of scribeRedirectsChecks)
if (!redirects.scribe.normal.includes(item)) {
var index = scribeRedirectsChecks.indexOf(item);
if (index !== -1) scribeRedirectsChecks.splice(index, 1);
}
for (const item of scribeRedirectsChecks) if (!redirects.scribe.normal.includes(item)) {
var index = scribeRedirectsChecks.indexOf(item);
if (index !== -1) scribeRedirectsChecks.splice(index, 1);
}
setScribeRedirectsChecks(scribeRedirectsChecks);
}

Expand Down
26 changes: 10 additions & 16 deletions src/assets/javascripts/helpers/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ let redirects = {
},
};
const getRedirects = () => redirects;
const getCustomRedirects = function () {
const getCustomRedirects = () => {
return {
"searx": {
"normal": [...searxRedirectsChecks, ...searxCustomRedirects]
Expand All @@ -151,13 +151,9 @@ function setSearxRedirects(val) {
redirects.searx = val;
browser.storage.sync.set({ searchRedirects: redirects })
console.log("searxRedirects:", val)
for (const item of searxRedirectsChecks) {
console.log(item)
if (!redirects.searx.normal.includes(item)) {
var index = searxRedirectsChecks.indexOf(item);
if (index !== -1) searxRedirectsChecks.splice(index, 1);
console.log(`Deleted ${item}`);
}
for (const item of searxRedirectsChecks) if (!redirects.searx.normal.includes(item)) {
var index = searxRedirectsChecks.indexOf(item);
if (index !== -1) searxRedirectsChecks.splice(index, 1);
}
setSearxRedirectsChecks(searxRedirectsChecks);
}
Expand All @@ -166,6 +162,11 @@ function setWhoogleRedirects(val) {
redirects.whoogle = val;
browser.storage.sync.set({ searchRedirects: redirects })
console.log("whoogleRedirects:", val)
for (const item of whoogleRedirectsChecks) if (!redirects.whoogle.normal.includes(item)) {
var index = whoogleRedirectsChecks.indexOf(item);
if (index !== -1) whoogleRedirectsChecks.splice(index, 1);
}
setWhoogleRedirectsChecks(whoogleRedirectsChecks);
}

let whoogleRedirectsChecks;
Expand All @@ -174,12 +175,6 @@ function setWhoogleRedirectsChecks(val) {
whoogleRedirectsChecks = val;
browser.storage.sync.set({ whoogleRedirectsChecks })
console.log("whoogleRedirectsChecks: ", val)
for (const item of whoogleRedirectsChecks)
if (!redirects.whoogle.normal.includes(item)) {
var index = whoogleRedirectsChecks.indexOf(item);
if (index !== -1) whoogleRedirectsChecks.splice(index, 1);
}
setWhoogleRedirectsChecks(whoogleRedirectsChecks);
}

let whoogleCustomRedirects = [];
Expand Down Expand Up @@ -251,7 +246,6 @@ function redirect(url) {
return `${randomInstance}${path}?${searchQuery}`;
}


async function init() {
return new Promise((resolve) => {
browser.storage.sync.get(
Expand All @@ -266,7 +260,7 @@ async function init() {
],
(result) => {
disable = result.disableSearch ?? false;

frontend = result.searchFrontend ?? 'searx';

if (result.searchRedirects) redirects = result.searchRedirects;
Expand Down

0 comments on commit 9f91997

Please sign in to comment.