aboutsummaryrefslogtreecommitdiff
path: root/content
diff options
context:
space:
mode:
authorYuchen Pei <hi@ypei.me>2022-09-22 12:54:07 +1000
committerYuchen Pei <hi@ypei.me>2022-09-22 12:54:07 +1000
commitaf903283f05e628ca2e25dfb8e2745baee945b7f (patch)
treef7eb4df454bf61d4299cde47e05daaa9d95f3301 /content
parentd3d4a8675626671f728ba64a6f85ef07d377c521 (diff)
clean up external license checking a bit
Diffstat (limited to 'content')
-rw-r--r--content/externalLicenseChecker.js13
1 files changed, 12 insertions, 1 deletions
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);