Activating reddit frontend btn. Excluding medium.com #19
This commit is contained in:
parent
d1ec4ac2af
commit
376f9b83ae
@ -6,25 +6,43 @@ const targets = [
|
|||||||
"i.redd.it",
|
"i.redd.it",
|
||||||
"redd.it",
|
"redd.it",
|
||||||
];
|
];
|
||||||
const redirects = [
|
const redirects = {
|
||||||
// libreddit: privacy w/ modern UI
|
// modern UI
|
||||||
"https://libredd.it",
|
"libreddit": [
|
||||||
"https://libreddit.spike.codes",
|
"https://libredd.it",
|
||||||
"https://libreddit.kavin.rocks",
|
"https://libreddit.spike.codes",
|
||||||
"https://libreddit.insanity.wtf",
|
"https://libreddit.kavin.rocks",
|
||||||
"https://libreddit.dothq.co",
|
"https://libreddit.insanity.wtf",
|
||||||
"https://libreddit.silkky.cloud",
|
"https://libreddit.dothq.co",
|
||||||
"https://libreddit.himiko.cloud",
|
"https://libreddit.silkky.cloud",
|
||||||
"https://reddit.artemislena.eu",
|
"https://libreddit.himiko.cloud",
|
||||||
"https://reddit.git-bruh.duckdns.org",
|
"https://reddit.artemislena.eu",
|
||||||
// teddit: privacy w/ old UI
|
"https://reddit.git-bruh.duckdns.org",
|
||||||
"https://teddit.net",
|
],
|
||||||
"https://teddit.ggc-project.de",
|
// old UI
|
||||||
"https://teddit.kavin.rocks",
|
"teddit": [
|
||||||
"https://old.reddit.com", // desktop
|
"https://teddit.net",
|
||||||
"https://i.reddit.com", // mobile
|
"https://teddit.ggc-project.de",
|
||||||
"https://snew.notabug.io", // anti-censorship
|
"https://teddit.kavin.rocks",
|
||||||
];
|
"https://teddit.zaggy.nl",
|
||||||
|
"https://teddit.namazso.eu",
|
||||||
|
"https://teddit.nautolan.racing",
|
||||||
|
"https://teddit.tinfoil-hat.net",
|
||||||
|
"https://teddit.domain.glass",
|
||||||
|
"https://snoo.ioens.is",
|
||||||
|
"https://teddit.httpjames.space",
|
||||||
|
"https://teddit.alefvanoon.xyz",
|
||||||
|
"https://incogsnoo.com",
|
||||||
|
"https://teddit.pussthecat.org",
|
||||||
|
"https://reddit.lol",
|
||||||
|
"https://teddit.sethforprivacy.com",
|
||||||
|
"https://teddit.totaldarkness.net",
|
||||||
|
"https://teddit.adminforge.de",
|
||||||
|
"https://teddit.bus-hit.me"
|
||||||
|
],
|
||||||
|
"desktop": "https://old.reddit.com", // desktop
|
||||||
|
"mobile": "https://i.reddit.com", // mobile
|
||||||
|
};
|
||||||
const bypassPaths = /\/(gallery\/poll\/rpan\/settings\/topics)/;
|
const bypassPaths = /\/(gallery\/poll\/rpan\/settings\/topics)/;
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
@ -29,10 +29,12 @@ const dataLatLngRegex = mapsHelper.dataLatLngRegex;
|
|||||||
const placeRegex = mapsHelper.placeRegex;
|
const placeRegex = mapsHelper.placeRegex;
|
||||||
const travelModes = mapsHelper.travelModes;
|
const travelModes = mapsHelper.travelModes;
|
||||||
const layers = mapsHelper.layers;
|
const layers = mapsHelper.layers;
|
||||||
|
|
||||||
const redditInstances = redditHelper.redirects;
|
const redditInstances = redditHelper.redirects;
|
||||||
const redditDomains = redditHelper.targets;
|
const redditDomains = redditHelper.targets;
|
||||||
const redditBypassPaths = redditHelper.bypassPaths;
|
const redditBypassPaths = redditHelper.bypassPaths;
|
||||||
const redditDefault = redditHelper.redirects[0];
|
const redditDefault = redditHelper.redirects[0];
|
||||||
|
|
||||||
const googleSearchRegex = searchHelper.targets;
|
const googleSearchRegex = searchHelper.targets;
|
||||||
const searchEngineInstances = searchHelper.redirects;
|
const searchEngineInstances = searchHelper.redirects;
|
||||||
const simplyTranslateInstances = googleTranslateHelper.redirects;
|
const simplyTranslateInstances = googleTranslateHelper.redirects;
|
||||||
@ -69,11 +71,15 @@ let invidiousPlayerStyle;
|
|||||||
let invidiousSubtitles;
|
let invidiousSubtitles;
|
||||||
let invidiousAutoplay;
|
let invidiousAutoplay;
|
||||||
let useFreeTube;
|
let useFreeTube;
|
||||||
|
|
||||||
let nitterRandomPool;
|
let nitterRandomPool;
|
||||||
let invidiousRandomPool;
|
let invidiousRandomPool;
|
||||||
let bibliogramRandomPool;
|
let bibliogramRandomPool;
|
||||||
let scribeRandomPool;
|
let scribeRandomPool;
|
||||||
|
|
||||||
|
|
||||||
let exceptions;
|
let exceptions;
|
||||||
|
let redditFrontend;
|
||||||
|
|
||||||
window.browser = window.browser || window.chrome;
|
window.browser = window.browser || window.chrome;
|
||||||
|
|
||||||
@ -112,53 +118,70 @@ browser.storage.sync.get(
|
|||||||
"scribeRandomPool",
|
"scribeRandomPool",
|
||||||
"wikilessRandomPool",
|
"wikilessRandomPool",
|
||||||
"exceptions",
|
"exceptions",
|
||||||
|
"redditFrontend",
|
||||||
],
|
],
|
||||||
(result) => {
|
(result) => {
|
||||||
nitterInstance = result.nitterInstance;
|
|
||||||
invidiousInstance = result.invidiousInstance;
|
|
||||||
bibliogramInstance = result.bibliogramInstance;
|
|
||||||
osmInstance = result.osmInstance || osmDefault;
|
osmInstance = result.osmInstance || osmDefault;
|
||||||
redditInstance = result.redditInstance || redditDefault;
|
|
||||||
scribeInstance = result.scribeInstance;
|
|
||||||
searchEngineInstance = result.searchEngineInstance;
|
|
||||||
simplyTranslateInstance =
|
|
||||||
result.simplyTranslateInstance || simplyTranslateDefault;
|
|
||||||
wikipediaInstance = result.wikipediaInstance || wikipediaDefault;
|
|
||||||
disableNitter = result.disableNitter;
|
|
||||||
disableScribe = result.disableScribe;
|
|
||||||
disableInvidious = result.disableInvidious;
|
|
||||||
disableBibliogram = result.disableBibliogram;
|
|
||||||
disableOsm = result.disableOsm;
|
disableOsm = result.disableOsm;
|
||||||
disableReddit = result.disableReddit;
|
|
||||||
|
searchEngineInstance = result.searchEngineInstance;
|
||||||
disableSearchEngine = result.disableSearchEngine;
|
disableSearchEngine = result.disableSearchEngine;
|
||||||
disableWikipedia = result.disableWikipedia;
|
|
||||||
|
simplyTranslateInstance = result.simplyTranslateInstance || simplyTranslateDefault;
|
||||||
disableSimplyTranslate = result.disableSimplyTranslate;
|
disableSimplyTranslate = result.disableSimplyTranslate;
|
||||||
alwaysProxy = result.alwaysProxy;
|
|
||||||
onlyEmbeddedVideo = result.onlyEmbeddedVideo;
|
redditInstance = result.redditInstance;
|
||||||
videoQuality = result.videoQuality;
|
disableReddit = result.disableReddit;
|
||||||
invidiousDarkMode = result.invidiousDarkMode;
|
redditFrontend = result.redditFrontend;
|
||||||
|
|
||||||
|
disableWikipedia = result.disableWikipedia;
|
||||||
|
wikipediaInstance = result.wikipediaInstance || wikipediaDefault;
|
||||||
|
|
||||||
exceptions = result.exceptions
|
exceptions = result.exceptions
|
||||||
? result.exceptions.map((e) => {
|
? result.exceptions.map((e) => {
|
||||||
return new RegExp(e);
|
return new RegExp(e);
|
||||||
})
|
})
|
||||||
: [];
|
: [];
|
||||||
|
|
||||||
|
|
||||||
|
onlyEmbeddedVideo = result.onlyEmbeddedVideo;
|
||||||
|
invidiousDarkMode = result.invidiousDarkMode;
|
||||||
|
disableInvidious = result.disableInvidious;
|
||||||
|
alwaysProxy = result.alwaysProxy;
|
||||||
|
invidiousInstance = result.invidiousInstance;
|
||||||
|
videoQuality = result.videoQuality;
|
||||||
invidiousVolume = result.invidiousVolume;
|
invidiousVolume = result.invidiousVolume;
|
||||||
invidiousPlayerStyle = result.invidiousPlayerStyle;
|
invidiousPlayerStyle = result.invidiousPlayerStyle;
|
||||||
invidiousSubtitles = result.invidiousSubtitles || "";
|
invidiousSubtitles = result.invidiousSubtitles || "";
|
||||||
invidiousAutoplay = result.invidiousAutoplay;
|
invidiousAutoplay = result.invidiousAutoplay;
|
||||||
useFreeTube = result.useFreeTube;
|
useFreeTube = result.useFreeTube;
|
||||||
nitterRandomPool = result.nitterRandomPool
|
invidiousRandomPool =
|
||||||
? result.nitterRandomPool.split(",")
|
result.invidiousRandomPool
|
||||||
: commonHelper.filterInstances(nitterInstances);
|
? result.invidiousRandomPool.split(",")
|
||||||
invidiousRandomPool = result.invidiousRandomPool
|
: commonHelper.filterInstances(invidiousInstances);
|
||||||
? result.invidiousRandomPool.split(",")
|
|
||||||
: commonHelper.filterInstances(invidiousInstances);
|
nitterInstance = result.nitterInstance;
|
||||||
bibliogramRandomPool = result.bibliogramRandomPool
|
disableNitter = result.disableNitter;
|
||||||
? result.bibliogramRandomPool.split(",")
|
nitterRandomPool =
|
||||||
: commonHelper.filterInstances(bibliogramInstances);
|
result.nitterRandomPool
|
||||||
scribeRandomPool = result.scribeRandomPool
|
? result.nitterRandomPool.split(",")
|
||||||
? result.scribeRandomPool.split(",")
|
: commonHelper.filterInstances(nitterInstances);
|
||||||
: commonHelper.filterInstances(scribeInstances);
|
|
||||||
|
|
||||||
|
bibliogramInstance = result.bibliogramInstance;
|
||||||
|
disableBibliogram = result.disableBibliogram;
|
||||||
|
bibliogramRandomPool =
|
||||||
|
result.bibliogramRandomPool
|
||||||
|
? result.bibliogramRandomPool.split(",")
|
||||||
|
: commonHelper.filterInstances(bibliogramInstances);
|
||||||
|
|
||||||
|
|
||||||
|
scribeInstance = result.scribeInstance;
|
||||||
|
disableScribe = result.disableScribe;
|
||||||
|
scribeRandomPool =
|
||||||
|
result.scribeRandomPool
|
||||||
|
? result.scribeRandomPool.split(",")
|
||||||
|
: commonHelper.filterInstances(scribeInstances);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -185,6 +208,9 @@ browser.storage.onChanged.addListener((changes) => {
|
|||||||
if ("redditInstance" in changes) {
|
if ("redditInstance" in changes) {
|
||||||
redditInstance = changes.redditInstance.newValue || redditDefault;
|
redditInstance = changes.redditInstance.newValue || redditDefault;
|
||||||
}
|
}
|
||||||
|
if ("redditFrontend" in changes)
|
||||||
|
redditFrontend = changes.redditFrontend.newValue
|
||||||
|
|
||||||
if ("scribeInstance" in changes) {
|
if ("scribeInstance" in changes) {
|
||||||
scribeInstance = changes.scribeInstance.newValue || scribeDefault;
|
scribeInstance = changes.scribeInstance.newValue || scribeDefault;
|
||||||
}
|
}
|
||||||
@ -348,14 +374,11 @@ function redirectTwitter(url, initiator) {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if (url.host.split(".")[0] === "pbs" || url.host.split(".")[0] === "video") {
|
if (url.host.split(".")[0] === "pbs" || url.host.split(".")[0] === "video") {
|
||||||
return `${nitterInstance || commonHelper.getRandomInstance(nitterRandomPool)
|
return `${nitterInstance || commonHelper.getRandomInstance(nitterRandomPool)}/pic/${encodeURIComponent(url.href)}`;
|
||||||
}/pic/${encodeURIComponent(url.href)}`;
|
|
||||||
} else if (url.pathname.split("/").includes("tweets")) {
|
} else if (url.pathname.split("/").includes("tweets")) {
|
||||||
return `${nitterInstance || commonHelper.getRandomInstance(nitterRandomPool)
|
return `${nitterInstance || commonHelper.getRandomInstance(nitterRandomPool)}${url.pathname.replace("/tweets", "")}${url.search}`;
|
||||||
}${url.pathname.replace("/tweets", "")}${url.search}`;
|
|
||||||
} else {
|
} else {
|
||||||
return `${nitterInstance || commonHelper.getRandomInstance(nitterRandomPool)
|
return `${nitterInstance || commonHelper.getRandomInstance(nitterRandomPool)}${url.pathname}${url.search}`;
|
||||||
}${url.pathname}${url.search}`;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -486,38 +509,38 @@ function redirectGoogleMaps(url, initiator) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function redirectReddit(url, initiator, type) {
|
function redirectReddit(url, initiator, type) {
|
||||||
if (disableReddit || isException(url, initiator)) {
|
console.info("reddit is redirecting");
|
||||||
|
console.log(redditFrontend)
|
||||||
|
|
||||||
|
if (disableReddit || isException(url, initiator))
|
||||||
return null;
|
return null;
|
||||||
}
|
|
||||||
// Do not redirect when already on the selected view
|
// Do not redirect when already on the selected view
|
||||||
if (
|
if ((initiator && initiator.origin === redditInstance) || url.origin === redditInstance)
|
||||||
(initiator && initiator.origin === redditInstance) ||
|
|
||||||
url.origin === redditInstance
|
|
||||||
) {
|
|
||||||
return null;
|
return null;
|
||||||
}
|
|
||||||
// Do not redirect exclusions nor anything other than main_frame
|
// Do not redirect exclusions nor anything other than main_frame
|
||||||
if (type !== "main_frame" || url.pathname.match(redditBypassPaths)) {
|
if (type !== "main_frame" || url.pathname.match(redditBypassPaths))
|
||||||
return null;
|
return null;
|
||||||
}
|
|
||||||
|
console.info(url.host);
|
||||||
if (url.host === "i.redd.it") {
|
if (url.host === "i.redd.it") {
|
||||||
if (redditInstance.includes("libredd")) {
|
if (redditFrontend == 'libreddit')
|
||||||
return `${redditInstance}/img${url.pathname}${url.search}`;
|
return `${redditInstance || commonHelper.getRandomInstance(redditInstances['libreddit'])}/img${url.pathname}${url.search}`;
|
||||||
} else if (redditInstance.includes("teddit")) {
|
if (redditFrontend == 'teddit')
|
||||||
// As of 2021-04-09, redirects for teddit images are nontrivial:
|
// As of 2021-04-09, redirects for teddit images are nontrivial:
|
||||||
// - navigating to the image before ever navigating to its page causes
|
// - navigating to the image before ever navigating to its page causes
|
||||||
// 404 error (probably needs fix on teddit project)
|
// 404 error (probably needs fix on teddit project)
|
||||||
// - some image links on teddit are very different
|
// - some image links on teddit are very different
|
||||||
// Therefore, don't support redirecting image links for teddit.
|
// Therefore, don't support redirecting image links for teddit.
|
||||||
return null;
|
return null;
|
||||||
} else {
|
|
||||||
return null;
|
return null;
|
||||||
}
|
|
||||||
} else if (url.host === "redd.it") {
|
} else if (url.host === "redd.it") {
|
||||||
if (
|
if (redditFrontend == 'libreddit')
|
||||||
redditInstance.includes("teddit") &&
|
return `${redditInstance || commonHelper.getRandomInstance(redditInstances['libreddit'])}${url.pathname}${url.search}`;
|
||||||
!url.pathname.match(/^\/+[^\/]+\/+[^\/]/)
|
if (redditFrontend == 'teddit' && !url.pathname.match(/^\/+[^\/]+\/+[^\/]/))
|
||||||
) {
|
|
||||||
// As of 2021-04-22, redirects for teddit redd.it/foo links don't work.
|
// As of 2021-04-22, redirects for teddit redd.it/foo links don't work.
|
||||||
// It appears that adding "/comments" as a prefix works, so manually add
|
// It appears that adding "/comments" as a prefix works, so manually add
|
||||||
// that prefix if it is missing. Even though redd.it/comments/foo links
|
// that prefix if it is missing. Even though redd.it/comments/foo links
|
||||||
@ -526,16 +549,23 @@ function redirectReddit(url, initiator, type) {
|
|||||||
//
|
//
|
||||||
// Note the difference between redd.it/comments/foo (doesn't work) and
|
// Note the difference between redd.it/comments/foo (doesn't work) and
|
||||||
// teddit.net/comments/foo (works).
|
// teddit.net/comments/foo (works).
|
||||||
return `${redditInstance}/comments${url.pathname}${url.search}`;
|
return `${redditInstance || commonHelper.getRandomInstance(redditInstances['teddit'])}/comments${url.pathname}${url.search}`;
|
||||||
}
|
return null;
|
||||||
}
|
}
|
||||||
return `${redditInstance}${url.pathname}${url.search}`;
|
if (redditFrontend == 'libreddit')
|
||||||
|
return `${redditInstance || commonHelper.getRandomInstance(redditInstances['libreddit'])}${url.pathname}${url.search}`;
|
||||||
|
if (redditFrontend == 'teddit')
|
||||||
|
return `${redditInstance || commonHelper.getRandomInstance(redditInstances['teddit'])}${url.pathname}${url.search}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
function redirectMedium(url, initiator) {
|
function redirectMedium(url, initiator) {
|
||||||
if (disableScribe || isException(url, initiator)) {
|
if (disableScribe || isException(url, initiator)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (url.pathname == "/")
|
||||||
|
return null;
|
||||||
|
|
||||||
if (
|
if (
|
||||||
isFirefox() &&
|
isFirefox() &&
|
||||||
initiator &&
|
initiator &&
|
||||||
@ -578,8 +608,6 @@ function redirectGoogleTranslate(url, initiator) {
|
|||||||
return `${simplyTranslateInstance}/${url.search}`;
|
return `${simplyTranslateInstance}/${url.search}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function redirectWikipedia(url, initiator) {
|
function redirectWikipedia(url, initiator) {
|
||||||
if (disableWikipedia || isException(url, initiator)) {
|
if (disableWikipedia || isException(url, initiator)) {
|
||||||
return null;
|
return null;
|
||||||
@ -604,8 +632,7 @@ function redirectWikipedia(url, initiator) {
|
|||||||
//wikiless doesn't have mobile view support yet
|
//wikiless doesn't have mobile view support yet
|
||||||
}
|
}
|
||||||
for (let i = 0; i < GETArguments.length; i++) {
|
for (let i = 0; i < GETArguments.length; i++) {
|
||||||
link +=
|
link += (i == 0 ? "?" : "&") + GETArguments[i][0] + "=" + GETArguments[i][1];
|
||||||
(i == 0 ? "?" : "&") + GETArguments[i][0] + "=" + GETArguments[i][1];
|
|
||||||
}
|
}
|
||||||
if (
|
if (
|
||||||
urlSplit[urlSplit.length - 1] == "org" &&
|
urlSplit[urlSplit.length - 1] == "org" &&
|
||||||
@ -659,9 +686,6 @@ browser.webRequest.onBeforeRequest.addListener(
|
|||||||
);
|
);
|
||||||
// console.info("Details", details);
|
// console.info("Details", details);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return redirect;
|
return redirect;
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -682,14 +706,16 @@ browser.tabs.onUpdated.addListener((tabId, changeInfo, _) => {
|
|||||||
mightyList.push(...invidiousInstances);
|
mightyList.push(...invidiousInstances);
|
||||||
mightyList.push(...nitterInstances);
|
mightyList.push(...nitterInstances);
|
||||||
mightyList.push(...bibliogramInstances);
|
mightyList.push(...bibliogramInstances);
|
||||||
mightyList.push(...redditInstances);
|
mightyList.push(...redditInstances['libreddit']);
|
||||||
|
mightyList.push(...redditInstances['teddit']);
|
||||||
|
mightyList.push(redditInstances['desktop']);
|
||||||
|
mightyList.push(redditInstances['mobile']);
|
||||||
mightyList.push(...searchEngineInstances);
|
mightyList.push(...searchEngineInstances);
|
||||||
mightyList.push(...simplyTranslateInstances);
|
mightyList.push(...simplyTranslateInstances);
|
||||||
mightyList.push(...scribeInstances);
|
mightyList.push(...scribeInstances);
|
||||||
mightyList.push(...wikipediaInstances);
|
mightyList.push(...wikipediaInstances);
|
||||||
|
|
||||||
if (mightyList.includes(protocolHost))
|
if (mightyList.includes(protocolHost)) browser.pageAction.show(tabId);
|
||||||
browser.pageAction.show(tabId);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
@ -698,21 +724,23 @@ browser.pageAction.onClicked.addListener((tab) => {
|
|||||||
var protocolHost = `${tabUrl.protocol}//${tabUrl.host}`;
|
var protocolHost = `${tabUrl.protocol}//${tabUrl.host}`;
|
||||||
var newUrl;
|
var newUrl;
|
||||||
if (invidiousInstances.includes(protocolHost))
|
if (invidiousInstances.includes(protocolHost))
|
||||||
newUrl = 'https://youtube.com/';
|
newUrl = 'https://youtube.com';
|
||||||
else if (nitterInstances.includes(protocolHost))
|
else if (nitterInstances.includes(protocolHost))
|
||||||
newUrl = 'https://twitter.com/';
|
newUrl = 'https://twitter.com';
|
||||||
else if (bibliogramInstances.includes(protocolHost))
|
else if (bibliogramInstances.includes(protocolHost))
|
||||||
newUrl = 'https://instagram.com/';
|
newUrl = 'https://instagram.com';
|
||||||
else if (redditInstances.includes(protocolHost))
|
else if (redditInstances['libreddit'].includes(protocolHost))
|
||||||
newUrl = 'https://reddit.com/';
|
newUrl = 'https://reddit.com';
|
||||||
|
else if (redditInstances['teddit'].includes(protocolHost))
|
||||||
|
newUrl = 'https://reddit.com';
|
||||||
else if (searchEngineInstances.includes(protocolHost))
|
else if (searchEngineInstances.includes(protocolHost))
|
||||||
newUrl = 'https://google.com/';
|
newUrl = 'https://google.com';
|
||||||
else if (simplyTranslateInstances.includes(protocolHost))
|
else if (simplyTranslateInstances.includes(protocolHost))
|
||||||
newUrl = 'https://translate.google.com/';
|
newUrl = 'https://translate.google.com';
|
||||||
else if (scribeInstances.includes(protocolHost))
|
else if (scribeInstances.includes(protocolHost))
|
||||||
newUrl = 'https://medium.com/';
|
newUrl = 'https://medium.com';
|
||||||
else if (wikipediaInstances.includes(protocolHost))
|
else if (wikipediaInstances.includes(protocolHost))
|
||||||
newUrl = 'https://wikipedia.com/';
|
newUrl = 'https://wikipedia.com';
|
||||||
|
|
||||||
if (newUrl)
|
if (newUrl)
|
||||||
browser.tabs.update({
|
browser.tabs.update({
|
||||||
@ -720,28 +748,34 @@ browser.pageAction.onClicked.addListener((tab) => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
browser.runtime.onInstalled.addListener((details) => {
|
browser.runtime.onInstalled.addListener((details) => {
|
||||||
browser.storage.sync.get(
|
browser.storage.sync.get(
|
||||||
["disableSearchEngine", "disableSimplyTranslate", "disableWikipedia"],
|
[
|
||||||
|
"disableSearchEngine",
|
||||||
|
"disableSimplyTranslate",
|
||||||
|
"disableWikipedia",
|
||||||
|
"redditFrontend"
|
||||||
|
],
|
||||||
(result) => {
|
(result) => {
|
||||||
if (result.disableSearchEngine === undefined) {
|
if (result.disableSearchEngine === undefined)
|
||||||
browser.storage.sync.set({
|
browser.storage.sync.set({
|
||||||
disableSearchEngine: true,
|
disableSearchEngine: true,
|
||||||
});
|
});
|
||||||
}
|
|
||||||
if (result.disableSimplyTranslate === undefined) {
|
if (result.disableSimplyTranslate === undefined)
|
||||||
browser.storage.sync.set({
|
browser.storage.sync.set({
|
||||||
disableSimplyTranslate: true,
|
disableSimplyTranslate: true,
|
||||||
});
|
});
|
||||||
}
|
|
||||||
if (result.disableWikipedia === undefined) {
|
if (result.disableWikipedia === undefined)
|
||||||
browser.storage.sync.set({
|
browser.storage.sync.set({
|
||||||
disableWikipedia: true,
|
disableWikipedia: true,
|
||||||
});
|
});
|
||||||
}
|
|
||||||
|
if (result.redditFrontend === undefined)
|
||||||
|
browser.storage.sync.set({
|
||||||
|
redditFrontend: 'libreddit'
|
||||||
|
})
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
if (details.reason === "update") {
|
if (details.reason === "update") {
|
||||||
|
@ -2,8 +2,6 @@ import mapsHelper from "../../assets/javascripts/helpers/google-maps.js";
|
|||||||
import commonHelper from "../../assets/javascripts/helpers/common.js";
|
import commonHelper from "../../assets/javascripts/helpers/common.js";
|
||||||
import shared from "./shared.js";
|
import shared from "./shared.js";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const osmInstances = mapsHelper.redirects;
|
const osmInstances = mapsHelper.redirects;
|
||||||
let osmInstance = document.getElementById("osm-instance");
|
let osmInstance = document.getElementById("osm-instance");
|
||||||
let disableOsm = document.getElementById("disable-osm");
|
let disableOsm = document.getElementById("disable-osm");
|
||||||
@ -32,8 +30,6 @@ const osmInstanceChange = commonHelper.debounce(() => {
|
|||||||
}, 500);
|
}, 500);
|
||||||
osmInstance.addEventListener("input", osmInstanceChange);
|
osmInstance.addEventListener("input", osmInstanceChange);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
disableOsm.addEventListener("change", (event) => {
|
disableOsm.addEventListener("change", (event) => {
|
||||||
browser.storage.sync.set({ disableOsm: !event.target.checked });
|
browser.storage.sync.set({ disableOsm: !event.target.checked });
|
||||||
});
|
});
|
@ -217,22 +217,24 @@
|
|||||||
</section>
|
</section>
|
||||||
|
|
||||||
<section class="reddit">
|
<section class="reddit">
|
||||||
|
|
||||||
<div class="some-block option-block">
|
<div class="some-block option-block">
|
||||||
<h1>Reddit (LibReddit)</h1>
|
<h1>Reddit (LibReddit)</h1>
|
||||||
<input id="disable-reddit" type="checkbox" checked />
|
<input id="disable-reddit" type="checkbox" checked />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="some-block option-block">
|
<div class="some-block option-block">
|
||||||
<h4>Instance</h4>
|
<h4>Instance</h4>
|
||||||
<div class="autocomplete">
|
<div class="autocomplete">
|
||||||
<input id="reddit-instance" type="url" placeholder="https://libredd.it" />
|
<input id="reddit-instance" type="url" placeholder="https://libredd.it" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<section class="settings-block">
|
<section class="settings-block">
|
||||||
<h4>Random instance pool (comma-separated)</h4>
|
<h4>Random instance pool (comma-separated)</h4>
|
||||||
<textarea id="reddit-random-pool" name="reddit-random-pool" type="text"></textarea>
|
<textarea id="reddit-random-pool" name="reddit-random-pool" type="text"></textarea>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
|
||||||
<div class="some-block option-block">
|
<div class="some-block option-block">
|
||||||
<h4>Frontend</h4>
|
<h4>Frontend</h4>
|
||||||
<select id="reddit-frontend">
|
<select id="reddit-frontend">
|
||||||
|
@ -7,16 +7,18 @@ const redditInstances = redditHelper.redirects;
|
|||||||
|
|
||||||
let redditInstance = document.getElementById("reddit-instance");
|
let redditInstance = document.getElementById("reddit-instance");
|
||||||
let disableReddit = document.getElementById("disable-reddit");
|
let disableReddit = document.getElementById("disable-reddit");
|
||||||
|
let redditFrontend = document.getElementById("reddit-frontend");
|
||||||
|
|
||||||
browser.storage.sync.get(
|
browser.storage.sync.get(
|
||||||
[
|
[
|
||||||
"redditInstance",
|
"redditInstance",
|
||||||
"disableReddit",
|
"disableReddit",
|
||||||
|
"redditFrontend"
|
||||||
],
|
],
|
||||||
(result) => {
|
(result) => {
|
||||||
redditInstance.value = result.redditInstance || "";
|
redditInstance.value = result.redditInstance || "";
|
||||||
disableReddit.checked = !result.disableReddit;
|
disableReddit.checked = !result.disableReddit;
|
||||||
|
redditFrontend.value = result.redditFrontend;
|
||||||
let id = "reddit-instance";
|
let id = "reddit-instance";
|
||||||
let instances = redditInstances;
|
let instances = redditInstances;
|
||||||
shared.autocompletes.push({ id: id, instances: instances })
|
shared.autocompletes.push({ id: id, instances: instances })
|
||||||
@ -24,15 +26,27 @@ browser.storage.sync.get(
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
const redditInstanceChange = commonHelper.debounce(() => {
|
const redditInstanceChange = commonHelper.debounce(
|
||||||
if (redditInstance.checkValidity()) {
|
() => {
|
||||||
browser.storage.sync.set({
|
if (redditInstance.checkValidity()) {
|
||||||
redditInstance: shared.parseURL(redditInstance.value),
|
browser.storage.sync.set({
|
||||||
});
|
redditInstance: shared.parseURL(redditInstance.value),
|
||||||
}
|
});
|
||||||
}, 500);
|
}
|
||||||
|
},
|
||||||
|
500
|
||||||
|
);
|
||||||
|
|
||||||
redditInstance.addEventListener("input", redditInstanceChange);
|
redditInstance.addEventListener("input", redditInstanceChange);
|
||||||
|
|
||||||
disableReddit.addEventListener("change", (event) => {
|
disableReddit.addEventListener("change", (event) => {
|
||||||
browser.storage.sync.set({ disableReddit: !event.target.checked });
|
browser.storage.sync.set({ disableReddit: !event.target.checked });
|
||||||
});
|
});
|
||||||
|
|
||||||
|
redditFrontend.addEventListener("change", (event) => {
|
||||||
|
const value = event.target.options[redditFrontend.selectedIndex].value;
|
||||||
|
console.info("Reddit Frontend", value)
|
||||||
|
browser.storage.sync.set({
|
||||||
|
redditFrontend: value,
|
||||||
|
})
|
||||||
|
})
|
Loading…
x
Reference in New Issue
Block a user