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

Added notice for privacy.resistFingerprinting

Fixes #427
This commit is contained in:
kkapsner 2020-01-23 15:23:56 +01:00
parent 1556ee45c2
commit 9353f71455
7 changed files with 73 additions and 28 deletions

View File

@ -83,6 +83,10 @@
"message": "Bei Aktualisierung nicht wieder anzeigen.",
"description": ""
},
"resistFingerprintingNotice": {
"message": "Sie haben privacy.resistFingerprinting aktiviert. Dies verändert das Verhalten von CanvasBlocker ein wenig. Weitere Informationen finden Sie {link:hier:https://github.com/kkapsner/CanvasBlocker/issues/158} und {link:hier:https://github.com/ghacksuserjs/ghacks-user.js/issues/767}.",
"description": ""
},
"openInTab": {
"message": "In separatem Tab öffnen",
"description": ""
@ -1543,4 +1547,4 @@
"message": "Der window-API-Schutz macht reCAPTCHA unbenutzbar. Diese Voreinstellung erlaubt die Benutzung der window.name-API in eingebetteten Seiten. Dadurch funktioniert es wieder.",
"description": ""
}
}
}

View File

@ -88,6 +88,10 @@
"message": "Don't show up again after update.",
"description": ""
},
"resistFingerprintingNotice": {
"message": "You have privacy.resistFingerprinting enabled. This slightly changes the behaviour of CanvasBlocker. See further information {link:here:https://github.com/kkapsner/CanvasBlocker/issues/158} and {link:here:https://github.com/ghacksuserjs/ghacks-user.js/issues/767}.",
"description": ""
},
"openInTab": {
"message": "Open in separate tab",
"description": ""

View File

@ -27,6 +27,38 @@
return id;
};
scope.parseTranslation = function parseTranslation(message){
const container = document.createDocumentFragment();
message.split(/(\{[^}]+\})/).forEach(function(part){
if (part.startsWith("{") && part.endsWith("}")){
part = part.substring(1, part.length - 1);
const args = part.split(":");
switch (args[0]){
case "image": {
const image = document.createElement("img");
image.className = "noticeImage";
image.src = args.slice(1).join(":");
container.appendChild(image);
break;
}
case "link": {
const link = document.createElement("a");
link.target = "_blank";
link.textContent = args[1];
link.href = args.slice(2).join(":");
container.appendChild(link);
break;
}
}
}
else {
container.appendChild(document.createTextNode(part));
}
});
return container;
};
scope.extensionID = browserAvailable? browser.extension.getURL(""): "extensionID";
scope.inIncognitoContext = browserAvailable? browser.extension.inIncognitoContext: false;

View File

@ -91,7 +91,8 @@
"webRequest",
"webRequestBlocking",
"contextualIdentities",
"cookies"
"cookies",
"privacy"
],
"applications": {

View File

@ -37,6 +37,12 @@ header .bookmarkNotice .dontShowOptionsOnUpdate input {
vertical-align: sub;
}
.resistFingerprintingNotice {
margin: 0.5em 0;
padding: 0.5em;
border: 1px solid var(--input-error-background-color);
}
.settings {
width: 100%;
border-spacing: 0;

View File

@ -228,6 +228,29 @@
groupTabs.classList = "groupTabs";
document.body.appendChild(groupTabs);
if (
browser.privacy &&
browser.privacy.websites &&
browser.privacy.websites.resistFingerprinting &&
browser.privacy.websites.resistFingerprinting.get
){
browser.privacy.websites.resistFingerprinting.get({}).then(function({value}){
if (value){
const rfpNotice = document.createElement("div");
rfpNotice.className = "resistFingerprintingNotice";
rfpNotice.appendChild(
extension.parseTranslation(
extension.getTranslation("resistFingerprintingNotice")
)
);
document.body.insertBefore(rfpNotice, groupTabs);
}
return undefined;
}).catch(function(error){
logging.warning("Unable to read resistFingerprinting:", error);
});
}
const groups = document.createElement("ul");
groups.className = "groups";
groupTabs.appendChild(groups);

View File

@ -141,32 +141,7 @@
if (noticeText){
const notice = document.createElement("div");
notice.className = noticeName + " notice";
noticeText.split(/(\{[^}]+\})/).forEach(function(part){
if (part.startsWith("{") && part.endsWith("}")){
part = part.substring(1, part.length - 1);
const args = part.split(":");
switch (args[0]){
case "image": {
const image = document.createElement("img");
image.className = "noticeImage";
image.src = args[1];
notice.appendChild(image);
break;
}
case "link": {
const link = document.createElement("a");
link.target = "_blank";
link.textContent = args[1];
link.href = args[2];
notice.appendChild(link);
break;
}
}
}
else {
notice.appendChild(document.createTextNode(part));
}
});
notice.appendChild(extension.parseTranslation(noticeText));
head.appendChild(notice);
}