bug-librejs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] Support multiple scripts per row in weblabels table


From: Andreas Gattringer
Subject: [PATCH] Support multiple scripts per row in weblabels table
Date: Mon, 26 Aug 2024 11:35:52 +0000

I want to use the same type of tables as described in the
"Web Labels: Support multiple scripts per row" feature request.

So here a simply patch that ads support for multiple scripts per row.

I hope this can be added,
Thank You

---
 content/externalLicenseChecker.js | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/content/externalLicenseChecker.js b/content/externalLicenseChecker.js
index f59eed8..69a3386 100644
--- a/content/externalLicenseChecker.js
+++ b/content/externalLicenseChecker.js
@@ -46,15 +46,16 @@
doc.head.appendChild(doc.createElement("base")).href = webLabelsUrl;
       }
       const link = a => ({ url: a.href, label: a.textContent });
-      const firstLink = parent => link(parent.querySelector("a"));
const allLinks = parent => Array.prototype.map.call(parent.querySelectorAll("a"), link); for (const row of doc.querySelectorAll("table#jslicense-labels1 > tbody > tr")) {
         try {
           const cols = row.querySelectorAll("td");
-          const script = firstLink(cols[0]);
+          const scripts = allLinks(cols[0]);
           const licenseLinks = allLinks(cols[1]);
           const sources = cols[2] ? allLinks(cols[2]) : [];
-          map.set(script.url, { script, licenseLinks, sources });
+          scripts.forEach((script) => {
+            map.set(script.url, { script, licenseLinks, sources });
+          });
         } catch (e) {
console.error("LibreJS: error parsing Web Labels at %s, row %s", webLabelsUrl, row.innerHTML, e);
         }
--
2.46.0





reply via email to

[Prev in Thread] Current Thread [Next in Thread]