mirror of
https://github.com/kkapsner/CanvasBlocker
synced 2025-07-03 03:56:26 +02:00
parent
5932ac2292
commit
8b9197a68a
17 changed files with 356 additions and 211 deletions
|
@ -17,7 +17,7 @@
|
|||
const logging = require("./logging");
|
||||
const {copyCanvasToWebgl} = require("./webgl");
|
||||
const getWrapped = require("sdk/getWrapped");
|
||||
const {hasType, checkerWrapper} = require("./modifiedAPIFunctions");
|
||||
const {checkerWrapper} = require("./modifiedAPIFunctions");
|
||||
const modifiedAudioAPI = require("./modifiedAudioAPI");
|
||||
const modifiedDOMRectAPI = require("./modifiedDOMRectAPI");
|
||||
|
||||
|
@ -153,6 +153,27 @@
|
|||
}
|
||||
}
|
||||
|
||||
function getProtectedPartChecker(pref, url){
|
||||
const protectedPart = pref("protectedCanvasPart", url);
|
||||
if (protectedPart === "everything"){
|
||||
return function(){
|
||||
return true;
|
||||
};
|
||||
}
|
||||
else {
|
||||
return function(parts){
|
||||
if (Array.isArray(parts)){
|
||||
return parts.some(function(part){
|
||||
return part === protectedPart;
|
||||
});
|
||||
}
|
||||
else {
|
||||
return parts === protectedPart;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
scope.setRandomSupply = function(supply){
|
||||
randomSupply = supply;
|
||||
modifiedAudioAPI.setRandomSupply(supply);
|
||||
|
@ -163,15 +184,15 @@
|
|||
scope.changedFunctions = {
|
||||
getContext: {
|
||||
type: "context",
|
||||
getStatus: function(obj, status){
|
||||
if (hasType(status, "internal")){
|
||||
getStatus: function(obj, status, prefs){
|
||||
if (status.internal){
|
||||
return {
|
||||
mode: "allow",
|
||||
type: status.type,
|
||||
active: false
|
||||
};
|
||||
}
|
||||
else if (hasType(status, "context") || hasType(status, "input")){
|
||||
else if (getProtectedPartChecker(prefs, status.url)("input")){
|
||||
return {
|
||||
mode: status.mode,
|
||||
type: status.type,
|
||||
|
@ -197,10 +218,11 @@
|
|||
},
|
||||
toDataURL: {
|
||||
type: "readout",
|
||||
getStatus: function(obj, status){
|
||||
getStatus: function(obj, status, prefs){
|
||||
const protectedPartChecker = getProtectedPartChecker(prefs, status.url);
|
||||
status = Object.create(status);
|
||||
status.active = hasType(status, "readout");
|
||||
if (!status.active && hasType(status, "input")){
|
||||
status.active = protectedPartChecker("readout");
|
||||
if (!status.active && protectedPartChecker("input")){
|
||||
var contextType = canvasContextType.get(obj);
|
||||
status.active = contextType !== "2d";
|
||||
}
|
||||
|
@ -227,10 +249,11 @@
|
|||
},
|
||||
toBlob: {
|
||||
type: "readout",
|
||||
getStatus: function(obj, status){
|
||||
getStatus: function(obj, status, prefs){
|
||||
const protectedPartChecker = getProtectedPartChecker(prefs, status.url);
|
||||
status = Object.create(status);
|
||||
status.active = hasType(status, "readout");
|
||||
if (!status.active && hasType(status, "input")){
|
||||
status.active = protectedPartChecker("readout");
|
||||
if (!status.active && protectedPartChecker("input")){
|
||||
var contextType = canvasContextType.get(obj);
|
||||
status.active = contextType !== "2d";
|
||||
}
|
||||
|
@ -258,10 +281,11 @@
|
|||
},
|
||||
mozGetAsFile: {
|
||||
type: "readout",
|
||||
getStatus: function(obj, status){
|
||||
getStatus: function(obj, status, prefs){
|
||||
const protectedPartChecker = getProtectedPartChecker(prefs, status.url);
|
||||
status = Object.create(status);
|
||||
status.active = hasType(status, "readout");
|
||||
if (!status.active && hasType(status, "input")){
|
||||
status.active = protectedPartChecker("readout");
|
||||
if (!status.active && protectedPartChecker("input")){
|
||||
var contextType = canvasContextType.get(obj);
|
||||
status.active = contextType !== "2d";
|
||||
}
|
||||
|
@ -288,9 +312,10 @@
|
|||
},
|
||||
getImageData: {
|
||||
type: "readout",
|
||||
getStatus: function(obj, status){
|
||||
getStatus: function(obj, status, prefs){
|
||||
const protectedPartChecker = getProtectedPartChecker(prefs, status.url);
|
||||
status = Object.create(status);
|
||||
status.active = hasType(status, "readout");
|
||||
status.active = protectedPartChecker("readout");
|
||||
return status;
|
||||
},
|
||||
object: "CanvasRenderingContext2D",
|
||||
|
@ -322,9 +347,10 @@
|
|||
},
|
||||
isPointInPath: {
|
||||
type: "readout",
|
||||
getStatus: function(obj, status){
|
||||
getStatus: function(obj, status, prefs){
|
||||
const protectedPartChecker = getProtectedPartChecker(prefs, status.url);
|
||||
status = Object.create(status);
|
||||
status.active = hasType(status, "readout");
|
||||
status.active = protectedPartChecker("readout");
|
||||
return status;
|
||||
},
|
||||
object: "CanvasRenderingContext2D",
|
||||
|
@ -348,9 +374,10 @@
|
|||
},
|
||||
isPointInStroke: {
|
||||
type: "readout",
|
||||
getStatus: function(obj, status){
|
||||
getStatus: function(obj, status, prefs){
|
||||
const protectedPartChecker = getProtectedPartChecker(prefs, status.url);
|
||||
status = Object.create(status);
|
||||
status.active = hasType(status, "readout");
|
||||
status.active = protectedPartChecker("readout");
|
||||
return status;
|
||||
},
|
||||
object: "CanvasRenderingContext2D",
|
||||
|
@ -374,9 +401,10 @@
|
|||
},
|
||||
fillText: {
|
||||
type: "input",
|
||||
getStatus: function(obj, status){
|
||||
getStatus: function(obj, status, prefs){
|
||||
const protectedPartChecker = getProtectedPartChecker(prefs, status.url);
|
||||
status = Object.create(status);
|
||||
status.active = hasType(status, "input");
|
||||
status.active = protectedPartChecker("input");
|
||||
return status;
|
||||
},
|
||||
object: "CanvasRenderingContext2D",
|
||||
|
@ -409,9 +437,10 @@
|
|||
},
|
||||
strokeText: {
|
||||
type: "input",
|
||||
getStatus: function(obj, status){
|
||||
getStatus: function(obj, status, prefs){
|
||||
const protectedPartChecker = getProtectedPartChecker(prefs, status.url);
|
||||
status = Object.create(status);
|
||||
status.active = hasType(status, "input");
|
||||
status.active = protectedPartChecker("input");
|
||||
return status;
|
||||
},
|
||||
object: "CanvasRenderingContext2D",
|
||||
|
@ -444,9 +473,10 @@
|
|||
},
|
||||
readPixels: {
|
||||
type: "readout",
|
||||
getStatus: function(obj, status){
|
||||
getStatus: function(obj, status, prefs){
|
||||
const protectedPartChecker = getProtectedPartChecker(prefs, status.url);
|
||||
status = Object.create(status);
|
||||
status.active = hasType(status, "readout") || hasType(status, "input");
|
||||
status.active = protectedPartChecker(["readout", "input"]);
|
||||
return status;
|
||||
},
|
||||
object: ["WebGLRenderingContext", "WebGL2RenderingContext"],
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue