Added removeXFrameOptions to Piped, Invidious #263

This commit is contained in:
ManeraKai 2022-05-19 03:46:38 +03:00
parent b8618956fb
commit d88a4afd6b
2 changed files with 30 additions and 6 deletions

View File

@ -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,
};

View File

@ -87,9 +87,7 @@ browser.webRequest.onBeforeRequest.addListener(
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"]