Merge pull request #126 from aapl-yumi/patch-1
Add Search Engine redirects.
This commit is contained in:
commit
a075c44938
|
@ -10,9 +10,9 @@
|
|||
[![Edge Extension](assets/images/badge-ms.png)](https://microsoftedge.microsoft.com/addons/detail/privacy-redirect/elnabkhcgpajchapppkhiaifkgikgihj)
|
||||
|
||||
## About
|
||||
A web extension that redirects *Twitter, YouTube, Instagram & Google Maps* requests to privacy friendly alternatives - [Nitter](https://github.com/zedeus/nitter), [Invidious](https://github.com/iv-org/invidious), [FreeTube](https://github.com/FreeTubeApp/FreeTube), [Bibliogram](https://sr.ht/~cadence/bibliogram/) & [OpenStreetMap](https://www.openstreetmap.org/).
|
||||
A web extension that redirects *Twitter, YouTube, Instagram, Google Maps & Non-Private Searches* requests to privacy friendly alternatives - [Nitter](https://github.com/zedeus/nitter), [Invidious](https://github.com/iv-org/invidious), [FreeTube](https://github.com/FreeTubeApp/FreeTube), [Bibliogram](https://sr.ht/~cadence/bibliogram/), [OpenStreetMap](https://www.openstreetmap.org/) & Private Search Engines like [DuckDuckGo](https://duckduckgo.com) and [Startpage](https://startpage.com).
|
||||
|
||||
It's possible to toggle all redirects on and off. The extension will default to using random instances if none are selected. If these instances are not working, you can try and set a custom instance from the list below.
|
||||
It's possible to toggle all redirects on and off. The extension will default to using random instances if none are selected. If these instances are not working, you can try and set a custom instance from the list below. \*Instance for Search Engine redirect cannot be chosen at the moment.
|
||||
|
||||
### Custom instances
|
||||
Privacy Redirect allows setting custom instances, instances can be found here:
|
||||
|
@ -20,6 +20,11 @@ Privacy Redirect allows setting custom instances, instances can be found here:
|
|||
- [Invidious instances](https://github.com/iv-org/invidious/wiki/Invidious-Instances)
|
||||
- [Bibliogram instances](https://git.sr.ht/~cadence/bibliogram-docs/tree/master/docs/Instances.md)
|
||||
- [OpenStreetMap tile servers](https://wiki.openstreetmap.org/wiki/Tile_servers)
|
||||
- Private Search Engine list
|
||||
- [DuckDuckGo](https://duckduckgo.com)
|
||||
- [Startpage](https://startpage.com)
|
||||
- [Qwant](https://www.qwant.com)
|
||||
- [Mojeek](https://www.mojeek.com)
|
||||
|
||||
## Build
|
||||
|
||||
|
|
|
@ -132,12 +132,20 @@ const layers = {
|
|||
traffic: "S", // not implemented on OSM, default to standard.
|
||||
bicycling: "C",
|
||||
};
|
||||
const googleSearchRegex = /https?:\/\/(((www|maps)\.)?(google\.).*(\/search)|search\.(google\.).*)/;
|
||||
const privateSearchEngine = [
|
||||
{ link: "https://duckduckgo.com", q: "/" },
|
||||
{ link: "https://startpage.com", q: "/search/" },
|
||||
{ link: "https://www.qwant.com", q: "/" },
|
||||
{ link: "https://www.mojeek.com", q: "/search" },
|
||||
];
|
||||
|
||||
let disableNitter;
|
||||
let disableInvidious;
|
||||
let disableBibliogram;
|
||||
let disableOsm;
|
||||
let disableOldReddit;
|
||||
let disableSearchEngine;
|
||||
let nitterInstance;
|
||||
let invidiousInstance;
|
||||
let bibliogramInstance;
|
||||
|
@ -175,6 +183,7 @@ browser.storage.sync.get(
|
|||
"disableBibliogram",
|
||||
"disableOsm",
|
||||
"disableOldReddit",
|
||||
"disableSearchEngine",
|
||||
"alwaysProxy",
|
||||
"onlyEmbeddedVideo",
|
||||
"videoQuality",
|
||||
|
@ -195,6 +204,7 @@ browser.storage.sync.get(
|
|||
disableBibliogram = result.disableBibliogram;
|
||||
disableOsm = result.disableOsm;
|
||||
disableOldReddit = result.disableOldReddit;
|
||||
disableSearchEngine = result.disableSearchEngine;
|
||||
nitterInstance = result.nitterInstance;
|
||||
invidiousInstance = result.invidiousInstance;
|
||||
bibliogramInstance = result.bibliogramInstance;
|
||||
|
@ -257,6 +267,9 @@ browser.storage.onChanged.addListener((changes) => {
|
|||
if ("disableOldReddit" in changes) {
|
||||
disableOldReddit = changes.disableOldReddit.newValue;
|
||||
}
|
||||
if ("disableSearchEngine" in changes) {
|
||||
disableSearchEngine = changes.disableSearchEngine.newValue;
|
||||
}
|
||||
if ("alwaysProxy" in changes) {
|
||||
alwaysProxy = changes.alwaysProxy.newValue;
|
||||
}
|
||||
|
@ -572,6 +585,23 @@ function redirectReddit(url, initiator, type) {
|
|||
return `${oldRedditView}${url.pathname}${url.search}`;
|
||||
}
|
||||
|
||||
function redirectSearchEngine(url, initiator) {
|
||||
if (disableSearchEngine || isException(url, initiator)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
let searchEngine = getRandomInstance(privateSearchEngine);
|
||||
let search = "";
|
||||
url.search
|
||||
.slice(1)
|
||||
.split("&")
|
||||
.forEach(function (input) {
|
||||
if (input.startsWith("q=")) search = input;
|
||||
});
|
||||
console.log("search: ", search);
|
||||
return `${searchEngine.link}${searchEngine.q}?${search}`;
|
||||
}
|
||||
|
||||
browser.webRequest.onBeforeRequest.addListener(
|
||||
(details) => {
|
||||
const url = new URL(details.url);
|
||||
|
@ -605,6 +635,10 @@ browser.webRequest.onBeforeRequest.addListener(
|
|||
redirect = {
|
||||
redirectUrl: redirectReddit(url, initiator, details.type),
|
||||
};
|
||||
} else if (url.href.match(googleSearchRegex)) {
|
||||
redirect = {
|
||||
redirectUrl: redirectSearchEngine(url, initiator),
|
||||
};
|
||||
}
|
||||
if (redirect && redirect.redirectUrl) {
|
||||
console.info(
|
||||
|
|
|
@ -141,6 +141,28 @@
|
|||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</section>
|
||||
<section class="settings-block">
|
||||
<table class="option" aria-label="Toggle Search Engine redirects">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>
|
||||
<h1 data-localise="__MSG_disableSearchEngine__">
|
||||
Search Engine Redirects
|
||||
</h1>
|
||||
</td>
|
||||
<td>
|
||||
<input
|
||||
aria-hidden="true"
|
||||
id="disable-searchEngine"
|
||||
type="checkbox"
|
||||
checked
|
||||
/>
|
||||
<label for="disable-searchEngine" class="checkbox-label"> </label>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</section>
|
||||
<section class="settings-block">
|
||||
<h1 data-localise="__MSG_nitterInstance__">Nitter Instance</h1>
|
||||
|
|
|
@ -70,6 +70,7 @@ let disableInvidious = document.getElementById("disable-invidious");
|
|||
let disableBibliogram = document.getElementById("disable-bibliogram");
|
||||
let disableOsm = document.getElementById("disable-osm");
|
||||
let disableOldReddit = document.getElementById("disable-old-reddit");
|
||||
let disableSearchEngine = document.getElementById("disable-searchEngine");
|
||||
let alwaysProxy = document.getElementById("always-proxy");
|
||||
let onlyEmbeddedVideo = document.getElementById("only-embed");
|
||||
let videoQuality = document.getElementById("video-quality");
|
||||
|
@ -127,6 +128,7 @@ browser.storage.sync.get(
|
|||
"disableBibliogram",
|
||||
"disableOsm",
|
||||
"disableOldReddit",
|
||||
"disableSearchEngine",
|
||||
"alwaysProxy",
|
||||
"onlyEmbeddedVideo",
|
||||
"videoQuality",
|
||||
|
@ -157,6 +159,7 @@ browser.storage.sync.get(
|
|||
disableBibliogram.checked = !result.disableBibliogram;
|
||||
disableOsm.checked = !result.disableOsm;
|
||||
disableOldReddit.checked = !result.disableOldReddit;
|
||||
disableSearchEngine.checked = !result.disableSearchEngine;
|
||||
alwaysProxy.checked = result.alwaysProxy;
|
||||
onlyEmbeddedVideo.checked = result.onlyEmbeddedVideo;
|
||||
videoQuality.value = result.videoQuality || "";
|
||||
|
@ -335,6 +338,10 @@ disableOldReddit.addEventListener("change", (event) => {
|
|||
browser.storage.sync.set({ disableOldReddit: !event.target.checked });
|
||||
});
|
||||
|
||||
disableSearchEngine.addEventListener("change", (event) => {
|
||||
browser.storage.sync.set({ disableSearchEngine: !event.target.checked });
|
||||
});
|
||||
|
||||
alwaysProxy.addEventListener("change", (event) => {
|
||||
browser.storage.sync.set({ alwaysProxy: event.target.checked });
|
||||
});
|
||||
|
|
|
@ -138,6 +138,27 @@
|
|||
</tbody>
|
||||
</table>
|
||||
</section>
|
||||
|
||||
<section class="settings-block">
|
||||
<table class="option" aria-label="Toggle Search Engine redirects">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>
|
||||
<h1 data-localise="__MSG_disableSearchEngine__">Search Engine Redirects</h1>
|
||||
</td>
|
||||
<td>
|
||||
<input
|
||||
aria-hidden="true"
|
||||
id="disable-searchEngine"
|
||||
type="checkbox"
|
||||
checked
|
||||
/>
|
||||
<label for="disable-searchEngine" class="checkbox-label"></label>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</section>
|
||||
|
||||
<section class="settings-block"></section>
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@ let disableInvidious = document.querySelector("#disable-invidious");
|
|||
let disableBibliogram = document.querySelector("#disable-bibliogram");
|
||||
let disableOsm = document.querySelector("#disable-osm");
|
||||
let disableOldReddit = document.querySelector("#disable-old-reddit");
|
||||
let disableSearchEngine = document.querySelector("#disable-searchEngine");
|
||||
let version = document.querySelector("#version");
|
||||
|
||||
window.browser = window.browser || window.chrome;
|
||||
|
@ -16,6 +17,7 @@ browser.storage.sync.get(
|
|||
"disableBibliogram",
|
||||
"disableOsm",
|
||||
"disableOldReddit",
|
||||
"disableSearchEngine",
|
||||
"theme",
|
||||
],
|
||||
(result) => {
|
||||
|
@ -25,6 +27,7 @@ browser.storage.sync.get(
|
|||
disableBibliogram.checked = !result.disableBibliogram;
|
||||
disableOsm.checked = !result.disableOsm;
|
||||
disableOldReddit.checked = !result.disableOldReddit;
|
||||
disableSearchEngine.checked = !result.disableSearchEngine;
|
||||
}
|
||||
);
|
||||
|
||||
|
@ -50,6 +53,10 @@ disableOldReddit.addEventListener("change", (event) => {
|
|||
browser.storage.sync.set({ disableOldReddit: !event.target.checked });
|
||||
});
|
||||
|
||||
disableSearchEngine.addEventListener("change", (event) => {
|
||||
browser.storage.sync.set({ disableSearchEngine: !event.target.checked });
|
||||
});
|
||||
|
||||
document.querySelector("#more-options").addEventListener("click", () => {
|
||||
browser.runtime.openOptionsPage();
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue