Можно ли удалить x-frame-options с помощью javascript в моем расширении chrome?
В настоящее время у меня есть это
manifest.json
{
"manifest_version": 2,
"name": "background",
"description": "DE background",
"version": "1.0",
"content_scripts": [
{
"matches": ["*://*.web.com/*"],
"js": ["contentscript.js"],
"all_frames": true
}
],
"permissions": ["*://*.web.com/*", "webRequest", "webRequestBlocking"]
}
Background.js
// This is to remove X-Frame-Options header, if present
chrome.webRequest.onHeadersReceived.addListener(
function(info) {
var headers = info.responseHeaders;
var index = headers.findIndex(x=>x.name.toLowerCase() == "x-frame-options");
if (index !=-1) {
headers.splice(index, 1);
}
return {responseHeaders: headers};
},
{
urls: ['*://*.web.com/*'], //
types: ['sub_frame']
},
['blocking', 'responseHeaders']
);
contentscript.js
var elementToInsert = document.createElement("h1");
elementToInsert.textContent = "This text comes from my content script.";
document.body.insertBefore(elementToInsert, document.body.firstChild);
Это нормально работает, если код находится в background.js, но возможно добавить этот код (background.js) в contentscript.js?
Я задаю этот вопрос, потому что в настоящее время у меня есть расширение в хранилище chrome с другими manifest.json и background.js, но я просто хочу отредактировать contentscript.js для удаления параметров x-frame, я не хочу редактировать Background.js или manifest.json Only contentscript.js
Спасибо