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

Improved storage of protected API features

This commit is contained in:
kkapsner 2019-11-11 15:30:11 +01:00
parent 1430b89d55
commit cc776b48de
6 changed files with 73 additions and 37 deletions

View File

@ -251,8 +251,8 @@
if (
funcStatus.active &&
(
!protectedAPIFeatures.hasOwnProperty(name) ||
protectedAPIFeatures[name]
!protectedAPIFeatures.hasOwnProperty(name + " @ " + changedFunction.api) ||
protectedAPIFeatures[name + " @ " + changedFunction.api]
)
){
if (funcStatus.mode === "ask"){
@ -383,8 +383,8 @@
if (
functionStatus.active &&
(
!protectedAPIFeatures.hasOwnProperty(name) ||
protectedAPIFeatures[name]
!protectedAPIFeatures.hasOwnProperty(name + " @ " + changedGetter.api) ||
protectedAPIFeatures[name + " @ " + changedGetter.api]
)
){
switch (functionStatus.mode){

View File

@ -91,44 +91,45 @@
defaultValue: {},
keys: [
{name: "Canvas-API", level: 1},
"getContext",
"getContext @ canvas",
{message: "readout", level: 2},
"toDataURL", "toBlob", "mozGetAsFile", "getImageData",
"isPointInPath", "isPointInStroke",
"toDataURL @ canvas", "toBlob @ canvas", "mozGetAsFile @ canvas", "getImageData @ canvas",
"isPointInPath @ canvas", "isPointInStroke @ canvas",
{message: "input", level: 2},
"fillText", "strokeText",
"fillText @ canvas", "strokeText @ canvas",
{name: "webGL", level: 2},
"readPixels", "getParameter",
"readPixels @ canvas", "getParameter @ canvas",
{name: "Audio-API", level: 1},
"getFloatFrequencyData", "getByteFrequencyData", "getFloatTimeDomainData", "getByteTimeDomainData",
"getChannelData", "copyFromChannel",
"getFrequencyResponse",
"getFloatFrequencyData @ audio", "getByteFrequencyData @ audio",
"getFloatTimeDomainData @ audio", "getByteTimeDomainData @ audio",
"getChannelData @ audio", "copyFromChannel @ audio",
"getFrequencyResponse @ audio",
{name: "History-API", level: 1},
"length",
"length @ history",
{name: "Window-API", level: 1},
"opener",
"name",
"opener @ window",
"name @ window",
{name: "DOMRect-API", level: 1},
"getClientRects",
"getBoundingClientRect",
"getBounds",
"getBBox",
"getExtentOfChar",
"intersectionRect",
"boundingClientRect",
"getClientRects @ domRect",
"getBoundingClientRect @ domRect",
"getBounds @ domRect",
"getBBox @ domRect",
"getExtentOfChar @ domRect",
"intersectionRect @ domRect",
"boundingClientRect @ domRect",
"rootBounds",
{name: "Navigator-API", level: 1},
"appCodeName",
"appName",
"appVersion",
"buildID",
"oscpu",
"platform",
"product",
"productSub",
"userAgent",
"vendor",
"vendorSub"
"appCodeName @ navigator",
"appName @ navigator",
"appVersion @ navigator",
"buildID @ navigator",
"oscpu @ navigator",
"platform @ navigator",
"product @ navigator",
"productSub @ navigator",
"userAgent @ navigator",
"vendor @ navigator",
"vendorSub @ navigator",
],
defaultKeyValue: true
},
@ -356,7 +357,7 @@
},
{
name: "storageVersion",
defaultValue: 0.5,
defaultValue: 0.6,
fixed: true
}
];

View File

@ -12,6 +12,9 @@
else {
scope = require.register("./settingsMigration", {});
}
const settingDefinitions = require("./settingDefinitions");
scope.validVersions = [undefined, 0.1, 0.2, 0.3, 0.4, 0.5];
scope.transitions = {
"": function(oldStorage){
@ -129,7 +132,31 @@
}
}
return newStorage;
},
0.5: function(oldStorage){
var newStorage = {
storageVersion: 0.6
};
if (oldStorage.hasOwnProperty("protectedAPIFeatures")){
const protectedAPIFeatures = {};
const protectedAPIFeaturesKeys = settingDefinitions.filter(function(definition){
return definition.name === "protectedAPIFeatures";
})[0].keys.filter(function(key){
return typeof key === "string";
});
Object.keys(oldStorage.protectedAPIFeatures).forEach(function(key){
const matchingKeys = protectedAPIFeaturesKeys.filter(function(definedKey){
return definedKey.startsWith(key);
});
if (matchingKeys.length){
protectedAPIFeatures[matchingKeys[0]] = oldStorage.protectedAPIFeatures[key];
}
});
newStorage.protectedAPIFeatures = protectedAPIFeatures;
}
return newStorage;
},
};
scope.check = function(storage, {settings, logging, changeValue, urlContainer}){

View File

@ -174,7 +174,9 @@
}
let nameCell = document.createElement("td");
nameCell.textContent = key;
nameCell.textContent = setting.display.replaceKeyPattern?
key.replace(setting.display.replaceKeyPattern, ""):
key;
row.appendChild(nameCell);
let keyType = inputTypes[typeof setting.defaultKeyValue];

View File

@ -298,6 +298,7 @@
},
{
"name": "protectedAPIFeatures",
"replaceKeyPattern": / @ .+$/,
"displayedSection": "Canvas-API",
"displayDependencies": [
{
@ -445,6 +446,7 @@
},
{
"name": "protectedAPIFeatures",
"replaceKeyPattern": / @ .+$/,
"displayedSection": "Audio-API",
"displayDependencies": [
{
@ -542,6 +544,7 @@
settings: [
{
"name": "protectedAPIFeatures",
"replaceKeyPattern": / @ .+$/,
"displayedSection": "History-API",
"displayDependencies": [
{
@ -565,6 +568,7 @@
},
{
"name": "protectedAPIFeatures",
"replaceKeyPattern": / @ .+$/,
"displayedSection": "Window-API",
"displayDependencies": [
{
@ -583,6 +587,7 @@
},
{
"name": "protectedAPIFeatures",
"replaceKeyPattern": / @ .+$/,
"displayedSection": "DOMRect-API",
"displayDependencies": [
{
@ -608,6 +613,7 @@
},
{
"name": "protectedAPIFeatures",
"replaceKeyPattern": / @ .+$/,
"displayedSection": "Navigator-API",
"displayDependencies": [
{

View File

@ -1,6 +1,6 @@
Version 0.5.15:
changes:
-
- improved storage of protected API features
new features:
-