1
0
mirror of https://github.com/kkapsner/CanvasBlocker synced 2024-11-10 23:28:51 +01:00
CanvasBlocker/lib/modifiedAPI.js
kkapsner 640bd36b86 Added SVG protection
Fixes #589 and fixes #590
2022-01-30 10:59:41 +01:00

46 lines
1.4 KiB
JavaScript

/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
(function(){
"use strict";
let scope;
if ((typeof exports) !== "undefined"){
scope = exports;
}
else {
scope = require.register("./modifiedAPI", {});
}
const randomSupplyCallbacks = [];
scope.setRandomSupply = function(supply){
randomSupplyCallbacks.forEach(function(callback){
callback(supply);
});
};
scope.changedFunctions = {};
scope.changedGetters = [];
function appendModified(collection){
if (collection.setRandomSupply){
randomSupplyCallbacks.push(collection.setRandomSupply);
}
Object.keys(collection.changedFunctions || {}).forEach(function(key){
scope.changedFunctions[key] = collection.changedFunctions[key];
});
(collection.changedGetters || []).forEach(function(changedGetter){
scope.changedGetters.push(changedGetter);
});
}
appendModified(require("./modifiedCanvasAPI"));
appendModified(require("./modifiedAudioAPI"));
appendModified(require("./modifiedHistoryAPI"));
appendModified(require("./modifiedWindowAPI"));
appendModified(require("./modifiedDOMRectAPI"));
appendModified(require("./modifiedSVGAPI"));
appendModified(require("./modifiedTextMetricsAPI"));
appendModified(require("./modifiedNavigatorAPI"));
appendModified(require("./modifiedScreenAPI"));
}());