mirror of
https://github.com/kkapsner/CanvasBlocker
synced 2024-11-11 07:38:58 +01:00
63 lines
1.8 KiB
JavaScript
63 lines
1.8 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("./modifiedNavigatorAPI", {});
|
|
}
|
|
|
|
const {checkerWrapper, setGetterProperties, getStatusByFlag} = require("./modifiedAPIFunctions");
|
|
const extension = require("./extension");
|
|
const navigator = require("./navigator");
|
|
|
|
let cookieStoreId = false;
|
|
scope.setCookieStoreId = function(newCookieStoreId){
|
|
if (typeof newCookieStoreId === "string"){
|
|
cookieStoreId = (
|
|
newCookieStoreId !== "" &&
|
|
newCookieStoreId !== "firefox-default"
|
|
)? newCookieStoreId: "";
|
|
}
|
|
};
|
|
function getCookieStoreId(){
|
|
while (cookieStoreId === false){
|
|
extension.waitSync("to wait for cookie store id");
|
|
}
|
|
return cookieStoreId;
|
|
}
|
|
|
|
scope.changedGetters = navigator.allProperties.map(function(property){
|
|
return {
|
|
objectGetters: [function(window){return window.Navigator && window.Navigator.prototype;}],
|
|
name: property,
|
|
getterGenerator: function(checker){
|
|
const temp = {
|
|
get [property](){
|
|
return checkerWrapper(checker, this, arguments, function(args, check){
|
|
const {notify, original} = check;
|
|
const originalValue = original.call(this, ...args);
|
|
const returnValue = navigator.getNavigatorValue(property, getCookieStoreId);
|
|
if (originalValue !== returnValue){
|
|
notify("fakedNavigatorReadout");
|
|
}
|
|
return returnValue;
|
|
});
|
|
}
|
|
};
|
|
return Object.getOwnPropertyDescriptor(temp, property).get;
|
|
}
|
|
};
|
|
});
|
|
|
|
setGetterProperties(scope.changedGetters, {
|
|
type: "readout",
|
|
getStatus: getStatusByFlag("protectNavigator"),
|
|
api: "navigator"
|
|
});
|
|
}()); |