minify injected proxy blocking code, add some description of what the logging option does, have the javascript injected into each visited page remove its own <script> tag
This commit is contained in:
parent
eefd6bde58
commit
4ccae4ba2f
7 changed files with 55 additions and 8 deletions
|
@ -57,6 +57,8 @@ for future inclusion:
|
|||
* Blocking property accesses on non-global structures through an additional
|
||||
level of interposition on runtime created objects.
|
||||
* Adding new Web API standards into the code base.
|
||||
* Extend blocking to properties and events (currently only functions and
|
||||
methods are interposed on).
|
||||
|
||||
|
||||
Background
|
||||
|
|
|
@ -12,7 +12,13 @@
|
|||
<input type="checkbox"
|
||||
v-model="shouldLog"
|
||||
@change="shouldLogChanged">
|
||||
|
||||
Log blocked functionality?
|
||||
|
||||
<p class="help-block">
|
||||
Enabling logging will print information about each
|
||||
blocked method to the console, for each domain.
|
||||
</p>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -1,12 +1,13 @@
|
|||
/*jslint es6: true, browser: true*/
|
||||
/*global chrome, window, Cookies*/
|
||||
/*global window, Cookies*/
|
||||
// This script file runs in the context of the extension, and mainly
|
||||
// exists to inject the proxy blocking code into content frames.
|
||||
(function () {
|
||||
"use strict";
|
||||
|
||||
const script = document.createElement('script');
|
||||
const rootElm = document.head || document.documentElement;
|
||||
const doc = window.document;
|
||||
const script = doc.createElement('script');
|
||||
const rootElm = doc.head || doc.documentElement;
|
||||
|
||||
const standardsCookieKey = "wam-standards";
|
||||
const {packingLib, standards} = window.WEB_API_MANAGER;
|
||||
|
@ -28,6 +29,6 @@
|
|||
###-INJECTED-PROXY-BLOCKING-CODE-###
|
||||
`;
|
||||
|
||||
script.appendChild(document.createTextNode(code));
|
||||
script.appendChild(doc.createTextNode(code));
|
||||
rootElm.appendChild(script);
|
||||
}());
|
|
@ -12,6 +12,12 @@
|
|||
const standardDefinitions = settings.standards;
|
||||
const hostName = window.location.hostname;
|
||||
|
||||
// Its possible that the Web API removal code will block direct references
|
||||
// to the following methods, so grab references to them before the
|
||||
// DOM is instrumented (and their references are possibly blocked).
|
||||
const removeChild = window.Element.prototype.removeChild;
|
||||
const getElementsByTagName = window.document.getElementsByTagName;
|
||||
|
||||
const defaultFunction = function () {};
|
||||
const funcPropNames = Object.getOwnPropertyNames(defaultFunction);
|
||||
const unconfigurablePropNames = funcPropNames.filter(function (propName) {
|
||||
|
@ -150,4 +156,10 @@
|
|||
};
|
||||
|
||||
featuresToBlock.forEach(blockFeatureAtKeyPath);
|
||||
|
||||
// Last, remove the script tag containing this code from the document,
|
||||
// so that the structure of the page looks like what the page author
|
||||
// expects / intended.
|
||||
const scriptTags = getElementsByTagName.call(window.document, "script");
|
||||
removeChild.call(scriptTags[0].parentNode, scriptTags[0]);
|
||||
}());
|
|
@ -1,5 +1,6 @@
|
|||
const gulp = require('gulp');
|
||||
const fs = require('fs');
|
||||
const gulp = require("gulp");
|
||||
const fs = require("fs");
|
||||
const UglifyJS = require("uglify-es");
|
||||
|
||||
gulp.task('default', function () {
|
||||
|
||||
|
@ -48,9 +49,11 @@ gulp.task('default', function () {
|
|||
|
||||
const proxyBlockSrcWOComments = stripCommentsFromSource(proxyBlockSrc);
|
||||
const instrumentSrcWOComments = stripCommentsFromSource(instrumentSrc);
|
||||
|
||||
const proxyBlockSrcWithHeader = "/** This code is a minified version of content_scripts/src/proxyblock.js **/\n" + proxyBlockSrcWOComments;
|
||||
const instrumentSrcWithProxyInjected = instrumentSrcWOComments.replace(
|
||||
"###-INJECTED-PROXY-BLOCKING-CODE-###",
|
||||
proxyBlockSrcWOComments
|
||||
UglifyJS.minify(proxyBlockSrcWithHeader, {mangle: false}).code
|
||||
);
|
||||
|
||||
fs.writeFileSync("content_scripts/dist/instrument.js", builtScriptComment + instrumentSrcWithProxyInjected);
|
||||
|
|
22
package-lock.json
generated
22
package-lock.json
generated
|
@ -125,6 +125,12 @@
|
|||
"integrity": "sha1-uI+UqCzzi4eR1YBG6kAprYjKmdE=",
|
||||
"dev": true
|
||||
},
|
||||
"commander": {
|
||||
"version": "2.11.0",
|
||||
"resolved": "https://registry.npmjs.org/commander/-/commander-2.11.0.tgz",
|
||||
"integrity": "sha512-b0553uYA5YAEGgyYIGYROzKQ7X5RAqedkfjiZxwi0kL1g3bOaBNNZfYkzt/CL0umgD5wc9Jec2FbB98CjkMRvQ==",
|
||||
"dev": true
|
||||
},
|
||||
"concat-map": {
|
||||
"version": "0.0.1",
|
||||
"resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
|
||||
|
@ -1337,6 +1343,12 @@
|
|||
"integrity": "sha1-P/IfGYytIXX587eBhT/ZTQ0ZtZA=",
|
||||
"dev": true
|
||||
},
|
||||
"source-map": {
|
||||
"version": "0.5.7",
|
||||
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz",
|
||||
"integrity": "sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w=",
|
||||
"dev": true
|
||||
},
|
||||
"sparkles": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/sparkles/-/sparkles-1.0.0.tgz",
|
||||
|
@ -1437,6 +1449,16 @@
|
|||
"integrity": "sha1-dkpaEa9QVhkhsTPztE5hhofg9cM=",
|
||||
"dev": true
|
||||
},
|
||||
"uglify-es": {
|
||||
"version": "3.1.3",
|
||||
"resolved": "https://registry.npmjs.org/uglify-es/-/uglify-es-3.1.3.tgz",
|
||||
"integrity": "sha512-Nuo5gkv/Q6PmLa+Ui2LvK+87YdMAcuXfRIWF0uVfkHVSfpT3Ue0euCSu4t0b8xv4Bt05lmXUT8bLI9OmnyPj8A==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"commander": "2.11.0",
|
||||
"source-map": "0.5.7"
|
||||
}
|
||||
},
|
||||
"unc-path-regex": {
|
||||
"version": "0.1.2",
|
||||
"resolved": "https://registry.npmjs.org/unc-path-regex/-/unc-path-regex-0.1.2.tgz",
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
"author": "",
|
||||
"license": "ISC",
|
||||
"devDependencies": {
|
||||
"gulp": "^3.9.1"
|
||||
"gulp": "^3.9.1",
|
||||
"uglify-es": "^3.1.3"
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue