1
0
mirror of https://github.com/kkapsner/CanvasBlocker synced 2024-11-10 23:28:51 +01:00
CanvasBlocker/lib/modifiedAPI.js

45 lines
1.4 KiB
JavaScript
Raw Normal View History

/* 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";
2019-11-28 01:26:35 +01:00
let scope;
2017-06-25 22:33:12 +02:00
if ((typeof exports) !== "undefined"){
scope = exports;
}
else {
2019-03-12 22:24:23 +01:00
scope = require.register("./modifiedAPI", {});
2017-06-25 22:33:12 +02:00
}
2019-03-13 08:08:36 +01:00
const randomSupplyCallbacks = [];
2017-06-25 22:33:12 +02:00
scope.setRandomSupply = function(supply){
2019-03-13 08:08:36 +01:00
randomSupplyCallbacks.forEach(function(callback){
callback(supply);
});
};
2019-03-13 08:08:36 +01:00
scope.changedFunctions = {};
2018-07-13 16:58:13 +02:00
2018-08-27 00:23:19 +02:00
scope.changedGetters = [];
2018-07-13 16:58:13 +02:00
function appendModified(collection){
2019-03-13 08:08:36 +01:00
if (collection.setRandomSupply){
randomSupplyCallbacks.push(collection.setRandomSupply);
}
2018-07-13 16:58:13 +02:00
Object.keys(collection.changedFunctions || {}).forEach(function(key){
scope.changedFunctions[key] = collection.changedFunctions[key];
});
2018-08-27 00:23:19 +02:00
(collection.changedGetters || []).forEach(function(changedGetter){
scope.changedGetters.push(changedGetter);
2018-07-13 16:58:13 +02:00
});
}
2019-03-13 08:08:36 +01:00
appendModified(require("./modifiedCanvasAPI"));
appendModified(require("./modifiedAudioAPI"));
appendModified(require("./modifiedHistoryAPI"));
appendModified(require("./modifiedWindowAPI"));
2019-03-13 08:08:36 +01:00
appendModified(require("./modifiedDOMRectAPI"));
appendModified(require("./modifiedTextMetricsAPI"));
2019-02-27 23:49:00 +01:00
appendModified(require("./modifiedNavigatorAPI"));
appendModified(require("./modifiedScreenAPI"));
}());