78 lines
1.9 KiB
JavaScript
78 lines
1.9 KiB
JavaScript
function url_block_callback(details)
|
|
{
|
|
//console.log(details);
|
|
if (details.requestBody)
|
|
{
|
|
if (details.requestBody.formData)
|
|
{
|
|
for (var key in details.requestBody.formData)
|
|
{
|
|
for(var idx in details.requestBody.formData[key])
|
|
{
|
|
value = details.requestBody.formData[key][idx];
|
|
if (value.startsWith("@@") ||
|
|
value.startsWith("@_"))
|
|
return {cancel: true};
|
|
}
|
|
}
|
|
}
|
|
|
|
/*
|
|
// Analyse POST parameters
|
|
if (details.method == "POST" && details.requestBody.raw)
|
|
{
|
|
alert(details.requestBody.raw);
|
|
var postedString = decodeURIComponent(String.fromCharCode.apply(null,
|
|
new Uint8Array(details.requestBody.raw[0].bytes)));
|
|
if (postedString.indexOf("=@@") != -1 ||
|
|
postedString.indexOf("=@_") != -1)
|
|
return {cancel: true};
|
|
}
|
|
*/
|
|
}
|
|
|
|
return {cancel: false};
|
|
}
|
|
|
|
browser.runtime.onMessage.addListener(
|
|
function(request) {
|
|
|
|
if (request.type == "notification")
|
|
{
|
|
options = {
|
|
type: "basic",
|
|
title : "gPass",
|
|
message : request.options.message,
|
|
iconUrl:browser.extension.getURL("icons/gpass_icon_64.png")
|
|
};
|
|
|
|
browser.notifications.create("gPass", options);
|
|
|
|
window.setTimeout(function() {browser.notifications.clear("gPass")}, 2000);
|
|
}
|
|
else if (request.type == "block_url")
|
|
{
|
|
browser.tabs.getCurrent().then(
|
|
function onGot(tab) {
|
|
if (tab)
|
|
{
|
|
browser.webRequest.onBeforeRequest.addListener(
|
|
url_block_callback,
|
|
{"urls":[request.options.url],
|
|
"types":["main_frame"],
|
|
"tabId":tab.id,
|
|
"windowId":tab.windowId
|
|
},
|
|
["blocking", "requestBody"]);
|
|
}
|
|
else
|
|
{
|
|
browser.webRequest.onBeforeRequest.addListener(
|
|
url_block_callback,
|
|
{"urls":[request.options.url], "types":["main_frame"]},
|
|
["blocking", "requestBody"]);
|
|
}
|
|
});
|
|
}
|
|
});
|