about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/assets/javascripts/services.js42
-rw-r--r--src/config.json30
-rw-r--r--src/pages/background/background.js7
-rw-r--r--src/pages/options/index.js10
-rw-r--r--src/pages/options/widgets/services.pug8
5 files changed, 40 insertions, 57 deletions
diff --git a/src/assets/javascripts/services.js b/src/assets/javascripts/services.js
index 173bec58..12a08d32 100644
--- a/src/assets/javascripts/services.js
+++ b/src/assets/javascripts/services.js
@@ -83,6 +83,10 @@ 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`
+		}
 
 		break
 	}
@@ -795,43 +799,6 @@ function processUpdate() {
 	})
 }
 
-// For websites that have a strict policy that would not normally allow these frontends to be embedded within the website.
-function modifyContentSecurityPolicy(details) {
-	let isChanged = false
-	if (details.type != "main_frame") return
-
-	for (const header in details.responseHeaders) {
-		if (details.responseHeaders[header].name == "content-security-policy") {
-			let instancesList = []
-			for (const service in config.services) {
-				if (config.services[service].embeddable) {
-					for (const frontend in config.services[service].frontends) {
-						if (config.services[service].frontends[frontend].embeddable) {
-							for (const network in config.networks) {
-								instancesList.push(...options[frontend])
-							}
-						}
-					}
-				}
-			}
-			let securityPolicyList = details.responseHeaders[header].value.split(";")
-			for (const i in securityPolicyList) securityPolicyList[i] = securityPolicyList[i].trim()
-			let newSecurity = ""
-			for (const item of securityPolicyList) {
-				if (item.trim() == "") continue
-				let regex = item.match(/([a-z-]{0,}) (.*)/)
-				if (regex == null) continue
-				let [, key, vals] = regex
-				if (key == "frame-src") vals = vals + " " + instancesList.join(" ")
-				newSecurity += key + " " + vals + "; "
-			}
-			details.responseHeaders[header].value = newSecurity
-			isChanged = true
-		}
-	}
-	if (isChanged) return { details }
-}
-
 async function copyRaw(url, test) {
 	const newUrl = await reverse(url)
 	if (newUrl) {
@@ -860,7 +827,6 @@ export default {
 	initDefaults,
 	upgradeOptions,
 	processUpdate,
-	modifyContentSecurityPolicy,
 	copyRaw,
 	switchInstance
 }
diff --git a/src/config.json b/src/config.json
index cb8a997d..12b6bd22 100644
--- a/src/config.json
+++ b/src/config.json
@@ -135,7 +135,8 @@
 					"name": "Nitter",
 					"embeddable": true,
 					"instanceList": true,
-					"url": "https://github.com/zedeus/nitter"
+					"url": "https://github.com/zedeus/nitter",
+					"localhost": true
 				}
 			},
 			"targets": [
@@ -148,7 +149,8 @@
 			"options": {
 				"enabled": false,
 				"redirectType": "main_frame",
-				"unsupportedUrls": "bypass"
+				"unsupportedUrls": "bypass",
+				"instance": "public"
 			},
 			"imageType": "png",
 			"embeddable": true,
@@ -179,7 +181,8 @@
 				"libreddit": {
 					"name": "Libreddit",
 					"instanceList": true,
-					"url": "https://github.com/spikecodes/libreddit"
+					"url": "https://github.com/spikecodes/libreddit",
+					"localhost": true
 				},
 				"teddit": {
 					"name": "Teddit",
@@ -195,7 +198,8 @@
 			"options": {
 				"enabled": false,
 				"frontend": "libreddit",
-				"unsupportedUrls": "bypass"
+				"unsupportedUrls": "bypass",
+				"instance": "public"
 			},
 			"imageType": "png",
 			"embeddable": false,
@@ -206,7 +210,8 @@
 				"rimgo": {
 					"name": "rimgo",
 					"instanceList": true,
-					"url": "https://codeberg.org/video-prize-ranch/rimgo"
+					"url": "https://codeberg.org/video-prize-ranch/rimgo",
+					"localhost": true
 				}
 			},
 			"targets": [
@@ -216,7 +221,8 @@
 			"options": {
 				"enabled": false,
 				"redirectType": "main_frame",
-				"unsupportedUrls": "bypass"
+				"unsupportedUrls": "bypass",
+				"instance": "public"
 			},
 			"imageType": "png",
 			"embeddable": true,
@@ -311,7 +317,8 @@
 				"breezeWiki": {
 					"name": "BreezeWiki",
 					"instanceList": true,
-					"url": "https://breezewiki.com"
+					"url": "https://breezewiki.com",
+					"localhost": true
 				}
 			},
 			"targets": [
@@ -320,7 +327,8 @@
 			"name": "Fandom",
 			"options": {
 				"enabled": false,
-				"unsupportedUrls": "bypass"
+				"unsupportedUrls": "bypass",
+				"instance": "public"
 			},
 			"imageType": "svg",
 			"embeddable": false,
@@ -397,7 +405,8 @@
 				"simplyTranslate": {
 					"name": "SimplyTranslate",
 					"instanceList": true,
-					"url": "https://git.sr.ht/~metalune/simplytranslate_web"
+					"url": "https://git.sr.ht/~metalune/simplytranslate_web",
+					"localhost": true
 				},
 				"lingva": {
 					"name": "Lingva Translate",
@@ -418,7 +427,8 @@
 			"options": {
 				"enabled": false,
 				"frontend": "simplyTranslate",
-				"unsupportedUrls": "bypass"
+				"unsupportedUrls": "bypass",
+				"instance": "public"
 			},
 			"imageType": "svgMono",
 			"embeddable": false,
diff --git a/src/pages/background/background.js b/src/pages/background/background.js
index 679564fc..02b705c4 100644
--- a/src/pages/background/background.js
+++ b/src/pages/background/background.js
@@ -214,13 +214,6 @@ browser.contextMenus.onClicked.addListener(async (info) => {
 	}
 })
 
-browser.webRequest.onHeadersReceived.addListener(
-	servicesHelper.modifyContentSecurityPolicy,
-	{ urls: ["<all_urls>"] },
-	["blocking", "responseHeaders"]
-)
-
-
 browser.runtime.onMessage.addListener((request, sender, sendResponse) => {
 	if (request == "reverseTab") {
 		browser.tabs.query({ active: true, currentWindow: true }, async tabs => {
diff --git a/src/pages/options/index.js b/src/pages/options/index.js
index 068940f0..5b229656 100644
--- a/src/pages/options/index.js
+++ b/src/pages/options/index.js
@@ -34,7 +34,15 @@ async function changeFrontendsSettings(service) {
 			const frontendDiv = document.getElementById(frontend)
 			if (typeof divs[service].frontend !== "undefined") {
 				if (frontend == divs[service].frontend.value) {
-					frontendDiv.style.display = "block"
+					frontendDiv.style.display = ""
+					if (config.services[service].frontends[frontend].localhost == true) {
+						document.getElementById(`${service}-instance-div`).style.display = ""
+						if (options[service].instance == "localhost") {
+							frontendDiv.style.display = "none"
+						}
+					} else {
+						document.getElementById(`${service}-instance-div`).style.display = "none"
+					}
 				} else {
 					frontendDiv.style.display = "none"
 				}
diff --git a/src/pages/options/widgets/services.pug b/src/pages/options/widgets/services.pug
index 98fd25bb..88be0786 100644
--- a/src/pages/options/widgets/services.pug
+++ b/src/pages/options/widgets/services.pug
@@ -26,6 +26,12 @@ each val, service in services
                     else
                         option(value=frontend)=Object.values(services[service].frontends)[0].name
 
+            div(class="some-block option-block" id=service+"-instance-div")
+                h4() Instance
+                select(id=service+"-instance")
+                    option(value="localhost") localhost
+                    option(value="public") public instances
+
             if services[service].embeddable
                 div(class="some-block option-block")
                     h4(data-localise="__MSG_redirectType__") Redirect Type
@@ -40,7 +46,7 @@ each val, service in services
             if (service == 'search')
                 div(class="some-block option-block")
                     h4 Set LibRedirect as Default Search Engine
-            
+
             hr            
 
             each val, frontend in services[service].frontends