Added removeXFrameOptions to Piped, Invidious #263
This commit is contained in:
parent
b8618956fb
commit
d88a4afd6b
|
@ -433,6 +433,29 @@ async function initInvidiousCookies(from) {
|
|||
)
|
||||
}
|
||||
|
||||
function removeXFrameOptions(e) {
|
||||
const url = new URL(e.url);
|
||||
let protocolHost = commonHelper.protocolHost(url);
|
||||
const list = [
|
||||
...redirects.invidious.normal,
|
||||
...invidiousNormalCustomRedirects,
|
||||
...redirects.invidious.tor,
|
||||
...invidiousTorCustomRedirects,
|
||||
|
||||
...redirects.piped.normal,
|
||||
...redirects.piped.tor,
|
||||
...pipedNormalCustomRedirects,
|
||||
...pipedTorCustomRedirects
|
||||
];
|
||||
if (!list.includes(protocolHost) || e.type != 'sub_frame') return;
|
||||
let isChanged = false;
|
||||
for (const i in e.responseHeaders) if (e.responseHeaders[i].name == 'x-frame-options') {
|
||||
e.responseHeaders.splice(i, 1);
|
||||
isChanged = true;
|
||||
}
|
||||
if (isChanged) return { responseHeaders: e.responseHeaders };
|
||||
}
|
||||
|
||||
let
|
||||
initPipedLocalStorage = piped.initPipedLocalStorage,
|
||||
initPipedMaterialLocalStorage = pipedMaterial.initPipedMaterialLocalStorage,
|
||||
|
@ -454,6 +477,7 @@ export default {
|
|||
copyPipedLocalStorage,
|
||||
|
||||
initDefaults,
|
||||
|
||||
init,
|
||||
|
||||
removeXFrameOptions,
|
||||
};
|
||||
|
|
|
@ -86,10 +86,8 @@ browser.webRequest.onBeforeRequest.addListener(
|
|||
initiator = new URL(details.originUrl);
|
||||
else if (details.initiator)
|
||||
initiator = new URL(details.initiator);
|
||||
|
||||
let newUrl;
|
||||
|
||||
if (!newUrl) newUrl = youtubeHelper.redirect(url, details, initiator)
|
||||
|
||||
let newUrl = youtubeHelper.redirect(url, details, initiator)
|
||||
if (youtubeMusicHelper.isYoutubeMusic(url, initiator)) newUrl = youtubeMusicHelper.redirect(url, details.type)
|
||||
|
||||
if (!newUrl) newUrl = twitterHelper.redirect(url, initiator);
|
||||
|
@ -149,7 +147,9 @@ browser.tabs.onRemoved.addListener(
|
|||
browser.webRequest.onHeadersReceived.addListener(
|
||||
async e => {
|
||||
await wholeInit();
|
||||
return twitterHelper.removeXFrameOptions(e);
|
||||
let response = twitterHelper.removeXFrameOptions(e)
|
||||
if (!response) youtubeHelper.removeXFrameOptions(e)
|
||||
return response;
|
||||
},
|
||||
{ urls: ["<all_urls>"], },
|
||||
["blocking", "responseHeaders"]
|
||||
|
|
Loading…
Reference in New Issue