From d26b319fd6f98517cc3421f10bf18698b953e4d2 Mon Sep 17 00:00:00 2001 From: Ruben Rodriguez Date: Thu, 13 Sep 2018 20:39:48 -0400 Subject: Updated extensions list for v60 --- .../html/display_panel/content/display-panel.html | 104 ++++++++++++ .../html/display_panel/content/main_panel.js | 177 +++++++++++++++++++++ .../html/display_panel/content/panel-styles.css | 157 ++++++++++++++++++ 3 files changed, 438 insertions(+) create mode 100644 data/extensions/jid1-KtlZuoiikVfFew@jetpack/html/display_panel/content/display-panel.html create mode 100644 data/extensions/jid1-KtlZuoiikVfFew@jetpack/html/display_panel/content/main_panel.js create mode 100644 data/extensions/jid1-KtlZuoiikVfFew@jetpack/html/display_panel/content/panel-styles.css (limited to 'data/extensions/jid1-KtlZuoiikVfFew@jetpack/html/display_panel/content') diff --git a/data/extensions/jid1-KtlZuoiikVfFew@jetpack/html/display_panel/content/display-panel.html b/data/extensions/jid1-KtlZuoiikVfFew@jetpack/html/display_panel/content/display-panel.html new file mode 100644 index 0000000..df153b3 --- /dev/null +++ b/data/extensions/jid1-KtlZuoiikVfFew@jetpack/html/display_panel/content/display-panel.html @@ -0,0 +1,104 @@ + + + + +Display JS Monitoring Panel + + + + + + + +
+
+

This whole site

+
+ + + +
+
+
+

+

+ LibreJS will decide whether blocking these scripts next time this page is loaded. +

+
    +
  • + : +

    +
    + + + + +
    +
  • +
+
+
+

