Added Neuters #231
This commit is contained in:
parent
12d484ae6c
commit
cd285222c7
File diff suppressed because one or more lines are too long
After Width: | Height: | Size: 15 KiB |
|
@ -64,6 +64,7 @@ const allPopupFrontends = [
|
|||
"wikipedia",
|
||||
"medium",
|
||||
"quora",
|
||||
"reuters",
|
||||
"peertube",
|
||||
"lbry",
|
||||
"sendTargets"
|
||||
|
|
|
@ -65,8 +65,6 @@ function init() {
|
|||
init();
|
||||
browser.storage.onChanged.addListener(init)
|
||||
|
||||
// https://www.quora.com/@keysikaspol/video/7061265241887345946
|
||||
// https://www.quora.com/@keysikaspol
|
||||
function redirect(url, type, initiator) {
|
||||
if (disableQuora) return;
|
||||
if (type != "main_frame") return;
|
||||
|
|
|
@ -0,0 +1,106 @@
|
|||
window.browser = window.browser || window.chrome;
|
||||
|
||||
import utils from './utils.js'
|
||||
|
||||
const targets = [
|
||||
/^https?:\/{2}(www\.|)reuters\.com.*/
|
||||
];
|
||||
|
||||
let redirects = {
|
||||
"neuters": {
|
||||
"normal": [
|
||||
'https://neuters.de',
|
||||
],
|
||||
"tor": []
|
||||
}
|
||||
}
|
||||
|
||||
let
|
||||
disableReuters,
|
||||
reutersProtocol,
|
||||
reutersRedirects,
|
||||
neutersNormalRedirectsChecks,
|
||||
neutersNormalCustomRedirects,
|
||||
neutersTorRedirectsChecks,
|
||||
neutersTorCustomRedirects;
|
||||
|
||||
function init() {
|
||||
return new Promise(async resolve => {
|
||||
browser.storage.local.get(
|
||||
[
|
||||
"disableReuters",
|
||||
"reutersProtocol",
|
||||
"reutersRedirects",
|
||||
"neutersNormalRedirectsChecks",
|
||||
"neutersNormalCustomRedirects",
|
||||
"neutersTorRedirectsChecks",
|
||||
"neutersTorCustomRedirects",
|
||||
],
|
||||
r => {
|
||||
disableReuters = r.disableReuters;
|
||||
reutersProtocol = r.reutersProtocol;
|
||||
reutersRedirects = r.reutersRedirects;
|
||||
neutersNormalRedirectsChecks = r.neutersNormalRedirectsChecks;
|
||||
neutersNormalCustomRedirects = r.neutersNormalCustomRedirects;
|
||||
neutersTorRedirectsChecks = r.neutersTorRedirectsChecks;
|
||||
neutersTorCustomRedirects = r.neutersTorCustomRedirects;
|
||||
resolve();
|
||||
}
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
init();
|
||||
browser.storage.onChanged.addListener(init)
|
||||
|
||||
function redirect(url, type, initiator) {
|
||||
if (disableReuters) return;
|
||||
if (type != "main_frame") return;
|
||||
const all = [
|
||||
...reutersRedirects.neuters.normal,
|
||||
...neutersNormalCustomRedirects
|
||||
];
|
||||
if (initiator && (all.includes(initiator.origin) || targets.includes(initiator.host))) return;
|
||||
if (!targets.some(rx => rx.test(url.href))) return;
|
||||
|
||||
let instancesList;
|
||||
if (reutersProtocol == 'normal') instancesList = [...neutersNormalRedirectsChecks, ...neutersNormalCustomRedirects];
|
||||
if (reutersProtocol == 'tor') instancesList = [...neutersTorRedirectsChecks, ...neutersTorCustomRedirects];
|
||||
if (instancesList.length === 0) return;
|
||||
|
||||
const randomInstance = utils.getRandomInstance(instancesList);
|
||||
// stolen from https://addons.mozilla.org/en-US/firefox/addon/reuters-redirect/
|
||||
if (
|
||||
url.pathname.startsWith('/article/') ||
|
||||
url.pathname.startsWith('/pf/') ||
|
||||
url.pathname.startsWith('/arc/') ||
|
||||
url.pathname.startsWith('/resizer/')
|
||||
)
|
||||
return null;
|
||||
else if (url.pathname.endsWith('/'))
|
||||
return `${randomInstance}${url.pathname}`;
|
||||
else
|
||||
return `${randomInstance}${url.pathname}/`;
|
||||
}
|
||||
|
||||
function initDefaults() {
|
||||
return new Promise(resolve => {
|
||||
browser.storage.local.set({
|
||||
disableReuters: false,
|
||||
reutersProtocol: "normal",
|
||||
|
||||
reutersRedirects: redirects,
|
||||
|
||||
neutersNormalRedirectsChecks: [...redirects.neuters.normal],
|
||||
neutersNormalCustomRedirects: [],
|
||||
|
||||
neutersTorRedirectsChecks: [...redirects.neuters.tor],
|
||||
neutersTorCustomRedirects: [],
|
||||
}, () => resolve());
|
||||
});
|
||||
}
|
||||
|
||||
export default {
|
||||
redirect,
|
||||
initDefaults
|
||||
};
|
|
@ -13,12 +13,14 @@ import translateHelper from "../../assets/javascripts/translate/translate.js";
|
|||
import mapsHelper from "../../assets/javascripts/maps.js";
|
||||
import wikipediaHelper from "../../assets/javascripts/wikipedia.js";
|
||||
import mediumHelper from "../../assets/javascripts/medium.js";
|
||||
import quoraHelper from "../../assets/javascripts/quora.js";
|
||||
import reutersHelper from "../../assets/javascripts/reuters.js";
|
||||
import imgurHelper from "../../assets/javascripts/imgur.js";
|
||||
import tiktokHelper from "../../assets/javascripts/tiktok.js";
|
||||
import sendTargetsHelper from "../../assets/javascripts/sendTargets.js";
|
||||
import peertubeHelper from "../../assets/javascripts/peertube.js";
|
||||
import lbryHelper from "../../assets/javascripts/lbry.js";
|
||||
import quoraHelper from "../../assets/javascripts/quora.js";
|
||||
|
||||
|
||||
window.browser = window.browser || window.chrome;
|
||||
|
||||
|
@ -43,6 +45,7 @@ browser.runtime.onInstalled.addListener(
|
|||
translateHelper.initDefaults();
|
||||
mediumHelper.initDefaults();
|
||||
quoraHelper.initDefaults();
|
||||
reutersHelper.initDefaults();
|
||||
redditHelper.initDefaults();
|
||||
wikipediaHelper.initDefaults();
|
||||
imgurHelper.initDefaults();
|
||||
|
@ -101,6 +104,7 @@ browser.webRequest.onBeforeRequest.addListener(
|
|||
if (!newUrl) newUrl = redditHelper.redirect(url, details.type, initiator);
|
||||
if (!newUrl) newUrl = mediumHelper.redirect(url, details.type, initiator);
|
||||
if (!newUrl) newUrl = quoraHelper.redirect(url, details.type, initiator);
|
||||
if (!newUrl) newUrl = reutersHelper.redirect(url, details.type, initiator);
|
||||
if (!newUrl) newUrl = imgurHelper.redirect(url, details.type, initiator);
|
||||
if (!newUrl) newUrl = tiktokHelper.redirect(url, details.type, initiator);
|
||||
if (!newUrl) newUrl = sendTargetsHelper.redirect(url, details.type, initiator);
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
</svg><a href="#medium" data-localise="__MSG_medium__">Medium</a>
|
||||
</div>
|
||||
<div class="title"><img src="../../../assets/images/quora.png"><a href="#quora" data-localise="__MSG_quora__">Quora</a></div>
|
||||
<div class="title"><img src="../../../assets/images/reuters.svg"><a href="#reuters" data-localise="__MSG_reuters__">Reuters</a></div>
|
||||
<div class="title"> <img src="../../../assets/images/peertube-icon.svg"><a href="#peertube" data-localise="__MSG_peertube__">PeerTube</a></div>
|
||||
<div class="title"> <img src="../../../assets/images/lbry-icon.png"><a href="#lbry" data-localise="__MSG_lbry__">LBRY/Odysee</a></div>
|
||||
<div class="title">
|
||||
|
@ -216,6 +217,12 @@
|
|||
</div>
|
||||
<input id="quora" type="checkbox">
|
||||
</div>
|
||||
<div>
|
||||
<div> <img src="../../../assets/images/reuters.svg">
|
||||
<x data-localise="__MSG_reuters__">Reuters</x>
|
||||
</div>
|
||||
<input id="reuters" type="checkbox">
|
||||
</div>
|
||||
<div>
|
||||
<div> <img src="../../../assets/images/peertube-icon.svg">
|
||||
<x data-localise="__MSG_peertube__">PeerTube</x>
|
||||
|
@ -1176,6 +1183,78 @@
|
|||
</div>
|
||||
<script type="module" src="./widgets/quora.js"></script>
|
||||
</section>
|
||||
<section class="option-block" id="reuters_page">
|
||||
<div class="some-block option-block">
|
||||
<h1 data-localise="__MSG_reuters__">Reuters</h1>
|
||||
</div>
|
||||
<hr>
|
||||
<div class="some-block option-block">
|
||||
<h4 data-localise="__MSG_enable__">Enable</h4>
|
||||
<input id="reuters-enable" type="checkbox">
|
||||
</div>
|
||||
<div class="some-block option-block">
|
||||
<h4 data-localise="__MSG_protocol__">Protocol</h4>
|
||||
<select id="reuters-protocol">
|
||||
<option value="normal" data-localise="__MSG_normal__">Normal</option>
|
||||
<option value="tor" data-localise="__MSG_tor__">Tor</option>
|
||||
</select>
|
||||
</div>
|
||||
<div id="neuters">
|
||||
<hr>
|
||||
<div class="normal">
|
||||
<div class="some-block option-block">
|
||||
<h4 data-localise="__MSG_defaultInstances__">Default Instances</h4>
|
||||
</div>
|
||||
<div class="checklist"></div>
|
||||
<hr>
|
||||
<div class="some-block option-block">
|
||||
<h4 data-localise="__MSG_customInstances__">Custom Instances</h4>
|
||||
</div>
|
||||
<form class="custom-instance-form">
|
||||
<div class="some-block option-block">
|
||||
<input class="custom-instance" placeholder="https://neuters.com" type="url">
|
||||
<button class="add add-instance" type="submit">
|
||||
<svg xmlns="https://www.w3.org/2000/svg" height="20px" viewBox="0 0 24 24" width="20px" fill="currentColor">
|
||||
<path d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"></path>
|
||||
</svg>
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
<div class="checklist custom-checklist"></div>
|
||||
<div class="buttons buttons-inline">
|
||||
<label class="button button-inline" id="latency-neuters-label" for="latency-neuters">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="currentColor">
|
||||
<path d="M19 19H5V5h7V3H5c-1.11 0-2 .9-2 2v14c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2v-7h-2v7zM14 3v2h3.59l-9.83 9.83 1.41 1.41L19 6.41V10h2V3h-7z"></path>
|
||||
</svg>
|
||||
<x data-localise="__MSG_testInstancesLatency__">Test Instances Latency</x>
|
||||
</label>
|
||||
<input class="button button-inline" id="latency-neuters" style="display:none;">
|
||||
</div>
|
||||
</div>
|
||||
<div class="tor">
|
||||
<div class="some-block option-block">
|
||||
<h4 data-localise="__MSG_defaultInstances__">Default Instances</h4>
|
||||
</div>
|
||||
<div class="checklist"></div>
|
||||
<hr>
|
||||
<div class="some-block option-block">
|
||||
<h4 data-localise="__MSG_customInstances__">Custom Instances</h4>
|
||||
</div>
|
||||
<form class="custom-instance-form">
|
||||
<div class="some-block option-block">
|
||||
<input class="custom-instance" placeholder="https://neuters.onion" type="url">
|
||||
<button class="add add-instance" type="submit">
|
||||
<svg xmlns="https://www.w3.org/2000/svg" height="20px" viewBox="0 0 24 24" width="20px" fill="currentColor">
|
||||
<path d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"></path>
|
||||
</svg>
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
<div class="checklist custom-checklist"></div>
|
||||
</div>
|
||||
</div>
|
||||
<script type="module" src="./widgets/reuters.js"></script>
|
||||
</section>
|
||||
<section class="option-block" id="peertube_page">
|
||||
<div class="some-block option-block">
|
||||
<h1 data-localise="__MSG_peertube__">PeerTube</h1>
|
||||
|
|
|
@ -23,6 +23,7 @@ html#elementToShowWithJavaScript(lang="en")
|
|||
include ./widgets/wikipedia.pug
|
||||
include ./widgets/medium.pug
|
||||
include ./widgets/quora.pug
|
||||
include ./widgets/reuters.pug
|
||||
include ./widgets/peertube.pug
|
||||
include ./widgets/lbry.pug
|
||||
include ./widgets/search.pug
|
||||
|
|
|
@ -132,6 +132,7 @@ resetSettings.addEventListener("click",
|
|||
await translateHelper.initDefaults();
|
||||
await mediumHelper.initDefaults();
|
||||
await quoraHelper.initDefaults();
|
||||
await reutersHelper.initDefaults();
|
||||
await redditHelper.initDefaults();
|
||||
await wikipediaHelper.initDefaults();
|
||||
await imgurHelper.initDefaults();
|
||||
|
|
|
@ -156,6 +156,12 @@ section#general_page.option-block
|
|||
x(data-localise="__MSG_quora__") Quora
|
||||
input#quora(type="checkbox")
|
||||
|
||||
div
|
||||
div
|
||||
img(src="../../../assets/images/reuters.svg")
|
||||
x(data-localise="__MSG_reuters__") Reuters
|
||||
input#reuters(type="checkbox")
|
||||
|
||||
div
|
||||
div
|
||||
img(src="../../../assets/images/peertube-icon.svg")
|
||||
|
|
|
@ -5,8 +5,8 @@ const protocol = document.getElementById("medium-protocol")
|
|||
const medium = document.getElementById('medium_page');
|
||||
|
||||
function changeProtocolSettings() {
|
||||
const normalDiv = document.getElementsByClassName("normal")[0];
|
||||
const torDiv = document.getElementsByClassName("tor")[0];
|
||||
const normalDiv = medium.getElementsByClassName("normal")[0];
|
||||
const torDiv = medium.getElementsByClassName("tor")[0];
|
||||
if (protocol.value == 'normal') {
|
||||
normalDiv.style.display = 'block';
|
||||
torDiv.style.display = 'none';
|
||||
|
|
|
@ -5,8 +5,8 @@ const protocol = document.getElementById("quora-protocol")
|
|||
const quora = document.getElementById('quora_page');
|
||||
|
||||
function changeProtocolSettings() {
|
||||
const normalDiv = document.getElementsByClassName("normal")[0];
|
||||
const torDiv = document.getElementsByClassName("tor")[0];
|
||||
const normalDiv = quora.getElementsByClassName("normal")[0];
|
||||
const torDiv = quora.getElementsByClassName("tor")[0];
|
||||
if (protocol.value == 'normal') {
|
||||
normalDiv.style.display = 'block';
|
||||
torDiv.style.display = 'none';
|
||||
|
|
|
@ -0,0 +1,43 @@
|
|||
import utils from "../../../assets/javascripts/utils.js";
|
||||
|
||||
const enable = document.getElementById("reuters-enable");
|
||||
const protocol = document.getElementById("reuters-protocol")
|
||||
const reuters = document.getElementById('reuters_page');
|
||||
|
||||
function changeProtocolSettings() {
|
||||
const normalDiv = reuters.getElementsByClassName("normal")[0];
|
||||
const torDiv = reuters.getElementsByClassName("tor")[0];
|
||||
if (protocol.value == 'normal') {
|
||||
|
||||
normalDiv.style.display = 'block';
|
||||
torDiv.style.display = 'none';
|
||||
}
|
||||
else if (protocol.value == 'tor') {
|
||||
normalDiv.style.display = 'none';
|
||||
torDiv.style.display = 'block';
|
||||
}
|
||||
}
|
||||
|
||||
reuters.addEventListener("change", () => {
|
||||
changeProtocolSettings();
|
||||
browser.storage.local.set({
|
||||
disableReuters: !enable.checked,
|
||||
reutersProtocol: protocol.value,
|
||||
})
|
||||
})
|
||||
|
||||
browser.storage.local.get(
|
||||
[
|
||||
"disableReuters",
|
||||
"reutersProtocol"
|
||||
],
|
||||
r => {
|
||||
enable.checked = !r.disableReuters;
|
||||
protocol.value = r.reutersProtocol;
|
||||
changeProtocolSettings();
|
||||
}
|
||||
)
|
||||
|
||||
utils.processDefaultCustomInstances('reuters', 'neuters', 'normal', document);
|
||||
utils.processDefaultCustomInstances('reuters', 'neuters', 'tor', document);
|
||||
utils.latency('reuters', 'neuters', document, location)
|
|
@ -0,0 +1,26 @@
|
|||
section#reuters_page.option-block
|
||||
.some-block.option-block
|
||||
h1(data-localise="__MSG_reuters__") Reuters
|
||||
hr
|
||||
.some-block.option-block
|
||||
h4(data-localise="__MSG_enable__") Enable
|
||||
input#reuters-enable(type="checkbox")
|
||||
|
||||
.some-block.option-block
|
||||
h4(data-localise="__MSG_protocol__") Protocol
|
||||
select#reuters-protocol
|
||||
option(value="normal" data-localise="__MSG_normal__") Normal
|
||||
option(value="tor" data-localise="__MSG_tor__") Tor
|
||||
|
||||
#neuters
|
||||
hr
|
||||
.normal
|
||||
include ../../widgets/instances.pug
|
||||
+instances('https://neuters.com')
|
||||
include ../../widgets/latency.pug
|
||||
+latency('neuters')
|
||||
.tor
|
||||
include ../../widgets/instances.pug
|
||||
+instances('https://neuters.onion')
|
||||
|
||||
script(type="module" src="./widgets/reuters.js")
|
|
@ -52,6 +52,10 @@
|
|||
<h4 data-localise="__MSG_quora__">Quora</h4></a>
|
||||
<input id="disable-quora" type="checkbox">
|
||||
</div>
|
||||
<div class="some-block" id="reuters"><a class="title" href="https://reuters.com"><img src="../../assets/images/reuters.svg">
|
||||
<h4 data-localise="__MSG_reuters__">Reuters</h4></a>
|
||||
<input id="disable-reuters" type="checkbox">
|
||||
</div>
|
||||
<div class="some-block" id="peertube"><a class="title" href="https://search.joinpeertube.org"><img src="../../assets/images/peertube-icon.svg">
|
||||
<h4 data-localise="__MSG_peertube__">PeerTube</h4></a>
|
||||
<input id="disable-peertube" type="checkbox">
|
||||
|
|
|
@ -45,6 +45,7 @@ let disableElement = document.getElementById("disable-simplyTranslate");
|
|||
let disableWikipediaElement = document.getElementById("disable-wikipedia");
|
||||
let disableMediumElement = document.getElementById("disable-medium");
|
||||
let disableQuoraElement = document.getElementById("disable-quora");
|
||||
let disableReutersElement = document.getElementById("disable-reuters");
|
||||
let disablePeertubeElement = document.getElementById("disable-peertube");
|
||||
let disableLbryElement = document.getElementById("disable-lbry");
|
||||
let disableSendTargetsElement = document.getElementById("disable-sendTargets");
|
||||
|
@ -66,6 +67,7 @@ browser.storage.local.get(
|
|||
"disableTiktok",
|
||||
"disableMedium",
|
||||
"disableQuora",
|
||||
"disableReuters",
|
||||
"disablePeertubeTargets",
|
||||
"disableLbryTargets",
|
||||
"disableSendTarget",
|
||||
|
@ -86,6 +88,7 @@ browser.storage.local.get(
|
|||
disableTiktokElement.checked = !r.disableTiktok;
|
||||
disableMediumElement.checked = !r.disableMedium;
|
||||
disableQuoraElement.checked = !r.disableQuora;
|
||||
disableReutersElement.checked = !r.disableReuters;
|
||||
disablePeertubeElement.checked = !r.disablePeertubeTargets;
|
||||
disableLbryElement.checked = !r.disableLbryTargets;
|
||||
disableSendTargetsElement.checked = !r.disableSendTarget;
|
||||
|
@ -113,6 +116,7 @@ document.addEventListener("change", () => {
|
|||
disableTiktok: !disableTiktokElement.checked,
|
||||
disableMedium: !disableMediumElement.checked,
|
||||
disableQuora: !disableQuoraElement.checked,
|
||||
disableReuters: !disableReutersElement.checked,
|
||||
disablePeertubeTargets: !disablePeertubeElement.checked,
|
||||
disableLbryTargets: !disableLbryElement.checked,
|
||||
disableSendTarget: !disableSendTargetsElement.checked,
|
||||
|
|
|
@ -68,6 +68,12 @@ html(lang="en")
|
|||
h4(data-localise="__MSG_quora__") Quora
|
||||
input#disable-quora(type="checkbox")
|
||||
|
||||
#reuters.some-block
|
||||
a.title(href="https://reuters.com")
|
||||
img(src="../../assets/images/reuters.svg")
|
||||
h4(data-localise="__MSG_reuters__") Reuters
|
||||
input#disable-reuters(type="checkbox")
|
||||
|
||||
#peertube.some-block
|
||||
a.title(href="https://search.joinpeertube.org")
|
||||
img(src="../../assets/images/peertube-icon.svg")
|
||||
|
|
|
@ -46,6 +46,10 @@ mixin links(service)
|
|||
img(src="../../../assets/images/quora.png")
|
||||
a(href="#quora" data-localise="__MSG_quora__") Quora
|
||||
|
||||
.title
|
||||
img(src="../../../assets/images/reuters.svg")
|
||||
a(href="#reuters" data-localise="__MSG_reuters__") Reuters
|
||||
|
||||
.title
|
||||
img(src="../../../assets/images/peertube-icon.svg")
|
||||
a(href="#peertube" data-localise="__MSG_peertube__") PeerTube
|
||||
|
|
Loading…
Reference in New Issue