-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1.2 : [Added regexp based whitelist]
- Loading branch information
Showing
6 changed files
with
467 additions
and
392 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.