diff options
author | hackademix <giorgio@maone.net> | 2019-02-25 22:22:13 +0100 |
---|---|---|
committer | hackademix <giorgio@maone.net> | 2019-02-25 22:22:13 +0100 |
commit | 881101334654012dd2289b5a73f123bb5d55a462 (patch) | |
tree | d1a6e0541beadeb98d42ba1b3d2638a33c705d2b | |
parent | ee895dd3e5e9fd743f6980f57008ce28b71c3bb0 (diff) |
Generate code view widget for first inline script with global license too.
-rw-r--r-- | main_background.js | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/main_background.js b/main_background.js index ebf9358..7bbc237 100644 --- a/main_background.js +++ b/main_background.js @@ -1053,13 +1053,15 @@ async function editHtml(html, documentUrl, tabId, frameId, whitelisted){ let findLine = finder => finder.test(html) && html.substring(0, finder.lastIndex).split(/\n/).length || 0; if (read_metadata(meta_element) || license) { console.log("Valid license for intrinsic events found"); - let line = 0; + let line, extras; if (meta_element) { line = findLine(/id\s*=\s*['"]?LibreJS-info\b/gi); + extras = "(0)"; } else if (license) { line = html.substring(0, html.indexOf(first_script_src)).split(/\n/).length; + extras = "\n" + encodeURIComponent(first_script_src); } - let viewUrl = line ? `view-source:${documentUrl}#line${line}(<${meta_element ? meta_element.tagName : "SCRIPT"}>)(0)` : url; + let viewUrl = line ? `view-source:${documentUrl}#line${line}(<${meta_element ? meta_element.tagName : "SCRIPT"}>)${extras}` : url; addReportEntry(tabId, url, {url, "accepted":[viewUrl, `Global license for the page: ${license}`]}); // Do not process inline scripts scripts = []; |