diff --git a/.eslintrc.json b/.eslintrc.json index 0522970..0cddb96 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -21,7 +21,7 @@ "constructor-super": "warn", "eqeqeq": "error", "max-len": ["warn", {"code": 120, "tabWidth": 4}], - "max-lines": ["warn", {"max": 400, "skipBlankLines": true, "skipComments": true}], + "max-lines": ["warn", {"max": 500, "skipBlankLines": true, "skipComments": true}], "max-params": ["warn", 4], "no-const-assign": "warn", "no-this-before-super": "warn", diff --git a/lib/modifiedAPIFunctions.js b/lib/modifiedAPIFunctions.js index 3a21eeb..9b7a31a 100644 --- a/lib/modifiedAPIFunctions.js +++ b/lib/modifiedAPIFunctions.js @@ -24,4 +24,30 @@ check.notify("blocked"); return undefined; }; + + scope.setFunctionProperties = function setFunctionProperties(functions, data){ + Object.keys(functions).forEach(function(key){ + var func = functions[key]; + ["type", "api", "getStatus"].forEach(function(property){ + if (data[property] && !func[property]){ + func[property] = data[property]; + } + }); + }); + }; + + scope.setGetterProperties = function setGetterProperties(getters, data){ + getters.forEach(function(getter){ + ["type", "api", "getStatus"].forEach(function(property){ + if (data[property] && !getter[property]){ + getter[property] = data[property]; + } + }); + }); + }; + + scope.setProperties = function setProperties(functions, getters, data){ + scope.setFunctionProperties(functions, data); + scope.setGetterProperties(getters, data); + }; }()); \ No newline at end of file diff --git a/lib/modifiedDOMRectAPI.js b/lib/modifiedDOMRectAPI.js index bfd167b..efce4dd 100644 --- a/lib/modifiedDOMRectAPI.js +++ b/lib/modifiedDOMRectAPI.js @@ -13,7 +13,7 @@ scope = window.scope.modifiedDOMRectAPI; } - const {checkerWrapper} = require("./modifiedAPIFunctions"); + const {checkerWrapper, setProperties: setProperties} = require("./modifiedAPIFunctions"); const {byteArrayToString: hash} = require("./hash"); const getWrapped = require("sdk/getWrapped"); @@ -89,9 +89,6 @@ scope.changedFunctions = { getClientRects: { - type: "readout", - api: "domRect", - getStatus: getStatus, object: ["Range", "Element"], fakeGenerator: function(checker){ return function getClientRects(){ @@ -107,9 +104,6 @@ } }, getBoundingClientRect: { - type: "readout", - api: "domRect", - getStatus: getStatus, object: ["Range", "Element"], fakeGenerator: function(checker){ return function getBoundingClientRect(){ @@ -124,9 +118,6 @@ } }, getBounds: { - type: "readout", - api: "domRect", - getStatus: getStatus, object: ["DOMQuad"], fakeGenerator: function(checker){ return function getBounds(){ @@ -140,9 +131,6 @@ } }, getBBox: { - type: "readout", - api: "domRect", - getStatus: getStatus, object: ["SVGGraphicsElement"], fakeGenerator: function(checker){ return function getBBox(){ @@ -156,9 +144,6 @@ } }, getExtentOfChar: { - type: "readout", - api: "domRect", - getStatus: getStatus, object: ["SVGTextContentElement"], fakeGenerator: function(checker){ return function getBBox(){ @@ -421,16 +406,15 @@ } ]; - function getStatus(obj, status, prefs){ status = Object.create(status); status.active = prefs("protectDOMRect", status.url); return status; } - scope.changedGetters.forEach(function(changedGetter){ - changedGetter.type = "readout"; - changedGetter.getStatus = getStatus; - changedGetter.api = "domRect"; + setProperties(scope.changedFunctions, scope.changedGetters, { + type: "readout", + getStatus: getStatus, + api: "domRect" }); }()); \ No newline at end of file diff --git a/options/options.js b/options/options.js index 91fa1fd..71eae3e 100644 --- a/options/options.js +++ b/options/options.js @@ -306,7 +306,7 @@ else { return false; } - } + }; } let hideChangeListeners = [];