diff options
author | Yuchen Pei <hi@ypei.me> | 2022-09-21 12:14:51 +1000 |
---|---|---|
committer | Yuchen Pei <hi@ypei.me> | 2022-09-21 12:14:51 +1000 |
commit | a7c7afb09afe2d4e9e26fdeedaaefde6e3050188 (patch) | |
tree | 62926e0f28aa6b9cd8e1c8da78c59ffc35e5a94d | |
parent | a9813757676dfbbbc58370e0ff1251806cf1435a (diff) |
refactoring getScript
-rw-r--r-- | main_background.js | 12 |
1 files 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}` ); } |