diff options
author | Ruben Rodriguez <ruben@fsf.org> | 2019-04-29 17:55:18 -0400 |
---|---|---|
committer | Ruben Rodriguez <ruben@fsf.org> | 2019-04-29 17:55:18 -0400 |
commit | ef4efa91207e1ad42b4a0bf1d54a14e5c1bea298 (patch) | |
tree | 5d67683fdf4f6e2de356bfcb6096820cd380b143 /html | |
parent | c6fafeed2ace4abd083b8e33d0846987dc9333fc (diff) | |
parent | b4ab7ef958d7d3d0761650b1404bf286d05f26cd (diff) |
Merge branch 'master' of ssh://pagure.io/librejs
Diffstat (limited to 'html')
-rw-r--r-- | html/display_panel/content/display-panel.html | 4 | ||||
-rw-r--r-- | html/display_panel/content/main_panel.js | 29 | ||||
-rw-r--r-- | html/display_panel/content/panel-styles.css | 7 | ||||
-rw-r--r-- | html/preferences_panel/pref.js | 3 | ||||
-rw-r--r-- | html/preferences_panel/preferences_panel.html | 4 |
5 files changed, 37 insertions, 10 deletions
diff --git a/html/display_panel/content/display-panel.html b/html/display_panel/content/display-panel.html index 5b9f99f..7d1fdf5 100644 --- a/html/display_panel/content/display-panel.html +++ b/html/display_panel/content/display-panel.html @@ -60,16 +60,18 @@ <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"> diff --git a/html/display_panel/content/main_panel.js b/html/display_panel/content/main_panel.js index 83c3a6b..b96143b 100644 --- a/html/display_panel/content/main_panel.js +++ b/html/display_panel/content/main_panel.js @@ -59,6 +59,7 @@ document.querySelector("#info").addEventListener("click", e => { 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) { @@ -69,10 +70,13 @@ document.querySelector("#info").addEventListener("click", e => { 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("-")); } @@ -94,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 @@ -169,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}`; @@ -194,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/html/display_panel/content/panel-styles.css b/html/display_panel/content/panel-styles.css index 0eb6490..6114307 100644 --- a/html/display_panel/content/panel-styles.css +++ b/html/display_panel/content/panel-styles.css @@ -94,11 +94,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 { diff --git a/html/preferences_panel/pref.js b/html/preferences_panel/pref.js index 9cecbb6..debb468 100644 --- a/html/preferences_panel/pref.js +++ b/html/preferences_panel/pref.js @@ -40,6 +40,9 @@ error = "Only one single trailing path wildcard (/*) allowed"; } } catch (e) { + if (/^https?:\/\/\*\./.test(url)) { + return this.malformedUrl(url.replace("*.", "")); + } error = "Invalid URL"; if (url && !url.includes("://")) error += ": missing protocol, either http:// or https://"; else if (url.endsWith("://")) error += ": missing domain name"; diff --git a/html/preferences_panel/preferences_panel.html b/html/preferences_panel/preferences_panel.html index 3a0ad7a..081ae07 100644 --- a/html/preferences_panel/preferences_panel.html +++ b/html/preferences_panel/preferences_panel.html @@ -45,10 +45,10 @@ <h3>Settings</h3> </div> <div id="widgets"> - <fieldset id="section-lists"><legend>Allow or block scripts matching the following URLs ("*" matches any path)</legend> + <fieldset id="section-lists"><legend>Allow or block scripts matching the following URLs ("*."" matches any subdomain, "/*" matches any path)</legend> <label>Type a new whitelist / blacklist entry:</label> <div id="new-site"> - <input type="text" id="site" value="" placeholder="https://www.gnu.org/*"> + <input type="text" id="site" value="" placeholder="https://*.gnu.org/*"> <button id="cmd-whitelist-site" class="white" title="Whitelist this site" default>Whitelist</button> <button id="cmd-blacklist-site" class="red" title="Blacklist this site">Blacklist</button> </div> |