From 6a171b86c75877da1ff47be9bfd46dd818cad896 Mon Sep 17 00:00:00 2001 From: Daniel Aleksandersen Date: Tue, 2 Apr 2019 14:03:48 +0200 Subject: [PATCH] Add Dat protocol support --- src/lib/background/index.js | 2 +- src/lib/common/utils.js | 3 +++ src/manifest.json | 7 ++++++- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/lib/background/index.js b/src/lib/background/index.js index 9391606..37579f5 100644 --- a/src/lib/background/index.js +++ b/src/lib/background/index.js @@ -220,7 +220,7 @@ chrome.webRequest.onHeadersReceived.addListener( record(tabId, "page-loaded", statusCode); }, - {urls: ["http://*/*", "https://*/*"]} + {urls: ["http://*/*", "https://*/*", "dat://*/*"]} ); on("authentication-changed", (isAuthenticated) => diff --git a/src/lib/common/utils.js b/src/lib/common/utils.js index 6c689bc..96d9cbd 100644 --- a/src/lib/common/utils.js +++ b/src/lib/common/utils.js @@ -54,6 +54,9 @@ exports.getCurrentTab = getCurrentTab; function normalizeURL(url) { url = new URL(url); + if (url.protocol == 'dat:') + url.protocol = 'http:' + if (!/^https?:$/.test(url.protocol)) throw new URIError("URL has invalid protocol"); diff --git a/src/manifest.json b/src/manifest.json index e5ba7c2..8c1f049 100644 --- a/src/manifest.json +++ b/src/manifest.json @@ -25,7 +25,11 @@ }, "content_scripts": [ { - "matches": ["http://*/*", "https://*/*"], + "matches": [ + "https://*/*", + "http://*/*", + "dat://*/*" + ], "js": ["lib/content/index.js"], "run_at": "document_start" } @@ -45,6 +49,7 @@ "permissions": [ "http://*/*", "https://*/*", + "dat://*/*", "alarms", "history", "idle",