Skip to content

Commit

Permalink
1.2 : [Added regexp based whitelist]
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomazPom committed Jul 26, 2018
1 parent 5430541 commit 68d8df3
Show file tree
Hide file tree
Showing 6 changed files with 467 additions and 392 deletions.
56 changes: 39 additions & 17 deletions background.js
Original file line number Diff line number Diff line change
@@ -1,30 +1,52 @@
var defaultRgx = ["http://*/*", "https://*/*"].join('\n')
var regexpesarray = [];
function updateRegexpes(save)
{
browser.storage.local.get("regstr", function(res) {
var regstr = (res.regstr || defaultRgx);

regexpesarray = [];
var regexpesarray = regstr.split("\n")
console.log(regexpesarray)

// Add the new header to the original array,
// and return it.
browser.webRequest.onHeadersReceived.removeListener(setHeader)
browser.webRequest.onHeadersReceived.addListener(setHeader,
{urls : regexpesarray},
["blocking", "responseHeaders"]
);
});
}
function setHeader(e) {
for (var header of e.responseHeaders) {
if (header.name.toLowerCase() === "x-frame-options") {
header.value = "ALLOW";
}
}
for (var header of e.responseHeaders) {
if (header.name.toLowerCase() === "x-frame-options") {
header.value = "ALLOW";
}
}
var setMyCookie = {
name: "x-frame-options",
value: "ALLOW"
};
e.responseHeaders.push(setMyCookie);
return {responseHeaders: e.responseHeaders};
}

// Listen for onHeaderReceived for the target page.
// Set "blocking" and "responseHeaders".
browser.webRequest.onHeadersReceived.addListener(
setHeader,
{urls : ["http://*/*", "https://*/*"]},
["blocking", "responseHeaders"]
);
updateRegexpes();
console.log("Loaded")
browser.browserAction.onClicked.addListener(function()
{
alert();
})
var portFromCS;
function connected(p) {
portFromCS = p;
//portFromCS.postMessage({greeting: "hi there content script!"});
portFromCS.onMessage.addListener(function(m) {
if(m.updateRegexpes)
{

browser.storage.local.set({"regstr":m.updateRegexpes}, function(res) {
updateRegexpes();
});


}
});
}
browser.runtime.onConnect.addListener(connected);
Empty file added js/jspop.js
Empty file.
11 changes: 8 additions & 3 deletions manifest.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,22 @@
{
"manifest_version": 2,
"name": "Ignore X-Frame-Options",
"version": "1.1",
"version": "1.2",
"description": "Allows all sites to be loaded in iframes, despite X-Frame-Options header settings.",
"homepage_url": "https://github.com/ThomazPom/Moz-Ext-Ignore-X-Frame-Options",
"icons": {
"48": "icons/48.png",
"96": "icons/2x.png"
},

"content_scripts":[
{
"matches": ["<all_urls>"],
"js": ["js/jspop.js"]
}
],
"permissions": [
"<all_urls>", "webRequest", "webRequestBlocking"]
"<all_urls>", "webRequest", "webRequestBlocking","storage"]
,

"browser_action": {
Expand All @@ -19,7 +25,6 @@

"default_popup": "popup.html"
},

"background": {
"scripts": ["background.js"]
}
Expand Down
Loading

0 comments on commit 68d8df3

Please sign in to comment.