From 580450b4630087028f93dbeb856b73e16a95a204 Mon Sep 17 00:00:00 2001 From: hackademix Date: Thu, 19 Jul 2018 01:04:35 +0200 Subject: Refactor ContentMetadata into ResponseMetaData. --- src/bg/RequestUtil.js | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'src/bg/RequestUtil.js') 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 = []; -- cgit v1.2.3