diff options
author | Ruben Rodriguez <ruben@gnu.org> | 2019-05-10 19:05:20 -0400 |
---|---|---|
committer | Ruben Rodriguez <ruben@gnu.org> | 2019-05-10 19:05:20 -0400 |
commit | 7859a9131fcda359265dc16ef55933e5ed218119 (patch) | |
tree | ecb4bf7a0fd005a637d3ff0444ce9afaa8817ba9 /data/extensions/jid1-KtlZuoiikVfFew@jetpack/html/display_panel | |
parent | cb4bbb16a12d495eca1ac05ebacc7557e9b05c05 (diff) |
Updated extensions bundle
Diffstat (limited to 'data/extensions/jid1-KtlZuoiikVfFew@jetpack/html/display_panel')
3 files changed, 103 insertions, 24 deletions
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 index 80f4cb9..7d1fdf5 100644 --- 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 @@ -28,6 +28,7 @@ * */ --> +<script src="/html/mobile.js"></script> </head> <body> @@ -59,20 +60,25 @@ <div id="info"> <div id="site"> <h2 class="site">This whole site <span></span></h2> + <div class="status"></div> <div class="buttons"> <button class="whitelist" name="*">Whitelist</button> <button class="blacklist" name="*">Blacklist</button> <button class="forget" name="*">Forget</button> + <button id="reload" class="reload">Reload</button> </div> </div> <div id="unknown" class="unknown-js"> <h2></h2> <p id="must-reload"> - LibreJS will decide whether blocking these scripts next time this page is loaded. <button id="reload">Reload it now</button> + LibreJS will decide whether blocking these scripts next time this page is loaded. <button class="reload" id="reload-now">Reload it now</button> </p> <ul> <li id="li-template"> - <a class="script-url" href="#"></a>: + <button class="toggle-source show" title="Show code inline">Show</button> + <button class="toggle-source hide" title="Hide code inline">Hide</button> + <a class="script-url" href="#" target="librejs_viewsource"></a>: + <pre class="source"></pre> <p class="reason"></p> <div class="buttons"> <button class="whitelist">Whitelist</button> @@ -80,6 +86,7 @@ <button class="forget">Forget</button> <button class="forget" name="*">Forget <span class="domain"></span></button> </div> + </li> </ul> </div> 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 index 2509545..b96143b 100644 --- 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 @@ -55,11 +55,28 @@ liTemplate.remove(); document.querySelector("#info").addEventListener("click", e => { let button = e.target; + if (button.tagName === "A") { + setTimeout(close, 100); + return; + } + if (button.tagName !== "BUTTON") button = button.closest("button"); + if (button.matches(".toggle-source")) { + let parent = button.parentNode; + if (!parent.querySelector(".source").textContent) { + parent.querySelector("a").click(); + } else { + parent.classList.toggle("visible"); + } + return; + } if (!button.matches(".buttons > button")) return; + let domain = button.querySelector(".domain"); + let li = button.closest("li"); let entry = li && li._scriptEntry || [currentReport.url, "Page's site"]; let action = button.className; - let site = button.name === "*"; + let site = domain ? domain.textContent : button.name === "*" ? currentReport.site : ""; + if (site) { ([action] = action.split("-")); } @@ -81,13 +98,14 @@ document.querySelector("#open-options").onclick = e => { close(); } -document.querySelector("#reload").onclick = async e => { +document.body.addEventListener("click", async e => { + if (!e.target.matches(".reload")) return; 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 @@ -111,11 +129,21 @@ function createList(data, group){ container.classList.add("empty"); } // generate list + let viewSourceToHuman = /^view-source:(.*)#line(\d+)\(([^)]*)\)[^]*/; for (let entry of entries) { let [scriptId, reason] = entry; let li = liTemplate.cloneNode(true); let a = li.querySelector("a"); a.href = scriptId.split("(")[0]; + if (scriptId.startsWith("view-source:")) { + a.target ="LibreJS-ViewSource"; + let source = scriptId.match(/\n([^]*)/); + if (source) { + li.querySelector(".source").textContent = source[1]; + li.querySelector(".toggle-source").style.display = "inline"; + } + scriptId = scriptId.replace(viewSourceToHuman, "$3 at line $2 of $1"); + } a.textContent = scriptId; li.querySelector(".reason").textContent = reason; let bySite = !!reason.match(/https?:\/\/[^/]+\/\*/); @@ -146,8 +174,8 @@ function createList(data, group){ */ function refreshUI(report) { currentReport = report; - - document.querySelector("#site").className = report.siteStatus || ""; + let {siteStatus, listedSite} = report; + document.querySelector("#site").className = siteStatus || ""; document.querySelector("#site h2").textContent = `This site ${report.site}`; @@ -171,6 +199,20 @@ function refreshUI(report) { b.disabled = true; } + if (siteStatus && siteStatus !== "unknown") { + let siteContainer = document.querySelector("#site"); + let statusLabel = siteStatus; + if (listedSite && listedSite !== report.site) { + statusLabel += ` via ${listedSite}`; + siteContainer.querySelector(".forget").disabled = true; + } + let status = siteContainer.querySelector(".status"); + status.classList.add(siteStatus); + status.textContent = statusLabel; + } else { + document.querySelector("#site .status").textContent = ""; + } + let noscript = scriptsCount === 0; document.body.classList.toggle("empty", noscript); } 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 index 940a8ff..fefd668 100644 --- 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 @@ -20,24 +20,26 @@ @import url("/html/common.css"); body { - width:500px; + max-width: 600px; + min-width: 500px; + -moz-user-select: text !important; } #header{ -display:block; -width:500px; +display: block; +width: 100% } h2 { - font-size:1.1em; + font-size: 1.4em; font-weight:bold; font-family:arial; - border-bottom:4px solid #444; + border-bottom:.2em solid #444; padding-bottom:0; - margin:10px 0 0 0; + margin:.8em 0 0 0; line-height:140%; } code { - font-size:1.2em; + font-size: 1.2em; margin:0; padding:0; } @@ -47,18 +49,18 @@ ul { list-style:none; } #info li { - padding:5px; - border-bottom:2px solid #CCC; + padding: .3em; + border-bottom:.1em solid #CCC; margin:0; overflow: hidden; } #info ul ul { - margin:10px; + margin: .4em; list-style:disc; } #info ul ul li { - padding:5px; + padding: .5em; border-bottom:0; } #info { @@ -94,11 +96,14 @@ ul { display: initial; } +.status { + margin: .2em; +} -button.whitelist { +button.whitelist, .status.whitelisted { color: #080; } -button.blacklist { +button.blacklist, .status.blacklisted { color: #800; } button.forget { @@ -109,6 +114,27 @@ button:disabled { color: #888 !important; } +button.toggle-source { + color: #004; + width: 5em; + text-align:center; +} + +pre.source { + display: none; + background: white; + border: 1px solid #444; + padding: .5em; + overflow: auto; + max-height: 20em; + white-space: pre-wrap; +} + +button.hide { display: none } +.visible > button.show { display: none !important} +.visible > pre.source { display: block } +.visible > button.hide { display: initial } + span.accepted, span.blocked { color:#008e00; font-size:145%; @@ -121,18 +147,18 @@ span.blocked { } .title-area { - width: 250px; + width: 50%; float:left !important; text-align: center !important; } .title-area #librejs-web-link { - font-size: 18px; + font-size: 1.2em; } #librejs-web-labels-pages>ul { - margin-top: 8px; - font-size: 14px; + margin-top: .5em; + font-size: 1.2em; list-style-type: disc; } @@ -150,3 +176,7 @@ span.blocked { width: 100%; text-align: center; } + +.mobile #report-tab { + display: none; +} |