+
    +
    +
    +

    +
      +
      +
      +

      +
        +
        +
        +

        +
          +
          +
          + + + diff --git a/data/extensions/jid1-KtlZuoiikVfFew@jetpack/html/display_panel/content/main_panel.js b/data/extensions/jid1-KtlZuoiikVfFew@jetpack/html/display_panel/content/main_panel.js new file mode 100644 index 0000000..c55b167 --- /dev/null +++ b/data/extensions/jid1-KtlZuoiikVfFew@jetpack/html/display_panel/content/main_panel.js @@ -0,0 +1,177 @@ +/** +* GNU LibreJS - A browser add-on to block nonfree nontrivial JavaScript. +* * +* Copyright (C) 2017, 2018 NateN1222 +* Copyright (C) 2018 Ruben Rodriguez +* Copyright (C) 2018 Giorgio Maone +* +* This program 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. +* +* This program 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 this program. If not, see . +* +*/ + +var fromTab = window.location.hash.match(/^#fromTab=(\d+)/) && RegExp.$1; +if (fromTab) { + let browserStyle = document.createElement("link"); + browserStyle.rel = "stylesheet"; + browserStyle.href = "chrome://browser/content/extension.css"; + document.head.appendChild(browserStyle); + document.documentElement.classList.add("tab"); +} + +var myPort = browser.runtime.connect({name: "port-from-cs"}); +var currentReport; + +// Sends a message that tells the background script the window is open +myPort.postMessage({"update": true, tabId: parseInt(currentReport && currentReport.tabId || fromTab) || ""}); + +// Display the actual extension version Number +document.querySelector("#version").textContent = browser.runtime.getManifest().version; + +var liTemplate = document.querySelector("#li-template"); +liTemplate.remove(); + +document.querySelector("#info").addEventListener("click", e => { + let button = e.target; + if (!button.matches(".buttons > button")) return; + let li = button.closest("li"); + let entry = li && li._scriptEntry || [currentReport.url, "Page's site"]; + let action = button.className; + let site = button.name === "*"; + if (site) { + ([action] = action.split("-")); + } + myPort.postMessage({[action]: entry, site, tabId: currentReport.tabId}); +}); + +document.querySelector("#report-tab").onclick = e => { + myPort.postMessage({report_tab: currentReport}); + close(); +} + +document.querySelector("#complain").onclick = e => { + myPort.postMessage({invoke_contact_finder: currentReport}); + close(); +} + +document.querySelector("#open-options").onclick = e => { + browser.runtime.openOptionsPage(); + close(); +} + +document.querySelector("#reload").onclick = async e => { + let {tabId} = currentReport; + if (tabId) { + await browser.tabs.reload(tabId); + myPort.postMessage({"update": true, tabId}); + } +}; + +/* +* Takes in the [[file_id, reason],...] array and the group name for one group +* of scripts found in this tab, rendering it as a list with management buttons. +* Groups are "unknown", "blacklisted", "whitelisted", "accepted", and "blocked". +*/ +function createList(data, group){ + var {url} = data; + let entries = data[group]; + let container = document.getElementById(group); + let heading = container.querySelector("h2"); + var list = container.querySelector("ul"); + list.classList.toggle(group, true); + if (Array.isArray(entries) && entries.length) { + heading.innerHTML = `${group} scripts in ${url}:`; + container.classList.remove("empty"); + } else { + // default message + list.innerHTML = `
        • No ${group} scripts on this page.
        • ` + entries = data[group] = []; + container.classList.add("empty"); + } + // generate list + for (let entry of entries) { + let [scriptId, reason] = entry; + let li = liTemplate.cloneNode(true); + let a = li.querySelector("a"); + a.href = scriptId.split("(")[0]; + a.textContent = scriptId; + li.querySelector(".reason").textContent = reason; + let bySite = !!reason.match(/https?:\/\/[^/]+\/\*/); + li.classList.toggle("by-site", bySite); + if (bySite) { + let domain = li.querySelector(".forget .domain"); + if (domain) domain.textContent = RegExp.lastMatch; + } + li._scriptEntry = entry; + list.appendChild(li); + } + +} + +/** +* Updates scripts lists and buttons to act on them. +* If return_HTML is true, it returns the HTML of the popup window without updating it. +* example report argument: +* { +* "accepted": [["FILENAME 1","REASON 1"],["FILENAME 2","REASON 2"]], +* "blocked": [["FILENAME 1","REASON 1"],["FILENAME 2","REASON 2"]], +* "whitelisted": [["FILENAME 1","REASON 1"],["FILENAME 2","REASON 2"]], +* "blacklisted": [["FILENAME 1","REASON 1"],["FILENAME 2","REASON 2"]], +* "unknown": [["FILENAME 1","REASON 1"],["FILENAME 2","REASON 2"]], +* "url":"example.com" +* }; +* +*/ +function refreshUI(report) { + currentReport = report; + + document.querySelector("#site").className = report.siteStatus || ""; + document.querySelector("#site h2").textContent = + `This site ${report.site}`; + + for (let toBeErased of document.querySelectorAll("#info h2:not(.site) > *, #info ul > *")) { + toBeErased.remove(); + } + + let scriptsCount = 0; + for (let group of ["unknown", "accepted", "whitelisted", "blocked", "blacklisted"]) { + if (group in report) createList(report, group); + scriptsCount += report[group].length; + } + + for (let b of document.querySelectorAll(`.forget, .whitelist, .blacklist`)) { + b.disabled = false; + } + for (let b of document.querySelectorAll( + `.unknown .forget, .accepted .forget, .blocked .forget, + .whitelisted .whitelist, .blacklisted .blacklist` + )) { + b.disabled = true; + } + + let noscript = scriptsCount === 0; + document.body.classList.toggle("empty", noscript); +} + +myPort.onMessage.addListener(m => { + if (m.show_info) { + refreshUI(m.show_info); + } +}); + +function print_local_storage(){ + myPort.postMessage({"printlocalstorage": true}); +} +function delete_local_storage(){ + myPort.postMessage({"deletelocalstorage":true}); +} diff --git a/data/extensions/jid1-KtlZuoiikVfFew@jetpack/html/display_panel/content/panel-styles.css b/data/extensions/jid1-KtlZuoiikVfFew@jetpack/html/display_panel/content/panel-styles.css new file mode 100644 index 0000000..cbf5cf5 --- /dev/null +++ b/data/extensions/jid1-KtlZuoiikVfFew@jetpack/html/display_panel/content/panel-styles.css @@ -0,0 +1,157 @@ +/** + * GNU LibreJS - A browser add-on to block nonfree nontrivial JavaScript. + * * + * Copyright (C) 2011, 2012, 2014 Loic J. Duros + * + * This program 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. + * + * This program 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 this program. If not, see . + * + */ +@import url("/html/common.css"); + +body { + width:500px; +} +#header{ +display:block; +width:500px; +} + +h2 { + font-size:1.1em; + font-weight:bold; + font-family:arial; + border-bottom:4px solid #444; + padding-bottom:0; + margin:10px 0 0 0; + line-height:140%; +} +code { + font-size:1.2em; + margin:0; + padding:0; +} +ul { + margin:0; + padding:0; + list-style:none; +} +#info li { + padding:5px; + border-bottom:2px solid #CCC; + margin:0; + overflow: hidden; +} + +#info ul ul { + margin:10px; + list-style:disc; +} +#info ul ul li { + padding:5px; + border-bottom:0; +} +#info { + clear:both; +} + +#info .type-name { + text-transform: uppercase; + font-weight: bold; +} + +#info .accepted-js .type-name { + color: #080; +} + +#info .blocked-js .type-name { + color: #800; +} + +#info .unknown-js .type-name { + color: #008; +} + +#info .unknown-js .reason { + display: none; +} + +.by-site button.forget, button.forget[name="*"] { + display: none; +} + +.by-site button.forget[name="*"], #site .forget[name="*"] { + display: initial; +} + + +button.whitelist { + color: #080; +} +button.blacklist { + color: #800; +} +button.forget { + color: #008; +} + +button:disabled { + color: #888 !important; +} + +span.accepted, span.blocked { + color:#008e00; + font-size:145%; + font-variant:small-caps; + font-weight:bold; +} + +span.blocked { + color:#8e0000; +} + +.title-area { + width: 250px; + float:left !important; + text-align: center !important; +} + +.title-area #librejs-web-link { + font-size: 18px; +} + +#librejs-web-labels-pages>ul { + margin-top: 8px; + font-size: 14px; + list-style-type: disc; +} + + +.empty #site, .unknown-js.empty { + display: none; +} + +.tab #must-reload, .tab #buttons, .empty #buttons { + display: none; +} + +#buttons button { + width: 100%; + text-align: center; +} + + + +#complain { + display: none; /* TODO: Complaint to owner UI */ +} -- cgit v1.2.3