1
0
mirror of https://github.com/kkapsner/CanvasBlocker synced 2024-12-22 12:50:36 +01:00

Added session white list

Fixes #197
This commit is contained in:
kkapsner 2018-07-17 13:07:50 +02:00
parent 6c2dbbebf0
commit 5077c86859
11 changed files with 306 additions and 1 deletions

View File

@ -512,6 +512,14 @@
"message": "Geben Sie die Domain ein, die erlaubt werden soll:", "message": "Geben Sie die Domain ein, die erlaubt werden soll:",
"description": "" "description": ""
}, },
"inputSessionWhitelistDomain": {
"message": "Geben Sie die URL RegExp ein, die für diese Sitzung erlaubt werden soll:",
"description": ""
},
"inputSessionWhitelistURL": {
"message": "Geben Sie die Domain ein, die für diese Sitzung erlaubt werden soll:",
"description": ""
},
"settings": { "settings": {
"message": "Einstellungen", "message": "Einstellungen",
"description": "" "description": ""
@ -585,6 +593,24 @@
"description": "" "description": ""
}, },
"sessionWhiteList_description": {
"message": "Domänen oder URLs, die die <canvas>-API in der aktuellen Sitzung verwenden dürfen. Mehrere Einträge müssen durch ein Komma getrennt werden.",
"description": ""
},
"sessionWhiteList_title": {
"message": "Sitzungs-Whitelist",
"description": ""
},
"whitelistDomainTemporarily": {
"message": "erlaube Domain übergangsweise",
"description": ""
},
"whitelistURLTemporarily": {
"message": "erlaube URL übergangsweise",
"description": ""
},
"inspectImage": { "inspectImage": {
"message": "Bild betrachten", "message": "Bild betrachten",
"description": "" "description": ""

View File

@ -512,6 +512,14 @@
"message": "Input domain to add to white list:", "message": "Input domain to add to white list:",
"description": "" "description": ""
}, },
"inputSessionWhitelistDomain": {
"message": "Input URL RegExp to add to the session white list:",
"description": ""
},
"inputSessionWhitelistURL": {
"message": "Input domain to add to the session white list:",
"description": ""
},
"settings": { "settings": {
"message": "settings", "message": "settings",
"description": "" "description": ""
@ -585,6 +593,24 @@
"description": "" "description": ""
}, },
"sessionWhiteList_title": {
"message": "Session white list",
"description": ""
},
"sessionWhiteList_description": {
"message": "Domains or URLs where the <canvas>-API should not be blocked in the current session. To add multiple entries, separate them by commas.",
"description": ""
},
"whitelistDomainTemporarily": {
"message": "whitelist domain temporarily",
"description": ""
},
"whitelistURLTemporarily": {
"message": "whitelist URL temporarily",
"description": ""
},
"inspectImage": { "inspectImage": {
"message": "inspect image", "message": "inspect image",
"description": "" "description": ""

View File

@ -0,0 +1,94 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="19"
height="19"
id="svg2"
version="1.1"
inkscape:version="0.92.2 2405546, 2018-03-11"
sodipodi:docname="pageAction-whitelistDomainTemporarily.svg">
<defs
id="defs4" />
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="7.9195959"
inkscape:cx="34.759442"
inkscape:cy="26.906576"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="false"
inkscape:window-width="1600"
inkscape:window-height="841"
inkscape:window-x="0"
inkscape:window-y="0"
inkscape:window-maximized="1" />
<metadata
id="metadata7">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title />
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Ebene 1"
inkscape:groupmode="layer"
id="layer1"
transform="translate(0,-1033.3622)">
<text
xml:space="preserve"
style="font-style:normal;font-weight:normal;line-height:0%;font-family:sans-serif;text-align:start;letter-spacing:0px;word-spacing:0px;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none"
x="-4.8717484"
y="1008.9256"
id="text3755"><tspan
sodipodi:role="line"
id="tspan3757"
x="-4.8717484"
y="1008.9256"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:20px;line-height:1.25;font-family:'Times New Roman';-inkscape-font-specification:'Times New Roman';text-align:start;text-anchor:start">www.</tspan></text>
<path
style="fill:none;stroke:#00be00;stroke-width:3;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
d="m 4.1668789,1040.8717 c 2.65165,3.1567 3.661803,3.788 4.293148,8.5863 0.883884,-3.7881 2.3550471,-9.0615 7.0710681,-13.3846"
id="path2985"
inkscape:connector-curvature="0"
sodipodi:nodetypes="ccc" />
<g
id="g1396"
transform="matrix(1.25,0,0,1.25,-4.2499997,-262.84053)"
style="fill:#ffffff;fill-opacity:1">
<circle
r="3.6056104"
cy="1047.3622"
cx="13"
id="path1366"
style="opacity:1;fill:#ffffff;fill-opacity:1;stroke:#bbbbbb;stroke-width:0.78877938;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
<path
inkscape:connector-curvature="0"
id="path1368"
d="m 13.188069,1044.9014 v 2.5254"
style="fill:#ffffff;stroke:#000000;stroke-width:0.5;stroke-linecap:round;stroke-linejoin:bevel;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;fill-opacity:1" />
<path
inkscape:connector-curvature="0"
id="path1370"
d="m 13.188069,1047.4268 2.466712,-1.2334"
style="fill:#ffffff;stroke:#000000;stroke-width:0.5;stroke-linecap:round;stroke-linejoin:bevel;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;fill-opacity:1" />
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 3.7 KiB

View File

@ -0,0 +1,90 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="19"
height="19"
id="svg2"
version="1.1"
inkscape:version="0.92.2 2405546, 2018-03-11"
sodipodi:docname="pageAction-whitelistURLTemporarily.svg">
<defs
id="defs4" />
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="7.9195959"
inkscape:cx="44.797833"
inkscape:cy="16.80505"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="false"
inkscape:window-width="1600"
inkscape:window-height="841"
inkscape:window-x="0"
inkscape:window-y="0"
inkscape:window-maximized="1" />
<metadata
id="metadata7">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title />
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Ebene 1"
inkscape:groupmode="layer"
id="layer1"
transform="translate(0,-1033.3622)">
<text
xml:space="preserve"
style="font-style:normal;font-weight:normal;line-height:0%;font-family:sans-serif;text-align:start;letter-spacing:0px;word-spacing:0px;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none"
x="4.5984316"
y="1006.9256"
id="text3755"><tspan
sodipodi:role="line"
id="tspan3757"
x="4.5984316"
y="1006.9256"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:20px;line-height:1.25;font-family:'Times New Roman';-inkscape-font-specification:'Times New Roman';text-align:start;text-anchor:start">https:</tspan></text>
<path
style="fill:none;stroke:#00be00;stroke-width:3;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
d="m 4.167,1040.8719 c 2.65165,3.1567 3.661803,3.788 4.293148,8.5863 0.883884,-3.7881 2.355047,-9.0615 7.071068,-13.3846"
id="path2985"
inkscape:connector-curvature="0"
sodipodi:nodetypes="ccc" />
<ellipse
style="opacity:1;fill:#ffffff;fill-opacity:1;stroke:#bbbbbb;stroke-width:0.98597425;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="path1366"
cx="12"
cy="1046.3623"
rx="4.5070128"
ry="4.5070133" />
<path
style="fill:none;stroke:#000000;stroke-width:0.62500006;stroke-linecap:round;stroke-linejoin:bevel;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 12.235088,1043.2863 v 3.1567"
id="path1368"
inkscape:connector-curvature="0" />
<path
style="fill:none;stroke:#000000;stroke-width:0.62500006;stroke-linecap:round;stroke-linejoin:bevel;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 12.235088,1046.443 3.08339,-1.5417"
id="path1370"
inkscape:connector-curvature="0" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 3.5 KiB

View File

@ -48,6 +48,9 @@
}; };
}); });
return addMatchToList(list);
}
function addMatchToList(list){
list.match = function(url){ list.match = function(url){
return this.some(function(entry){ return this.some(function(entry){
return entry.match(url); return entry.match(url);
@ -59,6 +62,7 @@
var lists = { var lists = {
white: [], white: [],
sessionWhite: [],
"ignore": [], "ignore": [],
black: [] black: []
}; };
@ -105,6 +109,10 @@
updateStackList(settings.stackList); updateStackList(settings.stackList);
scope.get = function getList(type){ scope.get = function getList(type){
if (type === "white"){
var combined = lists.white.slice().concat(lists.sessionWhite);
return addMatchToList(combined);
}
return lists[type]; return lists[type];
}; };
scope.appendTo = function appendToList(type, entry){ scope.appendTo = function appendToList(type, entry){

View File

@ -16,6 +16,9 @@
settings.onloaded(function(){ settings.onloaded(function(){
notice("everything loaded"); notice("everything loaded");
message("perform startup reset");
settings.startupReset();
persistentRndStorage.init(); persistentRndStorage.init();
message("register non port message listener"); message("register non port message listener");

View File

@ -42,6 +42,11 @@
name: "whiteList", name: "whiteList",
defaultValue: "" defaultValue: ""
}, },
{
name: "sessionWhiteList",
resetOnStartup: true,
defaultValue: ""
},
{ {
name: "blackList", name: "blackList",
defaultValue: "" defaultValue: ""

View File

@ -683,5 +683,12 @@
logging.message("settings still default?", settings.isStillDefault); logging.message("settings still default?", settings.isStillDefault);
} }
}; };
scope.startupReset = function(){
scope.forEach(function(definition){
if (definition.resetOnStartup){
definition.set(definition.defaultValue);
}
});
};
Object.seal(scope); Object.seal(scope);
}()); }());

View File

@ -279,6 +279,13 @@
"displayAdvancedSettings": [true] "displayAdvancedSettings": [true]
} }
}, },
{
"name": "sessionWhiteList",
"displayDependencies": {
"blockMode": ["blockReadout", "fakeReadout", "fakeInput", "askReadout", "block", "ask"],
"displayAdvancedSettings": [true]
}
},
{ {
"name": "blackList", "name": "blackList",
"displayDependencies": { "displayDependencies": {

View File

@ -12,6 +12,7 @@
const domainNotification = require("./domainNotification"); const domainNotification = require("./domainNotification");
const Notification = require("./Notification"); const Notification = require("./Notification");
const {createActionButtons, modalPrompt} = require("./gui"); const {createActionButtons, modalPrompt} = require("./gui");
const lists = require("./lists");
Promise.all([ Promise.all([
browser.tabs.query({active: true, currentWindow: true}), browser.tabs.query({active: true, currentWindow: true}),
@ -98,6 +99,25 @@
} }
}); });
} }
},
{
name: "whitelistDomainTemporarily",
isIcon: true,
callback: function(domain){
modalPrompt(
browser.i18n.getMessage("inputSessionWhitelistURL"),
domain
).then(function(domain){
if (domain){
lists.appendTo("sessionWhite", domain).then(function(){
window.close();
});
}
else {
window.close();
}
});
}
} }
].forEach(function(domainAction){ ].forEach(function(domainAction){
domainNotification.addAction(domainAction); domainNotification.addAction(domainAction);
@ -137,6 +157,25 @@
} }
}); });
} }
},
{
name: "whitelistURLTemporarily",
isIcon: true,
callback: function({url}){
modalPrompt(
browser.i18n.getMessage("inputSessionWhitelistDomain"),
"^" + url.href.replace(/([\\+*?[^\]$(){}=!|.])/g, "\\$1") + "$"
).then(function(url){
if (url){
lists.appendTo("sessionWhite", url).then(function(){
window.close();
});
}
else {
window.close();
}
});
}
} }
].forEach(function(action){ ].forEach(function(action){
Notification.addAction(action); Notification.addAction(action);

View File

@ -3,7 +3,7 @@ Version 0.5.1:
- -
new features: new features:
- - new setting: session white list that is cleared on addon load (= browser start)
fixes: fixes:
- Changes made in the page action were not saved in all Firefox versions - Changes made in the page action were not saved in all Firefox versions