aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--README.md4
-rw-r--r--src/assets/javascripts/general.js30
-rw-r--r--src/assets/javascripts/services.js13
-rw-r--r--src/pages/background/background.js6
-rw-r--r--src/pages/options/widgets/general.js13
5 files changed, 23 insertions, 43 deletions
diff --git a/README.md b/README.md
index e597053c..f22e0371 100644
--- a/README.md
+++ b/README.md
@@ -17,8 +17,8 @@ Requirements: [Node.js LTS](https://nodejs.org/)
git clone https://github.com/libredirect/browser_extension
cd browser_extension
npm install
-npm run html
-npm run start # Runs on firefox using web-ext
+npm run html # Generates html files using Pug
+npm run start # Runs in debug mode in firefox using Web-ext
```
### Run on Chromium manually
1. Open `chrome://extensions`
diff --git a/src/assets/javascripts/general.js b/src/assets/javascripts/general.js
deleted file mode 100644
index 588c67d1..00000000
--- a/src/assets/javascripts/general.js
+++ /dev/null
@@ -1,30 +0,0 @@
-"use strict"
-
-import utils from "./utils.js"
-
-window.browser = window.browser || window.chrome
-
-let exceptions
-
-function isException(url) {
- if (exceptions && url) {
- if (exceptions.url) for (const item of exceptions.url) if (item == url.href) return true
- if (exceptions.regex) for (const item of exceptions.regex) if (new RegExp(item).test(url.href)) return true
- }
- return false
-}
-
-function init() {
- return new Promise(async resolve => {
- const options = await utils.getOptions()
- if (options) exceptions = options.exceptions
- resolve()
- })
-}
-
-init()
-browser.storage.onChanged.addListener(init)
-
-export default {
- isException,
-}
diff --git a/src/assets/javascripts/services.js b/src/assets/javascripts/services.js
index 12a08d32..37847a57 100644
--- a/src/assets/javascripts/services.js
+++ b/src/assets/javascripts/services.js
@@ -83,7 +83,6 @@ function redirect(url, type, initiator, forceRedirection) {
) return "BYPASSTAB"
randomInstance = utils.getRandomInstance(instanceList)
- console.log(options[service].localhost)
if (config.services[service].frontends[frontend].localhost && options[service].instance == "localhost") {
randomInstance = `http://${frontend}.localhost:8080`
}
@@ -819,6 +818,15 @@ async function copyRaw(url, test) {
}
}
+function isException(url) {
+ let exceptions = options.exceptions
+ if (exceptions && url) {
+ if (exceptions.url) for (const item of exceptions.url) if (item == url.href) return true
+ if (exceptions.regex) for (const item of exceptions.regex) if (new RegExp(item).test(url.href)) return true
+ }
+ return false
+}
+
export default {
redirect,
redirectAsync,
@@ -828,5 +836,6 @@ export default {
upgradeOptions,
processUpdate,
copyRaw,
- switchInstance
+ switchInstance,
+ isException
}
diff --git a/src/pages/background/background.js b/src/pages/background/background.js
index 02b705c4..80713059 100644
--- a/src/pages/background/background.js
+++ b/src/pages/background/background.js
@@ -1,6 +1,5 @@
"use strict"
-import generalHelper from "../../assets/javascripts/general.js"
import utils from "../../assets/javascripts/utils.js"
import servicesHelper from "../../assets/javascripts/services.js"
@@ -44,9 +43,10 @@ browser.webRequest.onBeforeRequest.addListener(
if (tabIdRedirects[details.tabId] == false) return null
let newUrl = servicesHelper.redirect(url, details.type, initiator, tabIdRedirects[details.tabId], details.tabId)
- if (details.frameAncestors && details.frameAncestors.length > 0 && generalHelper.isException(new URL(details.frameAncestors[0].url))) newUrl = null
+ if (details.frameAncestors && details.frameAncestors.length > 0 && servicesHelper.isException(new URL(details.frameAncestors[0].url))) newUrl = null
- if (generalHelper.isException(url)) {
+ console.log(servicesHelper.isException(url))
+ if (servicesHelper.isException(url)) {
if (details.type == "main_frame")
newUrl = "BYPASSTAB"
else
diff --git a/src/pages/options/widgets/general.js b/src/pages/options/widgets/general.js
index 484edc05..3dd52af5 100644
--- a/src/pages/options/widgets/general.js
+++ b/src/pages/options/widgets/general.js
@@ -152,14 +152,15 @@ function calcExceptionsCustomInstances() {
}
calcExceptionsCustomInstances()
document.getElementById("custom-exceptions-instance-form").addEventListener("submit", async event => {
+ console.log('something plz.... :\')')
event.preventDefault()
-
let val
- if (instanceType == "url") {
- if (nameCustomInstanceInput.validity.valid) {
- val = nameCustomInstanceInput.value
- if (!exceptionsCustomInstances.url.includes(val)) exceptionsCustomInstances.url.push(val)
- }
+ if (instanceType == "url" && nameCustomInstanceInput.validity.valid) {
+ val = nameCustomInstanceInput.value
+ const url = new URL(val)
+ val = url.href
+ val = val.replace(/^http:\/\//, 'https://')
+ if (!exceptionsCustomInstances.url.includes(val)) exceptionsCustomInstances.url.push(val)
} else if (instanceType == "regex") {
val = nameCustomInstanceInput.value
if (val.trim() != "" && !exceptionsCustomInstances.regex.includes(val)) exceptionsCustomInstances.regex.push(val)