diff options
author | awy <awy@awy.one> | 2025-08-15 03:01:21 +0300 |
---|---|---|
committer | awy <awy@awy.one> | 2025-08-15 03:01:21 +0300 |
commit | a9370a08517668b3e98cc1d0bd42df407a76c220 (patch) | |
tree | 37e7bdb0e76f5495f798e077e45d377c0c3870c0 /data/extensions/jid1-KtlZuoiikVfFew@jetpack/content | |
parent | b73acfe395ea849fcd15c9886a7f4631f2b6f82b (diff) |
Diffstat (limited to 'data/extensions/jid1-KtlZuoiikVfFew@jetpack/content')
4 files changed, 0 insertions, 483 deletions
diff --git a/data/extensions/jid1-KtlZuoiikVfFew@jetpack/content/contactFinder.js b/data/extensions/jid1-KtlZuoiikVfFew@jetpack/content/contactFinder.js deleted file mode 100644 index 439f1b1..0000000 --- a/data/extensions/jid1-KtlZuoiikVfFew@jetpack/content/contactFinder.js +++ /dev/null @@ -1,259 +0,0 @@ -/** -* GNU LibreJS - A browser add-on to block nonfree nontrivial JavaScript. -* * -* Copyright (C) 2017 Nathan Nichols, Loic J. Duros, Nik Nyby -* Copyright (C) 2018 Giorgio Maone -* Copyright (C) 2022 Yuchen Pei -* -* This file is part of GNU LibreJS. -* -* GNU LibreJS is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation, either version 3 of the License, or -* (at your option) any later version. -* -* GNU LibreJS is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with GNU LibreJS. If not, see <http://www.gnu.org/licenses/>. -*/ - -// TO TEST THE CONTACT FINDER: -// - open the manifest.json -// - add a comma after the closing bracket of the key "background" -// - Copy and paste this after it: -/* - "content_scripts": [{ - "matches": ["<all_urls>"], - "js": ["/content/contactFinder.js"], - "css": ["/content/contactFinder.css"] - }] -*/ -// Now, the contact finder will load on every page and you can test it where ever you want. - - -//********************************************************************************************* -(() => { - function debug(format, ...args) { - console.debug(`LibreJS - ${format}`, ...args); - } - - debug("Injecting contact finder in %s", document.URL); - - /** - * contactSearchStrings - * Contains arrays of strings classified by language - * and by degree of certainty. - */ - const CONTACT_FRAGS = - [ - // de - { - 'certain': [ - '^[\\s]*Kontakt os[\\s]*$', - '^[\\s]*Email Os[\\s]*$', - '^[\\s]*Kontakt[\\s]*$' - ], - 'probable': ['^[\\s]Kontakt', '^[\\s]*Email'], - 'uncertain': [ - '^[\\s]*Om Us', - '^[\\s]*Om', - 'Hvem vi er' - ] - }, - // en - { - 'certain': [ - '^[\\s]*Contact Us[\\s]*$', - '^[\\s]*Email Us[\\s]*$', - '^[\\s]*Contact[\\s]*$', - '^[\\s]*Feedback[\\s]*$', - '^[\\s]*Web.?site Feedback[\\s]*$' - ], - 'probable': ['^[\\s]*Contact', '^[\\s]*Email'], - 'uncertain': [ - '^[\\s]*About Us', - '^[\\s]*About', - 'Who we are', - 'Who I am', - 'Company Info', - 'Customer Service' - ] - }, - // es - { - 'certain': [ - '^[\\s]*contáctenos[\\s]*$', - '^[\\s]*Email[\\s]*$' - ], - 'probable': ['^[\\s]contáctenos', '^[\\s]*Email'], - 'uncertain': [ - 'Acerca de nosotros' - ] - }, - // fr - { - 'certain': [ - '^[\\s]*Contactez nous[\\s]*$', - '^[\\s]*(Nous )?contacter[\\s]*$', - '^[\\s]*Email[\\s]*$', - '^[\\s]*Contact[\\s]*$', - '^[\\s]*Commentaires[\\s]*$' - ], - 'probable': ['^[\\s]Contact', '^[\\s]*Email'], - 'uncertain': [ - '^[\\s]*(A|À) propos', - 'Qui nous sommes', - 'Qui suis(-| )?je', - 'Info', - 'Service Client(e|è)le' - ] - } - ]; - - const CONTACT_LINK_LIMIT = 5; - - // Taken from http://emailregex.com/ - const EMAIL_REGEX = - new RegExp(/(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])/g); - //********************************************************************************************* - - function findMatch(link, frag) { - const result = (link.innerText.match(new RegExp(frag, "g")) || []).filter(x => typeof x == "string"); - if (result.length) return true; - return false; - } - - /** - * Tests all links on the page for regexes under a certain certainty level. - * - * Will return either all regex matches from the selected certainty level, - * up to a limit. - * - * certainty can be "certain" > "probable" > "uncertain" - */ - function attempt(certainty, limit) { - // There needs to be some kind of max so that people can't troll by for example leaving a comment with a bunch of emails - // to cause LibreJS users to slow down. - const matches = []; - const links = Array.from(document.links).filter(link => (typeof (link.innerText) === "string" || typeof (link.href) === "string")); - for (const link of links) { - for (const byLevel of CONTACT_FRAGS) { - for (const frag of byLevel[certainty]) { - findMatch(link, frag) && matches.push(link); - if (matches.length >= limit) return { 'fail': false, 'result': [link] }; - } - } - } - return { "fail": matches.length === 0, "result": matches }; - } - - /** - * "LibreJS detects contact pages and email addresses that are likely to be owned by the - * maintainer of the site." - */ - function findContacts() { - for (const type of ["certain", "probable", "uncertain"]) { - const attempted = attempt(type, CONTACT_LINK_LIMIT); - if (!attempted["fail"]) { - return [type, attempted["result"]]; - } - } - return null; - } - - - function createWidget(id, tag, parent = document.body) { - const oldWidget = document.getElementById(id); - if (oldWidget) oldWidget.remove(); - const widget = parent.appendChild(document.createElement(tag)); - widget.id = id; - return widget; - } - - /** - * - * Creates the contact finder / complain UI as a semi-transparent overlay - * - */ - - function main() { - const overlay = createWidget("_LibreJS_overlay", "div"); - const frame = createWidget("_LibreJS_frame", "iframe"); - - const close = () => { - frame.remove(); - overlay.remove(); - }; - - // Clicking the "outer area" closes the dialog. - overlay.addEventListener("click", close); - - const initFrame = prefs => { - debug("initFrame"); - const contentDoc = frame.contentWindow.document; - - const addText = (text, tag, wherein) => { - el = wherein.appendChild(contentDoc.createElement(tag)); - el.textContent = text; - } - - // Header of the dialog - const { body } = contentDoc; - body.id = "_LibreJS_dialog"; - addText('LibreJS Complaint', 'h1', body); - const closeButton = body.appendChild(contentDoc.createElement('button')); - closeButton.classList.toggle('close', true); - closeButton.textContent = 'x'; - closeButton.addEventListener("click", close); - - const content = body.appendChild(contentDoc.createElement("div")); - content.id = "content"; - - // Add list of contact links - const res = findContacts(); - if (!res) { - content.classList.toggle("_LibreJS_fail", true); - addText('Could not guess any contact page for this site.', 'div', content); - } else { - addText('Contact info guessed for this site', 'h3', content); - addText(res[0] + ':', 'span', content); - const list = content.appendChild(contentDoc.createElement("ul")); - for (const link of res[1]) { - const a = contentDoc.createElement("a"); - a.href = link.href; - a.textContent = link.textContent; - list.appendChild(contentDoc.createElement("li")).appendChild(a); - } - } - - // Add list of emails - const emails = (document.documentElement.textContent.match(EMAIL_REGEX) || []).filter(e => !!e); - if (emails.length) { - addText("Possible email addresses:", 'h5', content); - const list = content.appendChild(contentDoc.createElement("ul")); - for (const recipient of emails.slice(0, 10)) { - const a = contentDoc.createElement("a"); - a.href = `mailto:${recipient}?subject=${encodeURIComponent(prefs["pref_subject"]) - }&body=${encodeURIComponent(prefs["pref_body"]) - }`; - a.textContent = recipient; - list.appendChild(contentDoc.createElement("li")).appendChild(a); - } - } - - // contentDoc.querySelectorAll(".close, a").forEach(makeCloser); - debug("frame initialized"); - } - - frame.addEventListener("load", _ => { - debug("frame loaded"); - browser.runtime.connect({ name: "contact_finder" }).onMessage.addListener(initFrame); - }); - } - - main(); -})(); diff --git a/data/extensions/jid1-KtlZuoiikVfFew@jetpack/content/dialog.css b/data/extensions/jid1-KtlZuoiikVfFew@jetpack/content/dialog.css deleted file mode 100644 index 08e475f..0000000 --- a/data/extensions/jid1-KtlZuoiikVfFew@jetpack/content/dialog.css +++ /dev/null @@ -1,91 +0,0 @@ -#_LibreJS_dialog { - font-family: sans-serif; - font-size: 1.2em; - color: #000; - background-color: #eee; - margin: 0; - padding: 0; - text-align: center; -} -#_LibreJS_dialog .close { - -moz-appearance: none; - border: 0; - position: fixed; - top: .2em; - right: .2em; - font-size: 1em; - font-weight: bold; - text-transform: uppercase; - color: white; - background: black; - border-radius: 1em; - cursor: pointer; - display: block; - width: 1.5em; - height: 1.5em; - text-align: center; - vertical-align: middle; - padding: 0; -} -#_LibreJS_dialog .close:hover { - background: #800; -} - - #_LibreJS_dialog h1, #_LibreJS_dialog h2, #_LibreJS_dialog h3 { - font-family: sans-serif; - color: #000; - font-weight: bold; - text-align: center; - border: none; - padding: .2em; - margin: .2em; - display: block; -} - -#_LibreJS_dialog a { - text-decoration: none; - color: #048; - border: none; -} - -#_LibreJS_dialog a:hover { - text-decoration: none; - color: #06c; - border-bottom: 1px solid #048; -} - -#_LibreJS_dialog h1 { - font-size: 1.5em; - background: #666; - color: white; - position: fixed; - top: 0; - left: 0; - width: 100%; - margin: 0; - padding: .2em; -} - -#_LibreJS_dialog h3 { - font-size: 1.2em !important -} - -#_LibreJS_dialog h4 { - font-size: 1em; -} - -#_LibreJS_dialog #content { - position: fixed; - overflow: auto; - top: 2.5em; - bottom: 0; - left: 0; - right: 0; - width: 100%; -} - -#_LibreJS_dialog #content ul { - list-style: none; - margin: 0; - padding: 0; -} diff --git a/data/extensions/jid1-KtlZuoiikVfFew@jetpack/content/externalLicenseChecker.js b/data/extensions/jid1-KtlZuoiikVfFew@jetpack/content/externalLicenseChecker.js deleted file mode 100644 index f59eed8..0000000 --- a/data/extensions/jid1-KtlZuoiikVfFew@jetpack/content/externalLicenseChecker.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* GNU LibreJS - A browser add-on to block nonfree nontrivial JavaScript. -* -* Copyright (C) 2018 Giorgio Maone <giorgio@maone.net> -* Copyright (C) 2022 Yuchen Pei <id@ypei.org> -* -* This file is part of GNU LibreJS. -* -* GNU LibreJS is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation, either version 3 of the License, or -* (at your option) any later version. -* -* GNU LibreJS is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with GNU LibreJS. If not, see <http://www.gnu.org/licenses/>. -*/ -"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 => { - const { map, cache } = args; - const link = document.querySelector(`link[rel="jslicense"], link[data-jslicense="1"], a[rel="jslicense"], a[data-jslicense="1"]`); - const webLabelsUrl = link ? link.href : cache.webLabels && new URL(cache.webLabels.href, document.baseURI); - if (webLabelsUrl) try { - const response = await fetch(webLabelsUrl); - if (!response.ok) throw `${response.status} ${response.statusText}`; - const doc = new DOMParser().parseFromString( - await response.text(), - 'text/html' - ); - // Sets the base url to be the url of the weblabel page if it - // does not exist. Otherwise relative links on the weblabels - // page will use the base of the current page. - if (!doc.querySelector("base")) { - 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 licenseLinks = allLinks(cols[1]); - const sources = cols[2] ? allLinks(cols[2]) : []; - map.set(script.url, { script, licenseLinks, sources }); - } catch (e) { - console.error("LibreJS: error parsing Web Labels at %s, row %s", webLabelsUrl, row.innerHTML, e); - } - } - } catch (e) { - console.error("Error fetching Web Labels at %o", link, e); - } - return map; - } - - const fetchLicenseInfo = async cache => { - const map = new Map(); - const args = { map, cache }; - // in the fetchXxx methods we add to a map whatever license(s) - // URLs and source code references we can find in various formats - // (WebLabels is currently the only implementation), keyed by script URLs. - await Promise.all([ - fetchWebLabels(args), - // fetchXmlSpdx(args), - // fetchTxtSpdx(args), - // ... - ]); - return map; - } - - 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); - return licensedScripts.get(url) || licensedScripts.get(url.replace(/\?.*/, '')); - } - } - - browser.runtime.onMessage.addListener(async m => { - if (m.action in handlers) try { - debug("Received message", m); - const result = await handlers[m.action](m); - return result; - } catch (e) { - console.error(e); - } - }); -} diff --git a/data/extensions/jid1-KtlZuoiikVfFew@jetpack/content/overlay.css b/data/extensions/jid1-KtlZuoiikVfFew@jetpack/content/overlay.css deleted file mode 100644 index fa0a294..0000000 --- a/data/extensions/jid1-KtlZuoiikVfFew@jetpack/content/overlay.css +++ /dev/null @@ -1,28 +0,0 @@ -#_LibreJS_overlay { - z-index: 2147483647 !important; - background-color: #000; - opacity: 0.7 !important; - display: block !important; - position: fixed !important; - margin: 0 !important; - padding: 0 !important; - top: 0 !important; - bottom: 0 !important; - left: 0 !important; - right: 0 !important; -} - -#_LibreJS_frame { - width: 60% !important; - height: 80% !important; - top: 10% !important; - bottom: 10% !important; - left: 20% !important; - right: 20% !important; - overflow: auto !important; - position: fixed !important; - display:inline-block !important; - border: 2px solid #444 !important; - z-index: 2147483647 !important; - background: #eee; -} |