1
0
mirror of https://github.com/kkapsner/CanvasBlocker synced 2024-11-09 22:58:52 +01:00
CanvasBlocker/lib/modifiedHistoryAPI.js

55 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;
if ((typeof exports) !== "undefined"){
scope = exports;
}
else {
2019-03-12 22:24:23 +01:00
scope = require.register("./modifiedHistoryAPI", {});
}
2019-12-10 15:07:22 +01:00
const {checkerWrapper, setGetterProperties} = require("./modifiedAPIFunctions");
scope.changedGetters = [
{
objectGetters: [function(window){return window.History && window.History.prototype;}],
name: "length",
getterGenerator: function(checker){
const temp = {
get length(){
return checkerWrapper(checker, this, arguments, function(args, check){
const {prefs, notify, window, original} = check;
const originalLength = original.call(this, ...args);
const threshold = prefs("historyLengthThreshold", window.location);
if (originalLength > threshold){
notify("fakedHistoryReadout");
return threshold;
}
else {
return originalLength;
}
});
}
};
return Object.getOwnPropertyDescriptor(temp, "length").get;
}
}
];
function getStatus(obj, status){
status = Object.create(status);
status.active = true;
return status;
}
2019-12-10 15:07:22 +01:00
setGetterProperties(scope.changedGetters, {
type: "readout",
getStatus: getStatus,
api: "history"
});
}());