From a7c7afb09afe2d4e9e26fdeedaaefde6e3050188 Mon Sep 17 00:00:00 2001 From: Yuchen Pei Date: Wed, 21 Sep 2022 12:14:51 +1000 Subject: refactoring getScript --- main_background.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/main_background.js b/main_background.js index 3d66618..d37f2ba 100644 --- a/main_background.js +++ b/main_background.js @@ -735,16 +735,16 @@ async function getScript(scriptSrc, url, tabId = -1, whitelisted = false, return return result(`/* LibreJS: script whitelisted by user preference. */\n${scriptSrc}`); } - let [verdict, editedSource, reason] = licenseRead(scriptSrc, scriptName, isExternal); + let [accepted, editedSource, reason] = licenseRead(scriptSrc, scriptName, isExternal); if (tabId < 0) { - return result(verdict ? scriptSrc : editedSource); + return result(editedSource); } let domain = get_domain(url); let report = activityReports[tabId] || (activityReports[tabId] = await createReport({ tabId })); - updateBadge(tabId, report, !verdict); - let category = await addReportEntry(tabId, { 'url': domain, [verdict ? 'accepted' : 'blocked']: [url, reason] }); + updateBadge(tabId, report, !accepted); + let category = await addReportEntry(tabId, { 'url': domain, [accepted ? 'accepted' : 'blocked']: [url, reason] }); switch (category) { case 'blacklisted': { editedSource = `/* LibreJS: script ${category} by user. */`; @@ -756,9 +756,9 @@ async function getScript(scriptSrc, url, tabId = -1, whitelisted = false, return ? scriptSrc : `/* LibreJS: script ${category} by user. */\n${scriptSrc}`); } default: { - let scriptSource = verdict ? scriptSrc : editedSource; + let scriptSource = accepted ? scriptSrc : editedSource; return result(scriptSrc.startsWith('javascript:') - ? (verdict ? scriptSource : `javascript:void(/* ${scriptSource} */)`) + ? (accepted ? scriptSource : `javascript:void(/* ${scriptSource} */)`) : `/* LibreJS: script ${category}. */\n${scriptSource}` ); } -- cgit v1.2.3