Added Twitter embed toggle #344
This commit is contained in:
parent
f6861164a3
commit
1c1c3cd434
@ -36,6 +36,7 @@ let
|
||||
disableTwitter,
|
||||
twitterProtocol,
|
||||
twitterRedirects,
|
||||
twitterRedirectType,
|
||||
nitterNormalRedirectsChecks,
|
||||
nitterNormalCustomRedirects,
|
||||
nitterTorRedirectsChecks,
|
||||
@ -48,6 +49,7 @@ function init() {
|
||||
"disableTwitter",
|
||||
"twitterProtocol",
|
||||
"twitterRedirects",
|
||||
"twitterRedirectType",
|
||||
"nitterNormalRedirectsChecks",
|
||||
"nitterNormalCustomRedirects",
|
||||
"nitterTorRedirectsChecks",
|
||||
@ -57,6 +59,7 @@ function init() {
|
||||
disableTwitter = r.disableTwitter;
|
||||
twitterProtocol = r.twitterProtocol;
|
||||
twitterRedirects = r.twitterRedirects;
|
||||
twitterRedirectType = r.twitterRedirectType;
|
||||
nitterNormalRedirectsChecks = r.nitterNormalRedirectsChecks;
|
||||
nitterNormalCustomRedirects = r.nitterNormalCustomRedirects;
|
||||
nitterTorRedirectsChecks = r.nitterTorRedirectsChecks;
|
||||
@ -79,11 +82,13 @@ function all() {
|
||||
];
|
||||
}
|
||||
|
||||
function redirect(url, initiator) {
|
||||
function redirect(url, type, initiator) {
|
||||
if (disableTwitter) return;
|
||||
if (!targets.some(rx => rx.test(url.href))) return;
|
||||
if (url.pathname.split("/").includes("home")) return;
|
||||
if (initiator && all().includes(initiator.origin)) return 'BYPASSTAB';
|
||||
if (twitterRedirectType == 'sub_frame' && type == "main_frame") return;
|
||||
if (twitterRedirectType == 'main_frame' && type != "main_frame") return;
|
||||
|
||||
let instancesList;
|
||||
if (twitterProtocol == 'normal') instancesList = [...nitterNormalRedirectsChecks, ...nitterNormalCustomRedirects];
|
||||
@ -206,7 +211,7 @@ function pasteNitterCookies() {
|
||||
utils.getCookiesFromStorage('nitter', checkedInstances, 'proxyVideos');
|
||||
utils.getCookiesFromStorage('nitter', checkedInstances, 'muteVideos');
|
||||
utils.getCookiesFromStorage('nitter', checkedInstances, 'autoplayGifs');
|
||||
|
||||
|
||||
utils.getCookiesFromStorage('nitter', checkedInstances, 'replaceInstagram');
|
||||
utils.getCookiesFromStorage('nitter', checkedInstances, 'replaceReddit');
|
||||
utils.getCookiesFromStorage('nitter', checkedInstances, 'replaceTwitter');
|
||||
@ -231,6 +236,7 @@ function initDefaults() {
|
||||
disableTwitter: false,
|
||||
twitterRedirects: redirects,
|
||||
twitterProtocol: "normal",
|
||||
twitterRedirectType: "both",
|
||||
|
||||
nitterNormalRedirectsChecks: nitterNormalRedirectsChecks,
|
||||
nitterNormalCustomRedirects: [],
|
||||
|
@ -169,8 +169,8 @@ function redirect(url, details, initiator) {
|
||||
const sub_frame = details.type === "sub_frame";
|
||||
|
||||
if (url.pathname.match(/iframe_api/) || url.pathname.match(/www-widgetapi/)) return; // Don't redirect YouTube Player API.
|
||||
if (onlyEmbeddedVideo == 'onlyEmbedded' && !sub_frame) return;
|
||||
if (onlyEmbeddedVideo == 'onlyNotEmbedded' && sub_frame) return;
|
||||
if (onlyEmbeddedVideo == 'onlyEmbedded' && main_frame) return;
|
||||
if (onlyEmbeddedVideo == 'onlyNotEmbedded' && !main_frame) return;
|
||||
|
||||
if ((isFreetube || isYatte) && sub_frame && isFrontendYoutube) return;
|
||||
|
||||
|
@ -59,7 +59,7 @@ browser.runtime.onInstalled.addListener(
|
||||
});
|
||||
})
|
||||
};
|
||||
function initDefault(){
|
||||
function initDefault() {
|
||||
|
||||
}
|
||||
|
||||
@ -103,7 +103,7 @@ browser.webRequest.onBeforeRequest.addListener(
|
||||
|
||||
let newUrl = youtubeMusicHelper.redirect(url, details.type)
|
||||
if (!newUrl) newUrl = youtubeHelper.redirect(url, details, initiator)
|
||||
if (!newUrl) newUrl = twitterHelper.redirect(url, initiator);
|
||||
if (!newUrl) newUrl = twitterHelper.redirect(url, details.type, initiator);
|
||||
if (!newUrl) newUrl = instagramHelper.redirect(url, details.type, initiator);
|
||||
if (!newUrl) newUrl = mapsHelper.redirect(url, initiator);
|
||||
if (!newUrl) newUrl = redditHelper.redirect(url, details.type, initiator);
|
||||
@ -160,7 +160,7 @@ browser.tabs.onRemoved.addListener(
|
||||
browser.webRequest.onHeadersReceived.addListener(
|
||||
e => {
|
||||
let response = youtubeHelper.removeXFrameOptions(e);
|
||||
if (!response) response = twitterHelper.removeXFrameOptions(e);
|
||||
if (!response) response = twitterHelper.removeXFrameOptions(e);
|
||||
return response;
|
||||
},
|
||||
{ urls: ["<all_urls>"] },
|
||||
|
@ -70,10 +70,6 @@
|
||||
<option value="dark" data-localise="__MSG_dark__">Dark</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="some-block option-block">
|
||||
<h4>Tor Browser</h4>
|
||||
<input id="firstPartyIsolate" type="checkbox">
|
||||
</div>
|
||||
<div class="some-block option-block">
|
||||
<h4 data-localise="__MSG_autoRedirect__"></h4>
|
||||
<input id="auto-redirect" type="checkbox">
|
||||
@ -525,6 +521,14 @@
|
||||
<option value="tor" data-localise="__MSG_tor__">Tor</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="some-block option-block">
|
||||
<h4 data-localise="__MSG_redirectType__">Redirect Type</h4>
|
||||
<select id="twitter-redirect_type">
|
||||
<option value="both" data-localise="__MSG_both__">both</option>
|
||||
<option value="sub_frame" data-localise="__MSG_onlyEmbedded__">Only Embedded</option>
|
||||
<option value="main_frame" data-localise="__MSG_onlyNotEmbedded__">Only Not Embedded</option>
|
||||
</select>
|
||||
</div>
|
||||
<div id="nitter">
|
||||
<hr>
|
||||
<div class="normal">
|
||||
|
@ -180,20 +180,20 @@ for (const frontend of generalHelper.allPopupFrontends)
|
||||
}
|
||||
)
|
||||
|
||||
const firstPartyIsolate = document.getElementById('firstPartyIsolate');
|
||||
firstPartyIsolate.addEventListener("change", () => browser.storage.local.set({ firstPartyIsolate: firstPartyIsolate.checked }))
|
||||
// const firstPartyIsolate = document.getElementById('firstPartyIsolate');
|
||||
// firstPartyIsolate.addEventListener("change", () => browser.storage.local.set({ firstPartyIsolate: firstPartyIsolate.checked }))
|
||||
|
||||
browser.storage.local.get(
|
||||
[
|
||||
'theme',
|
||||
'autoRedirect',
|
||||
'exceptions',
|
||||
'firstPartyIsolate'
|
||||
// 'firstPartyIsolate'
|
||||
],
|
||||
r => {
|
||||
autoRedirectElement.checked = r.autoRedirect;
|
||||
themeElement.value = r.theme;
|
||||
firstPartyIsolate.checked = r.firstPartyIsolate;
|
||||
// firstPartyIsolate.checked = r.firstPartyIsolate;
|
||||
|
||||
instanceTypeElement.addEventListener("change",
|
||||
event => {
|
||||
|
@ -2,6 +2,7 @@ import utils from "../../../assets/javascripts/utils.js";
|
||||
|
||||
const enable = document.getElementById("twitter-enable");
|
||||
const protocol = document.getElementById("twitter-protocol");
|
||||
const redirectType = document.getElementById("twitter-redirect_type");
|
||||
const twitter = document.getElementById('twitter_page');
|
||||
|
||||
function changeProtocolSettings() {
|
||||
@ -21,10 +22,12 @@ browser.storage.local.get(
|
||||
[
|
||||
"disableTwitter",
|
||||
"twitterProtocol",
|
||||
"twitterRedirectType",
|
||||
],
|
||||
r => {
|
||||
enable.checked = !r.disableTwitter;
|
||||
protocol.value = r.twitterProtocol;
|
||||
redirectType.value = r.twitterRedirectType;
|
||||
changeProtocolSettings();
|
||||
}
|
||||
)
|
||||
@ -33,6 +36,7 @@ twitter.addEventListener("change", () => {
|
||||
browser.storage.local.set({
|
||||
disableTwitter: !enable.checked,
|
||||
twitterProtocol: protocol.value,
|
||||
twitterRedirectType: redirectType.value,
|
||||
});
|
||||
changeProtocolSettings();
|
||||
})
|
||||
|
@ -12,6 +12,13 @@ section#twitter_page.option-block
|
||||
option(value="normal" data-localise="__MSG_normal__") Normal
|
||||
option(value="tor" data-localise="__MSG_tor__") Tor
|
||||
|
||||
.some-block.option-block
|
||||
h4(data-localise="__MSG_redirectType__") Redirect Type
|
||||
select#twitter-redirect_type
|
||||
option(value="both" data-localise="__MSG_both__") both
|
||||
option(value="sub_frame" data-localise="__MSG_onlyEmbedded__") Only Embedded
|
||||
option(value="main_frame" data-localise="__MSG_onlyNotEmbedded__") Only Not Embedded
|
||||
|
||||
#nitter
|
||||
hr
|
||||
.normal
|
||||
|
Loading…
x
Reference in New Issue
Block a user