aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhackademix <giorgio@maone.net>2018-08-06 22:34:41 +0200
committerhackademix <giorgio@maone.net>2018-08-06 22:34:41 +0200
commit2cb91e36eed08993c0a9ca693f910b153705da65 (patch)
tree1eec00d3b44405837ae0e8a0fff2d30665473a0e
parenta6dce3bccda7ff9406c2dd9255c25baefad70225 (diff)
Fixed regression, commit #13ea9430ff74174b0e1043119e4d855259b62a30 breaking reporting when intrinsic scripts are detected.
-rw-r--r--main_background.js12
1 files changed, 9 insertions, 3 deletions
diff --git a/main_background.js b/main_background.js
index 62ff18e..c409959 100644
--- a/main_background.js
+++ b/main_background.js
@@ -750,11 +750,11 @@ function license_read(script_src, name, external = false){
* Asynchronous function, returns the final edited script as a string,
* or an array containing it and the index, if the latter !== -1
*/
-async function get_script(response, url, tabId, whitelisted = false, index = -1) {
+async function get_script(response, url, tabId = -1, whitelisted = false, index = -1) {
function result(scriptSource) {
return index === -1 ? scriptSource : [scriptSource, index];
}
- let report = unused_data[tabId] || (unused_data[tabId] = createReport({url, tabId}));
+
let scriptName = url.split("/").pop();
if (whitelisted) {
@@ -767,8 +767,14 @@ async function get_script(response, url, tabId, whitelisted = false, index = -1)
return result(`/* LibreJS: script whitelisted by user preference. */\n${response}`);
}
let [verdict, editedSource, reason] = license_read(response, scriptName, index === -2);
+
+ if (tabId < 0) {
+ return result(verdict ? response : editedSource);
+ }
+
let sourceHash = hash(response);
let domain = get_domain(url);
+ let report = unused_data[tabId] || (unused_data[tabId] = createReport({url, tabId}));
let blockedCount = report.blocked.length + report.blacklisted.length;
dbg_print(`amt. blocked on page: ${blockedCount}`);
if (blockedCount > 0 || !verdict) {
@@ -1012,7 +1018,7 @@ function edit_html(html,url,tabid,wl){
// "i" is an index in html_doc.all
// "j" is an index in intrinsic_events
function edit_event(src,i,j,name){
- var edited = get_script(src, name, tabid);
+ var edited = get_script(src, name);
edited.then(function(){
html_doc.all[i].attributes[intrinsic_events[j]].value = edited[0];
});