about summary refs log tree commit diff stats
path: root/src/assets/javascripts/general.js
diff options
context:
space:
mode:
authorEdward <contact@langdon.slmail.me>2022-10-09 19:04:15 +0530
committerGitHub <noreply@github.com>2022-10-09 19:04:15 +0530
commit26abc5d2c9f671d359be8a7bf503632242abb2c2 (patch)
treeab05b3b2906fbc8423eea3abe1bd8efeccefa439 /src/assets/javascripts/general.js
parentUpdate messages.json (diff)
parentMerge pull request #404 from marcelocripe/patch-1 (diff)
downloadlibredirect-26abc5d2c9f671d359be8a7bf503632242abb2c2.zip
Merge branch 'master' into patch-3
Diffstat (limited to 'src/assets/javascripts/general.js')
-rw-r--r--src/assets/javascripts/general.js55
1 files changed, 19 insertions, 36 deletions
diff --git a/src/assets/javascripts/general.js b/src/assets/javascripts/general.js
index a8360bd5..6eb0a454 100644
--- a/src/assets/javascripts/general.js
+++ b/src/assets/javascripts/general.js
@@ -1,17 +1,20 @@
 "use strict"
 window.browser = window.browser || window.chrome
 
+let exceptions
+
 function isException(url) {
 	for (const item of exceptions.url) if (item == `${url.protocol}//${url.host}`) return true
 	for (const item of exceptions.regex) if (new RegExp(item).test(url.href)) return true
 	return false
 }
 
-let exceptions
-
 function init() {
-	browser.storage.local.get("exceptions", r => {
-		exceptions = r.exceptions
+	return new Promise(resolve => {
+		browser.storage.local.get("options", r => {
+			if (r.options) exceptions = r.options.exceptions
+			resolve()
+		})
 	})
 }
 
@@ -22,46 +25,26 @@ async function initDefaults() {
 	return new Promise(resolve =>
 		browser.storage.local.set(
 			{
-				exceptions: {
-					url: [],
-					regex: [],
+				options: {
+					exceptions: {
+						url: [],
+						regex: [],
+					},
+					theme: "detect",
+					popupServices: ["youtube", "twitter", "instagram", "tiktok", "imgur", "reddit", "quora", "translate", "maps"],
+					autoRedirect: false,
+					firstPartyIsolate: false,
+					network: "clearnet",
+					networkFallback: true,
+					latencyThreshold: 1000,
 				},
-				theme: "DEFAULT",
-				popupFrontends: ["youtube", "twitter", "instagram", "tiktok", "imgur", "reddit", "quora", "translate", "maps"],
-				autoRedirect: false,
-				firstPartyIsolate: false,
-				protocol: "normal",
-				protocolFallback: true,
-				latencyThreshold: 1000,
 			},
 			() => resolve()
 		)
 	)
 }
 
-const allPopupFrontends = [
-	"youtube",
-	"youtubeMusic",
-	"twitter",
-	"instagram",
-	"tiktok",
-	"imgur",
-	"reddit",
-	"search",
-	"translate",
-	"maps",
-	"wikipedia",
-	"medium",
-	"quora",
-	"imdb",
-	"reuters",
-	"peertube",
-	"lbry",
-	"sendTargets",
-]
-
 export default {
 	isException,
 	initDefaults,
-	allPopupFrontends,
 }