diff options
author | hackademix | 2018-07-19 01:04:35 +0200 |
---|---|---|
committer | hackademix | 2018-07-19 01:04:35 +0200 |
commit | 580450b4630087028f93dbeb856b73e16a95a204 (patch) | |
tree | a8612692c82c9a874f239acc8c0a49494a1f745e /src/bg | |
parent | 091056692685779a9f4c87f1ec9884fa4804b708 (diff) | |
download | noscript-580450b4630087028f93dbeb856b73e16a95a204.tar.gz noscript-580450b4630087028f93dbeb856b73e16a95a204.tar.xz noscript-580450b4630087028f93dbeb856b73e16a95a204.zip |
Refactor ContentMetadata into ResponseMetaData.
Diffstat (limited to 'src/bg')
-rw-r--r-- | src/bg/RequestUtil.js | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/src/bg/RequestUtil.js b/src/bg/RequestUtil.js index 5a52975..629f270 100644 --- a/src/bg/RequestUtil.js +++ b/src/bg/RequestUtil.js @@ -47,8 +47,8 @@ var RequestUtil = { - getContentMetaData(request) { - return request.content || (request.content = new ContentMetaData(request)); + getResponseMetaData(request) { + return request.response || (request.response = new ResponseMetaData(request)); }, async executeOnStart(request, details) { @@ -63,12 +63,14 @@ return; } } - let content = this.getContentMetaData(request); - if (content.disposition) { - debug("Skipping execute on start of %s %o", url, content); + + let response = this.getResponseMetaData(request); + let {contentType, contentDisposition} = response; + if (contentDisposition) { + debug("Skipping execute on start of %s %o", url, response); return; } - debug("Injecting script on start in %s (%o)", url, content); + debug("Injecting script on start in %s (%o)", url, response); let scripts = pendingRequests.get(requestId); let scriptKey = JSON.stringify(details); @@ -80,12 +82,12 @@ return; } - if (xmlFeedOrImage.test(content.type) && !/\/svg\b/i.test(content.type)) return; + if (xmlFeedOrImage.test(contentType) && !/\/svg\b/i.test(contentType)) return; if (typeof brokenXMLOnLoad === "undefined") { brokenXMLOnLoad = await (async () => parseInt((await browser.runtime.getBrowserInfo()).version) < 61)(); } - let mustCheckFeed = brokenXMLOnLoad && frameId === 0 && rawXml.test(content.type); + let mustCheckFeed = brokenXMLOnLoad && frameId === 0 && rawXml.test(contentType); debug("mustCheckFeed = %s, brokenXMLOnLoad = %s", mustCheckFeed, brokenXMLOnLoad); let filter = browser.webRequest.filterResponseData(requestId); let buffer = []; |