Removed x-frame-options header on iframes from Nitter instances #20
This commit is contained in:
parent
1079e64f0d
commit
9547cc95fd
|
@ -184,6 +184,20 @@ function switchInstance(url) {
|
||||||
return `${randomInstance}${url.pathname}${url.search}`;
|
return `${randomInstance}${url.pathname}${url.search}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function removeXFrameOptions(e) {
|
||||||
|
let url = new URL(e.url);
|
||||||
|
let protocolHost = `${url.protocol}//${url.host}`;
|
||||||
|
let twitterList = [
|
||||||
|
...redirects.nitter.normal,
|
||||||
|
...redirects.nitter.tor,
|
||||||
|
...nitterNormalCustomRedirects,
|
||||||
|
...nitterTorCustomRedirects,
|
||||||
|
];
|
||||||
|
if (!twitterList.includes(protocolHost) && e.type != 'sub_frame') return;
|
||||||
|
for (const i in e.responseHeaders) if (e.responseHeaders[i].name = 'x-frame-options') e.responseHeaders.splice(i, 1);
|
||||||
|
return { responseHeaders: e.responseHeaders };
|
||||||
|
}
|
||||||
|
|
||||||
function isNitter(url, type) {
|
function isNitter(url, type) {
|
||||||
let protocolHost = `${url.protocol}//${url.host}`;
|
let protocolHost = `${url.protocol}//${url.host}`;
|
||||||
|
|
||||||
|
@ -299,6 +313,8 @@ export default {
|
||||||
getBypassWatchOnTwitter,
|
getBypassWatchOnTwitter,
|
||||||
setBypassWatchOnTwitter,
|
setBypassWatchOnTwitter,
|
||||||
|
|
||||||
|
removeXFrameOptions,
|
||||||
|
|
||||||
getProtocol,
|
getProtocol,
|
||||||
setProtocol,
|
setProtocol,
|
||||||
|
|
||||||
|
|
|
@ -131,6 +131,16 @@ browser.tabs.onRemoved.addListener(
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
// Set "blocking" and "responseHeaders".
|
||||||
|
browser.webRequest.onHeadersReceived.addListener(
|
||||||
|
e => {
|
||||||
|
return twitterHelper.removeXFrameOptions(e);
|
||||||
|
},
|
||||||
|
{ urls: ["<all_urls>"], },
|
||||||
|
["blocking", "responseHeaders"]
|
||||||
|
);
|
||||||
|
|
||||||
function redirectOfflineInstance(url, tabId) {
|
function redirectOfflineInstance(url, tabId) {
|
||||||
let newUrl;
|
let newUrl;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue