Added bypass on reddit option
This commit is contained in:
parent
f4d07c15ac
commit
3246d6fd69
|
@ -184,21 +184,40 @@ function setProtocol(val) {
|
||||||
console.log("redditProtocol: ", val)
|
console.log("redditProtocol: ", val)
|
||||||
}
|
}
|
||||||
|
|
||||||
function isReddit(url, initiator) {
|
function isReddit(url,) {
|
||||||
if (
|
|
||||||
initiator &&
|
|
||||||
(
|
|
||||||
[...redirects.libreddit.normal, ...libredditNormalCustomRedirects].includes(initiator.origin) ||
|
|
||||||
[...redirects.teddit.normal, ...tedditNormalCustomRedirects].includes(initiator.origin) ||
|
|
||||||
targets.includes(initiator.host)
|
|
||||||
)
|
|
||||||
) return false;
|
|
||||||
return targets.includes(url.host)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function redirect(url, type) {
|
let bypassWatchOnReddit;
|
||||||
|
const getBypassWatchOnReddit = () => bypassWatchOnReddit;
|
||||||
|
function setBypassWatchOnReddit(val) {
|
||||||
|
bypassWatchOnReddit = val;
|
||||||
|
browser.storage.local.set({ bypassWatchOnReddit })
|
||||||
|
console.log("bypassWatchOnReddit: ", bypassWatchOnReddit)
|
||||||
|
}
|
||||||
|
|
||||||
|
function redirect(url, type, initiator) {
|
||||||
if (disableReddit) return null;
|
if (disableReddit) return null;
|
||||||
|
|
||||||
|
if (
|
||||||
|
bypassWatchOnReddit &&
|
||||||
|
initiator &&
|
||||||
|
(
|
||||||
|
[...redirects.libreddit.normal,
|
||||||
|
...redirects.libreddit.tor,
|
||||||
|
...libredditNormalCustomRedirects,
|
||||||
|
...libredditTorCustomRedirects,
|
||||||
|
...redirects.teddit.normal,
|
||||||
|
...redirects.teddit.tor,
|
||||||
|
...tedditNormalCustomRedirects,
|
||||||
|
...tedditTorCustomRedirects,
|
||||||
|
].includes(initiator.origin) ||
|
||||||
|
targets.includes(initiator.host)
|
||||||
|
)
|
||||||
|
) return 'BYBASSTAB';
|
||||||
|
|
||||||
|
if ((!targets.includes(url.host))) return null;
|
||||||
|
|
||||||
if (type !== "main_frame" || url.pathname.match(bypassPaths)) return null;
|
if (type !== "main_frame" || url.pathname.match(bypassPaths)) return null;
|
||||||
|
|
||||||
if (frontend == 'old') return `${redirects.desktop}${url.pathname}${url.search}`;
|
if (frontend == 'old') return `${redirects.desktop}${url.pathname}${url.search}`;
|
||||||
|
@ -314,11 +333,14 @@ async function init() {
|
||||||
"tedditTorCustomRedirects",
|
"tedditTorCustomRedirects",
|
||||||
|
|
||||||
"redditProtocol",
|
"redditProtocol",
|
||||||
|
"bypassWatchOnReddit",
|
||||||
], (result) => {
|
], (result) => {
|
||||||
disableReddit = result.disableReddit ?? false;
|
disableReddit = result.disableReddit ?? false;
|
||||||
protocol = result.redditProtocol ?? 'normal';
|
protocol = result.redditProtocol ?? 'normal';
|
||||||
frontend = result.redditFrontend ?? 'libreddit';
|
frontend = result.redditFrontend ?? 'libreddit';
|
||||||
|
|
||||||
|
bypassWatchOnReddit = result.bypassWatchOnReddit ?? true;
|
||||||
|
|
||||||
redirects.teddit = dataJson.teddit;
|
redirects.teddit = dataJson.teddit;
|
||||||
if (result.redditRedirects) redirects = result.redditRedirects;
|
if (result.redditRedirects) redirects = result.redditRedirects;
|
||||||
|
|
||||||
|
@ -359,6 +381,9 @@ export default {
|
||||||
getProtocol,
|
getProtocol,
|
||||||
setProtocol,
|
setProtocol,
|
||||||
|
|
||||||
|
getBypassWatchOnReddit,
|
||||||
|
setBypassWatchOnReddit,
|
||||||
|
|
||||||
getLibredditNormalRedirectsChecks,
|
getLibredditNormalRedirectsChecks,
|
||||||
setLibredditNormalRedirectsChecks,
|
setLibredditNormalRedirectsChecks,
|
||||||
getLibredditTorRedirectsChecks,
|
getLibredditTorRedirectsChecks,
|
||||||
|
|
|
@ -60,7 +60,7 @@ browser.webRequest.onBeforeRequest.addListener(
|
||||||
|
|
||||||
if (mapsHelper.isMaps(url, initiator)) newUrl = mapsHelper.redirect(url);
|
if (mapsHelper.isMaps(url, initiator)) newUrl = mapsHelper.redirect(url);
|
||||||
|
|
||||||
if (redditHelper.isReddit(url, initiator)) newUrl = redditHelper.redirect(url, details.type);
|
if (!newUrl) newUrl = redditHelper.redirect(url, details.type, initiator);
|
||||||
|
|
||||||
if (mediumHelper.isMedium(url, initiator)) newUrl = mediumHelper.redirect(url, details.type);
|
if (mediumHelper.isMedium(url, initiator)) newUrl = mediumHelper.redirect(url, details.type);
|
||||||
|
|
||||||
|
|
|
@ -136,6 +136,11 @@
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="some-block option-block">
|
||||||
|
<h4>Bypass Watch On Reddit</h4>
|
||||||
|
<input id="bypass-watch-on-reddit" type="checkbox" checked />
|
||||||
|
</div>
|
||||||
|
|
||||||
<hr>
|
<hr>
|
||||||
|
|
||||||
<div id="libreddit">
|
<div id="libreddit">
|
||||||
|
|
|
@ -61,8 +61,14 @@ function changeProtocolSettings(protocol) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let bypassWatchOnRedditElement = document.getElementById("bypass-watch-on-reddit")
|
||||||
|
bypassWatchOnRedditElement.addEventListener("change",
|
||||||
|
event => redditHelper.setBypassWatchOnReddit(event.target.checked)
|
||||||
|
);
|
||||||
|
|
||||||
redditHelper.init().then(() => {
|
redditHelper.init().then(() => {
|
||||||
disableRedditElement.checked = !redditHelper.getDisableReddit();
|
disableRedditElement.checked = !redditHelper.getDisableReddit();
|
||||||
|
bypassWatchOnRedditElement.checked = redditHelper.getBypassWatchOnReddit();
|
||||||
|
|
||||||
let frontend = redditHelper.getFrontend();
|
let frontend = redditHelper.getFrontend();
|
||||||
redditFrontendElement.value = frontend;
|
redditFrontendElement.value = frontend;
|
||||||
|
|
Loading…
Reference in New Issue