From 3f2aca651b85d73c8a217bda927c36bf7e6b43f8 Mon Sep 17 00:00:00 2001 From: hackademix Date: Mon, 6 Aug 2018 22:57:13 +0200 Subject: Fixed report attempts when no tabId is available. --- main_background.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'main_background.js') diff --git a/main_background.js b/main_background.js index c409959..d401b96 100644 --- a/main_background.js +++ b/main_background.js @@ -758,14 +758,17 @@ async function get_script(response, url, tabId = -1, whitelisted = false, index let scriptName = url.split("/").pop(); if (whitelisted) { - let site = ListStore.siteItem(url); - // Accept without reading script, it was explicitly whitelisted - let reason = whitelist.contains(site) - ? `All ${site} whitelisted by user` - : "Address whitelisted by user"; + if (tabId !== -1) { + let site = ListStore.siteItem(url); + // Accept without reading script, it was explicitly whitelisted + let reason = whitelist.contains(site) + ? `All ${site} whitelisted by user` + : "Address whitelisted by user"; addReportEntry(tabId, url, {"whitelisted": [url, reason], url}); + } return result(`/* LibreJS: script whitelisted by user preference. */\n${response}`); } + let [verdict, editedSource, reason] = license_read(response, scriptName, index === -2); if (tabId < 0) { @@ -888,6 +891,7 @@ var ResponseHandler = { */ async post(response) { let {url, type} = response.request; + url = ListStore.urlItem(url); let handle_it = type === "script" ? handle_script : handle_html; return await handle_it(response, response.whitelisted); } -- cgit v1.2.3