From af903283f05e628ca2e25dfb8e2745baee945b7f Mon Sep 17 00:00:00 2001 From: Yuchen Pei Date: Thu, 22 Sep 2022 12:54:07 +1000 Subject: clean up external license checking a bit --- content/externalLicenseChecker.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'content/externalLicenseChecker.js') diff --git a/content/externalLicenseChecker.js b/content/externalLicenseChecker.js index 70a763c..91377b3 100644 --- a/content/externalLicenseChecker.js +++ b/content/externalLicenseChecker.js @@ -21,8 +21,14 @@ */ "use strict"; { + // Find and fetch the url to the web labels table, and returns the + // license info in the table as a map from the script url to + // { script: {url, label}, + // licenseLinks: [{url, label}], + // sources: [{url, label}] } + // + // see https://www.gnu.org/software/librejs/free-your-javascript.html#step3 const fetchWebLabels = async args => { - // see https://www.gnu.org/software/librejs/free-your-javascript.html#step3 const { map, cache } = args; const link = document.querySelector(`link[rel="jslicense"], link[data-jslicense="1"], a[rel="jslicense"], a[data-jslicense="1"]`); const baseURL = link ? link.href : cache.webLabels && new URL(cache.webLabels.href, document.baseURI); @@ -69,6 +75,11 @@ } const handlers = { + // Look up the script url in the web labels and return it if found, + // otherwise return undefined. The found value is of the format + // { script: {url, label}, + // licenseLinks: [{url, label}], + // sources: [{url, label}] } async checkLicensedScript(m) { const { url, cache } = m; const licensedScripts = await fetchLicenseInfo(cache); -- cgit v1.2.3