diff options
Diffstat (limited to 'data/extensions/https-everywhere@eff.org/pages')
16 files changed, 0 insertions, 2108 deletions
diff --git a/data/extensions/https-everywhere@eff.org/pages/base.css b/data/extensions/https-everywhere@eff.org/pages/base.css deleted file mode 100644 index 92adbf8..0000000 --- a/data/extensions/https-everywhere@eff.org/pages/base.css +++ /dev/null @@ -1,46 +0,0 @@ -:root { - --https-blue: #0a84ff; - --darker-blue: #0060df; - --text-main: #000; - --text-secondary: #464646; - --light-grey: #ececec; - --space: 5px; - --font: 'Lucida Grande', 'Segoe UI', Tahoma, 'DejaVu Sans', Arial, sans-serif; - --code-font: 'VeraMono'; -} - -/*-------------------------------------------------------------- -# Layout ---------------------------------------------------------------*/ -.grid { - display: grid; - grid-template-columns: 1fr 1fr 1fr; - row-gap: 16px; -} - -/*-------------------------------------------------------------- -# Typography ---------------------------------------------------------------*/ -.font { - font-family: var(--font); -} - -/*-------------------------------------------------------------- -# Elements ---------------------------------------------------------------*/ -.button { - border: var(--https-blue) solid 1px; - color: var(--text-main); - display: block; - font-size: 12px; - font-weight: bold; - margin: var(--space) auto; - padding: 10px; - text-align: center; - text-decoration: none; -} - -.button:hover { - background-color: var(--darker-blue); - color: #fff; -} diff --git a/data/extensions/https-everywhere@eff.org/pages/cancel/index.html b/data/extensions/https-everywhere@eff.org/pages/cancel/index.html deleted file mode 100644 index ec25184..0000000 --- a/data/extensions/https-everywhere@eff.org/pages/cancel/index.html +++ /dev/null @@ -1,32 +0,0 @@ -<!doctype html> -<html> - <head> - <!-- Required meta tags --> - <meta charset="utf-8"> - <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> - - <title>⚠ HTTPS Everywhere ⚠</title> - <link href="style.css" rel="stylesheet"> - <link rel="icon" href="/images/icons/icon-blocking-38.png"> - </head> - <body> - <div class="banner"> - <img src="/images/banner-red.svg" alt="HTTPS Everywhere"> - </div> - - <div class="explainer" data-i18n="cancel_he_blocking_explainer"></div> - - <div class="copy_block"> - <pre id="url-value"></pre> - <button id="copy-url" class="ease_button" data-i18n="cancel_copy_url"></button> - </div> - - <div class="button_options"> - <button id="http-once-button" class="ease_button" data-i18n="cancel_http_once"></button> - <button id="open-url-button" class="ease_button" data-i18n="cancel_open_page"></button> - </div> - <script src="/pages/translation.js"></script> - <script src="/pages/util.js"></script> - <script src="ux.js"></script> - </body> -</html> diff --git a/data/extensions/https-everywhere@eff.org/pages/cancel/style.css b/data/extensions/https-everywhere@eff.org/pages/cancel/style.css deleted file mode 100644 index aeba151..0000000 --- a/data/extensions/https-everywhere@eff.org/pages/cancel/style.css +++ /dev/null @@ -1,130 +0,0 @@ -@import "../main.css"; - -body { - display: grid; - grid-template-columns: 1fr 1fr 1fr; - margin: 2% auto; - font-size: 12pt; - font-family: sans-serif; - line-height: 150%; - row-gap: 16px; -} - -/*--------- -# GRID LAYOUT ----------*/ -.banner { - grid-column: 2; - grid-row: 1; -} -.explainer { - grid-column: 2; - grid-row: 2; -} -.copy_block { - grid-column: 2; - grid-row: 3; -} -.button_options { - grid-column: 2; - grid-row: 4; -} - -h1 { - display: block; -} - -h1 img { - width: 100%; - height: auto; -} - -#url-paragraph { - display: inline-flex; - overflow: hidden; - white-space: nowrap; - text-overflow: ellipsis; -} - -.ease_button { - background-color: #ec1e1e; - border: 1px solid #ec1e1e; - border-radius: 4px; - color: #fff; - cursor: pointer; - padding: 0.5em 1em; - float: none; - font-size: 12pt; - font-weight: normal; - margin: 8px 0; - line-height: 150%; -} - -button:last-child { - margin: 0; -} - -#url-value{ - float: left; - font-weight: bold; - margin: 2% 2% 0 0; -} -#copy-url, #open-url-button{ - background-color: var(--light-grey) !important; - border: 1px solid var(--text-secondary) !important; -} -#copy-url { - color: var(--text-secondary) !important; - font-size: 14px; -} -#open-url-button { - color: #666666 !important; -} -#copy-url:hover, #open-url-button:hover { - background-color: var(--text-secondary) !important; - border: 1px solid var(--text-secondary) !important; - color: var(--light-grey) !important; -} - -@media screen and (max-width: 800px) { - body { - grid-template-columns: 1fr; - margin: 5%; - } - .banner { - grid-row: 1; - } - .explainer { - grid-row: 2; - } - .copy_block { - grid-row: 3; - } - .button_options { - grid-row: 4; - } - .ease_button { - width: 100%; - margin: 8px 0; - } -} - -@media (prefers-color-scheme: dark) { - body { - background-color: #202023; - color: #f9f9fa; - } - - a { - color: #45a1ff; - } - - .ease_button { - color: #202023; - } - - .ease_button:hover { - background-color: #202023; - border-color: #ec1e1e; - } -} diff --git a/data/extensions/https-everywhere@eff.org/pages/cancel/ux.js b/data/extensions/https-everywhere@eff.org/pages/cancel/ux.js deleted file mode 100644 index 259d602..0000000 --- a/data/extensions/https-everywhere@eff.org/pages/cancel/ux.js +++ /dev/null @@ -1,128 +0,0 @@ -/* global sendMessage */ - -"use strict"; - -let observer; -document.addEventListener("DOMContentLoaded", () => { - const explainer = document.querySelector("[data-i18n=cancel_he_blocking_explainer]"); - observer = new MutationObserver(() => { - replaceLink(explainer); - }); - if (explainer.innerText.length > 0) { - replaceLink(explainer); - } else { - observer.observe(explainer, {childList: true}); - } - displayURL(); -}); - -function replaceLink(explainer) { - observer.disconnect(); - const linkText = chrome.i18n.getMessage("cancel_he_blocking_network"); - const link = document.createElement("a"); - link.classList.add("wikilink"); - link.href = "https://en.wikipedia.org/wiki/Downgrade_attack"; - link.innerText = linkText; - explainer.innerHTML = explainer.innerHTML.replace(linkText, link.outerHTML); - - /* - In response to translation of i18n string "cancel_he_blocking_network". - Within context of the paragraph and as a standalone string can be interpreted differently - langauge to language. - - So if link fails to swap in replace, this conditional is triggered - */ - if (document.getElementsByClassName("wikilink").length === 0) { - link.innerText = linkText; - explainer.after(link); - } - -} - -function displayURL() { - const searchParams = new URLSearchParams(window.location.search); - const originURL = searchParams.get('originURL'); - const originURLLink = document.getElementById('url-value'); - const openURLButton = document.getElementById('open-url-button'); - const openHttpOnce = document.getElementById('http-once-button'); - const copyButton = document.getElementById('copy-url'); - const url = new URL(originURL); - - originURLLink.innerText = originURL; - originURLLink.href = originURL; - - openURLButton.addEventListener("click", function() { - if (confirm(chrome.i18n.getMessage("cancel_open_page") + '?')) { - sendMessage("disable_on_site", url.host, () => { - window.location = originURL; - }); - } - - return false; - }); - - // Copy URL Feature on EASE - - function copyLinkAlternate() { - let isSuccessful = false; - - const sel = window.getSelection(); - - try { - sel.removeAllRanges(); - - const range = document.createRange(); - range.selectNode(originURLLink); - - sel.addRange(range); - - isSuccessful = document.execCommand("copy"); - - sel.removeAllRanges(); - - return isSuccessful; - } catch (err) { - console.error(err); - - sel.removeAllRanges(); - - return false; - } - } - - async function copyLink() { - try { - await navigator.clipboard.writeText(originURL); - return true; - } catch (err) { - return copyLinkAlternate(); - } - } - - let restoreTimeout = null; - - copyButton.addEventListener("click", async () => { - if (await copyLink()) { - copyButton.innerText = chrome.i18n.getMessage("cancel_copied_url"); - - if (restoreTimeout !== null) { - clearTimeout(restoreTimeout); - } - - restoreTimeout = setTimeout(() => { - copyButton.innerText = chrome.i18n.getMessage("cancel_copy_url"); - restoreTimeout = null; - }, 1500); - } - }); - - openHttpOnce.addEventListener("click", function() { - if (confirm(chrome.i18n.getMessage("cancel_http_once") + '?')) { - sendMessage("disable_on_site_once", url.host, () => { - window.location = originURL; - }); - } - - return false; - }); -} diff --git a/data/extensions/https-everywhere@eff.org/pages/debugging-rulesets/index.html b/data/extensions/https-everywhere@eff.org/pages/debugging-rulesets/index.html deleted file mode 100644 index d3e9122..0000000 --- a/data/extensions/https-everywhere@eff.org/pages/debugging-rulesets/index.html +++ /dev/null @@ -1,25 +0,0 @@ -<!doctype html> -<html> - <head> - <meta charset="utf-8"> - <title></title> - <link href="style.css" rel="stylesheet"> - <script src="/external/codemirror/codemirror-5.31.0.min.js"></script> - <link href="/external/codemirror/codemirror-5.31.0.min.css" rel="stylesheet"> - <script src="/external/codemirror/codemirror-5.31.0.xml.min.js"></script> - </head> - <body> - <div class="section-header"><span class="section-header-span">Debugging Rulesets</span></div> - <div class="section-explainer"> - Enter ruleset XML below and click save when ready. These rulesets will be immediately activated upon saving, and will persist across restarts.<br> - <i>Warning</i>: This should only be used for debugging rulesets. This feature is not guaranteed to work reliably for regular usage.<br> - <i>Note</i>: Due to a bug in Chromium, it may be necessary to close the options ui before saving. - </div> - <div id="unsaved-text">There are unsaved changes! Be sure to save them for them to take effect.</div> - <textarea id="codemirror-textarea"></textarea> - <button type="button" id="save-button">Save</button> - <div id="saved-text">Saved!</div> - <script src="../util.js"></script> - <script src="ux.js"></script> - </body> -</html> diff --git a/data/extensions/https-everywhere@eff.org/pages/debugging-rulesets/style.css b/data/extensions/https-everywhere@eff.org/pages/debugging-rulesets/style.css deleted file mode 100644 index e424c70..0000000 --- a/data/extensions/https-everywhere@eff.org/pages/debugging-rulesets/style.css +++ /dev/null @@ -1,40 +0,0 @@ -.cm-s-main{ - width: 100%; - height: 500px; -} - -.cm-s-saved{ - border: 1px solid black; -} - -.cm-s-unsaved{ - border: 1px solid red; -} - -.section-explainer{ - margin-bottom: 5px; -} - -.section-header{ - margin-bottom: 10px; -} - -.section-header-span{ - border-bottom: 1px solid #ccc; - font-size: 15px; -} - -#saved-text{ - display: none; - color: green; - font-weight: bold; - margin: 30px; -} - -#unsaved-text{ - font-weight: bold; - margin: 10px 0px; - color: red; - visibility: hidden; - text-align: center; -} diff --git a/data/extensions/https-everywhere@eff.org/pages/debugging-rulesets/ux.js b/data/extensions/https-everywhere@eff.org/pages/debugging-rulesets/ux.js deleted file mode 100644 index 0df93d8..0000000 --- a/data/extensions/https-everywhere@eff.org/pages/debugging-rulesets/ux.js +++ /dev/null @@ -1,46 +0,0 @@ -/* global sendMessage, CodeMirror */ - -"use strict"; - -const savedTextElement = document.getElementById("saved-text"); -const unsavedTextElement = document.getElementById("unsaved-text"); -const savedTitle = "Debugging Rulesets"; -const unsavedTitle = "* Debugging Rulesets"; - -document.title = savedTitle; - -const cm = CodeMirror.fromTextArea( - document.getElementById("codemirror-textarea"), - { - mode: "xml", - theme: "default main saved" - } -); - -let valueHasChanged = false; -sendMessage("get_option", { debugging_rulesets: "" }, item => { - cm.setValue(item.debugging_rulesets); - cm.on("change", cm => { - if (!(valueHasChanged)) { - valueHasChanged = true; - document.title = unsavedTitle; - cm.setOption("theme", "default main unsaved"); - unsavedTextElement.style.visibility = "visible"; - } - }); -}); - -document.getElementById("save-button").addEventListener("click", e => { - e.preventDefault(); - sendMessage("set_option", { debugging_rulesets: cm.getValue() }, () => { - savedTextElement.style.display = "block"; - setTimeout(() => { - savedTextElement.style.display = "none"; - }, 1000); - - valueHasChanged = false; - document.title = savedTitle; - cm.setOption("theme", "default main saved"); - unsavedTextElement.style.visibility = "hidden"; - }); -}); diff --git a/data/extensions/https-everywhere@eff.org/pages/main.css b/data/extensions/https-everywhere@eff.org/pages/main.css deleted file mode 100644 index 2772c46..0000000 --- a/data/extensions/https-everywhere@eff.org/pages/main.css +++ /dev/null @@ -1,21 +0,0 @@ -/*-------------------------------------------------------------- ->>> TABLE OF CONTENTS: ----------------------------------------------------------------- -# Base - - Layout - - Typography - - Elements - - Links -# Utilities - - Accessibility - ---------------------------------------------------------------*/ - -/*-------------------------------------------------------------- -# Base ---------------------------------------------------------------*/ -@import "base.css"; - -/* Utilities - TBA ---------------------------------------------- */ - diff --git a/data/extensions/https-everywhere@eff.org/pages/options/index.html b/data/extensions/https-everywhere@eff.org/pages/options/index.html deleted file mode 100644 index b6bdc33..0000000 --- a/data/extensions/https-everywhere@eff.org/pages/options/index.html +++ /dev/null @@ -1,65 +0,0 @@ -<!doctype html> -<html> - <head> - <meta charset="utf-8"> - <meta name="viewport" content="width=device-width, initial-scale=1"> - <title></title> - <link href="style.css" rel="stylesheet"> - </head> - <body class="font"> - <section class="header-wrapper"> - <span class="button section-header-span active" data-show="general-settings-wrapper" data-i18n="options_generalSettings"></span> - <span class="button section-header-span inactive" data-show="advanced-settings-wrapper" data-i18n="options_advancedSettings"></span> - <span class="button section-header-span inactive" data-show="update-channels-wrapper" data-i18n="options_updateChannels"></span> - </section> - <div class="section-wrapper" id="general-settings-wrapper"> - <div id="update-wrapper" class="settings-wrapper"> - <input type="checkbox" id="autoUpdateRulesets"> - <label for="autoUpdateRulesets" data-i18n="options_autoUpdateRulesets"></label> - </div> - <div id="user-rules-wrapper"> - <p class="user-rules-wrapper-header" data-i18n="options_userRulesListed"></p> - </div> - <div id="disabled-rules-wrapper"> - <p class="disabled-rules-wrapper-header" data-i18n="options_disabledUrlsListed"></p> - <div id="add-disabled-site-wrapper"> - <button class="button" id="add-disabled-site" data-i18n="options_addDisabledSite"></button> - <input type="text" id="disabled-site" /> - </div> - <div id="add-disabled-site-invalid-host" data-i18n="options_hostNotFormattedCorrectly"></div> - </div> - </div> - - <div class="section-wrapper" id="advanced-settings-wrapper"> - <div id="mixed-rulesets-wrapper" class="settings-wrapper"> - <input type="checkbox" id="enableMixedRulesets"> - <label for="enableMixedRulesets" data-i18n="options_enableMixedRulesets"></label> - </div> - <div id="show-devtools-tab-wrapper" class="settings-wrapper"> - <input type="checkbox" id="showDevtoolsTab"> - <label for="showDevtoolsTab" data-i18n="options_showDevtoolsTab"></label> - </div> - </div> - - <div class="section-wrapper" id="update-channels-wrapper"> - <div id="update-channels-error"> - <span id="update-channels-error-text"></span> - <img id="update-channels-error-hide" src="/images/remove.png"> - </div> - <div id="update-channels-warning" data-i18n="options_updateChannelsWarning"></div> - <div id="update-channels-last-checked"></div> - <div class="clearer"></div> - <div id="update-channels-list"></div> - <div id="add-update-channel-wrapper"> - <button class="button" id="add-update-channel" data-i18n="options_addUpdateChannel"></button> - <input type="text" id="update-channel-name" /> - </div> - </div> - - <a id="secretArea" href="/pages/debugging-rulesets/index.html" target="_blank" class="hidden" data-i18n="options_debuggingRulesets"></a> - - <script src="ux.js"></script> - <script src="../translation.js"></script> - <script src="../util.js"></script> - </body> -</html> diff --git a/data/extensions/https-everywhere@eff.org/pages/options/style.css b/data/extensions/https-everywhere@eff.org/pages/options/style.css deleted file mode 100644 index 032a7ba..0000000 --- a/data/extensions/https-everywhere@eff.org/pages/options/style.css +++ /dev/null @@ -1,264 +0,0 @@ -@import "../main.css"; - -body{ - display: grid; - grid-template-columns: 1fr 1fr 1fr; -} - -/*--------- -# GRID LAYOUT ----------*/ -.header-wrapper, .section-wrapper { - margin: auto; -} -.header-wrapper { - display: inline-flex; - grid-column: 2; - grid-row: 1; -} -.section-wrapper { - grid-column: 2; - grid-row: 2; -} -#add-disabled-site-wrapper { - float: left; -} -#add-update-channel-wrapper { - display: inline-block; -} - -.settings-wrapper{ - margin: 10px 0 0 0; -} - -.settings-wrapper#update-wrapper{ - margin-bottom: 20px; -} - -.settings-wrapper#show-devtools-tab-wrapper{ - margin-bottom: 20px; -} - -/** User rules Option**/ -.user-rules-wrapper-header { - font-weight: bold; - padding-left: 5px; -} -.user-rules-list-item:last-of-type { - border-bottom: none; -} -.user-rules-list-item { - border-bottom: 1px solid #ccc; - display: inline-flex; - margin-left: 5%; - width: 80%; -} -.user-rules-list-item p { - width: 100%; -} - -/** Disabled Sites Option**/ -#add-disabled-site-invalid-host { - font-weight: bold; - color: red; - display: none; -} -.disabled-rules-wrapper-header { - font-weight: bold; - padding-left: 5px; -} -img.remove{ - cursor: pointer; - float: right; - height: 15px; - margin-top: -34px; - width: 15px; -} -.disabled-rule-list-item:last-of-type { - border-bottom: none; -} -.disabled-rule-list-item { - border-bottom: 1px solid #ccc; - clear: both; -} -.disabled-rule-list-item p { - width: 80%; - word-wrap: anywhere; -} - -.section-header{ - margin-bottom: 10px; -} - -#import{ - margin-bottom: 10px; - float: right; -} - -#import-confirmed{ - display: none; -} - -.section-header-span{ - cursor: pointer; - padding: 8px; - margin-left: 0 !important; - margin-right: var(--space) !important; - display: inline-block; -} - -.section-header-span.active{ - background-color: var(--darker-blue); - color: #FFF; -} -.section-header-span.inactive{ - background-color: var(--light-grey); -} -.section-header-span.inactive:hover { - background-color: var(--darker-blue); -} - -.update-channel{ - border: 1px solid grey; - border-radius: 20px; - margin-top: 30px; - margin-bottom: 30px; - padding: 6px; -} - -.update-channel-name{ - font-weight: bold; - font-size: 14px; - margin: 10px; -} - -.update-channel-column-left { - width: 89px; - float: left; - font-size: 13px; - text-align: right; - margin-right: 10px; - min-height: 1px; -} - -.update-channel-column-right { - float: left; - width: 380px; -} - -textarea.update-channel-jwk { - width: 367px; - height: 250px; - resize: vertical; -} - -input.update-channel-path-prefix, input.update-channel-scope { - width: 367px; -} - -div.update-channel-row-scope { - margin-top: 3px; -} - -.update-channel-column-right button { - float: right; - margin: 10px; - border-radius: 7px; -} - -button#add-update-channel, button#add-disabled-site { - float: right; - height: 30px; - margin: 0px 10px 10px 10px; - padding: 6px; -} - -input#update-channel-name, input#disabled-site { - float: right; -} - -.clearer{ - clear: both; -} - -.update-channel-last-updated { - float: right; - font-weight: lighter; - font-size: 10px; -} - -div#update-channels-error, div#update-channels-warning { - margin-top: 20px; - font-weight: bold; - padding: 10px; - border-radius: 10px; -} - -div#update-channels-error { - background-color: #CC3333; - display: none; - color: white; -} - -div#update-channels-warning { - background-color: #FFCC00; - font-color: black; -} - -#update-channels-error-text{ - display: inline-block; - width: 460px; -} - -img#update-channels-error-hide { - float: right; -} - -div#update-channels-last-checked { - margin-top: 10px; - float: right; - font-weight: bold; - font-size: 10px; -} - -#update-channels-list { - display: inline-block; -} - -@keyframes flash { - from { - background: #fc0; - } - to { - background: transparent; - } -} - -#secretArea { - border-radius: 5px; - padding: 5px; -} - -.hidden { - display: none -} - -.flash { - animation: flash 1s ease-out; -} - -@media (prefers-color-scheme: dark) { - body { - background-color: #202023; - color: #f9f9fa; - } - - .section-header-span, div#update-channels-warning { - color: #000; - } - - textarea, input[type=text] { - background-color: #202023; - color: #f9f9fa; - } -} diff --git a/data/extensions/https-everywhere@eff.org/pages/options/ux.js b/data/extensions/https-everywhere@eff.org/pages/options/ux.js deleted file mode 100644 index 02ad39d..0000000 --- a/data/extensions/https-everywhere@eff.org/pages/options/ux.js +++ /dev/null @@ -1,422 +0,0 @@ -/* global sendMessage */ -/* global getOption_ */ -/* global e */ -/* global show, hide */ - -"use strict"; - -document.addEventListener("DOMContentLoaded", () => { - const secretArea = document.getElementById('secretArea'); - - const onKeyDownHandler = evt => { - if (evt.ctrlKey && evt.key === 'z') { - secretArea.classList.remove('hidden'); - secretArea.classList.add('flash'); - - sendMessage('set_option', { developerMode: true }); - - document.removeEventListener('keydown', onKeyDownHandler); - - evt.preventDefault(); - } - }; - - sendMessage('get_option', { developerMode: false }, item => { - if (item.developerMode) { - secretArea.classList.remove('hidden'); - } else { - document.addEventListener('keydown', onKeyDownHandler); - } - }); - - const autoUpdateRulesets = document.getElementById("autoUpdateRulesets"); - const enableMixedRulesets = document.getElementById("enableMixedRulesets"); - const showDevtoolsTab = document.getElementById("showDevtoolsTab"); - - const defaultOptions = { - autoUpdateRulesets: false, - enableMixedRulesets: false, - showDevtoolsTab: true - }; - - sendMessage("get_option", defaultOptions, item => { - autoUpdateRulesets.checked = item.autoUpdateRulesets; - enableMixedRulesets.checked = item.enableMixedRulesets; - showDevtoolsTab.checked = item.showDevtoolsTab; - - autoUpdateRulesets.addEventListener("change", () => { - sendMessage("set_option", { autoUpdateRulesets: autoUpdateRulesets.checked }); - }); - - enableMixedRulesets.addEventListener("change", () => { - sendMessage("set_option", { enableMixedRulesets: enableMixedRulesets.checked }); - }); - - showDevtoolsTab.addEventListener("change", () => { - sendMessage("set_option", { showDevtoolsTab: showDevtoolsTab.checked }); - }); - }); - - function onlyShowSection(sectionId) { - document.querySelectorAll('.section-wrapper').forEach(sw => { - sw.style.display = "none"; - }); - document.getElementById(sectionId).style.display = "block"; - } - onlyShowSection('general-settings-wrapper'); - - document.querySelectorAll('.section-header-span').forEach(shs => { - shs.addEventListener("click", () => { - document.querySelectorAll('.section-header-span').forEach(shs => { - shs.classList.remove("active"); - shs.classList.add("inactive"); - }); - shs.classList.remove("inactive"); - shs.classList.add("active"); - onlyShowSection(shs.dataset.show); - }); - }); - - function create_update_channel_element(update_channel, last_updated, locked) { - let ruleset_version_string; - - if(last_updated) { - const ruleset_date = new Date(last_updated * 1000); - ruleset_version_string = ruleset_date.getUTCFullYear() + "." + (ruleset_date.getUTCMonth() + 1) + "." + ruleset_date.getUTCDate(); - } else { - ruleset_version_string = "n/a"; - } - - const update_channel_div = document.createElement('div'); - update_channel_div.className = "update-channel"; - - const update_channel_name = document.createElement('div'); - update_channel_name.className = "update-channel-name"; - update_channel_name.innerText = update_channel.name; - update_channel_div.appendChild(update_channel_name); - const update_channel_last_updated = document.createElement('div'); - update_channel_last_updated.className = "update-channel-last-updated"; - update_channel_last_updated.innerText = chrome.i18n.getMessage("options_storedRulesetsVersion") + ruleset_version_string; - update_channel_name.appendChild(update_channel_last_updated); - - const update_channel_row_format = document.createElement('div'); - update_channel_row_format.className = "update-channel-row-format"; - update_channel_div.appendChild(update_channel_row_format); - const update_channel_format_column_left = document.createElement('div'); - update_channel_format_column_left.className = "update-channel-column-left"; - update_channel_format_column_left.innerText = "Format:"; - update_channel_row_format.appendChild(update_channel_format_column_left); - const update_channel_format_column_right = document.createElement('div'); - update_channel_format_column_right.className = "update-channel-column-right"; - update_channel_row_format.appendChild(update_channel_format_column_right); - const update_channel_format = document.createElement('select'); - update_channel_format.className = "update-channel-format"; - update_channel_format.setAttribute("data-name", update_channel.name); - update_channel_format.disabled = locked; - update_channel_format_column_right.appendChild(update_channel_format); - const update_channel_format_option_ruleset = document.createElement('option'); - update_channel_format_option_ruleset.value = "ruleset"; - update_channel_format_option_ruleset.innerText = "ruleset"; - update_channel_format_option_ruleset.defaultSelected = true; - update_channel_format_option_ruleset.selected = (update_channel.format == "ruleset"); - update_channel_format.appendChild(update_channel_format_option_ruleset); - const update_channel_format_option_bloom = document.createElement('option'); - update_channel_format_option_bloom.value = "bloom"; - update_channel_format_option_bloom.innerText = "bloom"; - update_channel_format_option_bloom.selected = (update_channel.format == "bloom"); - update_channel_format.appendChild(update_channel_format_option_bloom); - - const update_channel_row_jwk = document.createElement('div'); - update_channel_row_jwk.className = "update-channel-row-jwk"; - update_channel_div.appendChild(update_channel_row_jwk); - const update_channel_jwk_column_left = document.createElement('div'); - update_channel_jwk_column_left.className = "update-channel-column-left"; - update_channel_jwk_column_left.innerText = "JWK:"; - update_channel_row_jwk.appendChild(update_channel_jwk_column_left); - const update_channel_jwk_column_right = document.createElement('div'); - update_channel_jwk_column_right.className = "update-channel-column-right"; - update_channel_row_jwk.appendChild(update_channel_jwk_column_right); - const update_channel_jwk = document.createElement('textarea'); - update_channel_jwk.className = "update-channel-jwk"; - update_channel_jwk.setAttribute("data-name", update_channel.name); - update_channel_jwk.disabled = locked; - update_channel_jwk.innerText = JSON.stringify(update_channel.jwk); - update_channel_jwk_column_right.appendChild(update_channel_jwk); - - const update_channel_row_path_prefix = document.createElement('div'); - update_channel_row_path_prefix.className = "update-channel-row-path-prefix"; - update_channel_div.appendChild(update_channel_row_path_prefix); - const update_channel_path_prefix_column_left = document.createElement('div'); - update_channel_path_prefix_column_left.className = "update-channel-column-left"; - update_channel_path_prefix_column_left.innerText = "Path Prefix:"; - update_channel_row_path_prefix.appendChild(update_channel_path_prefix_column_left); - const update_channel_path_prefix_column_right = document.createElement('div'); - update_channel_path_prefix_column_right.className = "update-channel-column-right"; - update_channel_row_path_prefix.appendChild(update_channel_path_prefix_column_right); - const update_channel_path_prefix = document.createElement('input'); - update_channel_path_prefix.setAttribute("type", "text"); - update_channel_path_prefix.className = "update-channel-path-prefix"; - update_channel_path_prefix.setAttribute("data-name", update_channel.name); - update_channel_path_prefix.disabled = locked; - update_channel_path_prefix.value = update_channel.update_path_prefix; - update_channel_path_prefix_column_right.appendChild(update_channel_path_prefix); - - let clearer = document.createElement('div'); - clearer.className = "clearer"; - update_channel_div.appendChild(clearer); - - const update_channel_row_scope = document.createElement('div'); - if(update_channel.format == "bloom") { - update_channel_row_scope.style.display = "none"; - } - update_channel_row_scope.className = "update-channel-row-scope"; - update_channel_div.appendChild(update_channel_row_scope); - const update_channel_scope_column_left = document.createElement('div'); - update_channel_scope_column_left.className = "update-channel-column-left"; - update_channel_scope_column_left.innerText = "Scope:"; - update_channel_row_scope.appendChild(update_channel_scope_column_left); - const update_channel_scope_column_right = document.createElement('div'); - update_channel_scope_column_right.className = "update-channel-column-right"; - update_channel_row_scope.appendChild(update_channel_scope_column_right); - const update_channel_scope = document.createElement('input'); - update_channel_scope.setAttribute("type", "text"); - update_channel_scope.className = "update-channel-scope"; - update_channel_scope.setAttribute("data-name", update_channel.name); - update_channel_scope.disabled = locked; - update_channel_scope.value = update_channel.scope; - update_channel_scope_column_right.appendChild(update_channel_scope); - - const update_channel_row_controls = document.createElement('div'); - update_channel_row_controls.className = "update-channel-row-controls"; - update_channel_div.appendChild(update_channel_row_controls); - const update_channel_controls_column_left = document.createElement('div'); - update_channel_controls_column_left.className = "update-channel-column-left"; - update_channel_controls_column_left.innerText = " "; - update_channel_row_controls.appendChild(update_channel_controls_column_left); - const update_channel_controls_column_right = document.createElement('div'); - update_channel_controls_column_right.className = "update-channel-column-right"; - update_channel_row_controls.appendChild(update_channel_controls_column_right); - const update_channel_update = document.createElement('button'); - update_channel_update.className = "update-channel-update"; - update_channel_update.setAttribute("data-name", update_channel.name); - update_channel_update.disabled = locked; - update_channel_update.innerText = chrome.i18n.getMessage("options_update"); - update_channel_controls_column_right.appendChild(update_channel_update); - const update_channel_delete = document.createElement('button'); - update_channel_delete.className = "update-channel-update"; - update_channel_delete.setAttribute("data-name", update_channel.name); - update_channel_delete.disabled = locked; - update_channel_delete.innerText = chrome.i18n.getMessage("options_delete"); - update_channel_controls_column_right.appendChild(update_channel_delete); - - clearer = document.createElement('div'); - clearer.className = "clearer"; - update_channel_div.appendChild(clearer); - - update_channel_format.addEventListener("change", () => { - if(update_channel_format.value == "bloom") { - update_channel_row_scope.style.display = "none"; - } else { - update_channel_row_scope.style.display = "block"; - } - }); - update_channel_delete.addEventListener("click", () => { - sendMessage("delete_update_channel", update_channel.name, () => { - render_update_channels(); - }); - }); - - update_channel_update.addEventListener("click", () => { - sendMessage("update_update_channel", { - name: update_channel.name, - format: update_channel_format.value, - jwk: JSON.parse(update_channel_jwk.value), - update_path_prefix: update_channel_path_prefix.value, - scope: update_channel_scope.value - }, () => { - render_update_channels(); - }); - }); - - return update_channel_div; - } - - function render_update_channels() { - const update_channels_list = document.getElementById("update-channels-list"); - while(update_channels_list.firstChild) { - update_channels_list.removeChild(update_channels_list.firstChild); - } - - sendMessage("get_pinned_update_channels", null, item => { - for(const update_channel of item.update_channels) { - update_channels_list.appendChild( - create_update_channel_element( - update_channel, - item.last_updated[update_channel.name], - true, - ) - ); - - } - }); - - sendMessage("get_stored_update_channels", null, item => { - for(const update_channel of item.update_channels) { - update_channels_list.appendChild( - create_update_channel_element( - update_channel, - item.last_updated[update_channel.name], - update_channel.locked === true, - ) - ); - } - }); - } - render_update_channels(); - - const add_update_channel = document.getElementById("add-update-channel"); - const update_channel_name_div = document.getElementById("update-channel-name"); - const update_channels_error_text = document.getElementById("update-channels-error-text"); - const update_channels_error = document.getElementById("update-channels-error"); - update_channel_name_div.setAttribute("placeholder", chrome.i18n.getMessage("options_enterUpdateChannelName")); - - function displayError(text) { - update_channels_error_text.innerText = text; - update_channels_error.style.display = "block"; - window.scrollTo(0,0); - } - - // Get a list of user Rules - sendMessage("get_user_rules", null, userRules => { - let user_rules_parent = e("user-rules-wrapper"); - - if ( 0 === userRules.length) { - hide(user_rules_parent); - return ; - } - - // img element "remove button" - let templateRemove = document.createElement("img"); - templateRemove.src = chrome.runtime.getURL("images/remove.png"); - templateRemove.className = "remove"; - - for (const userRule of userRules) { - let user_rule_host = document.createElement("div"); - let user_rule_name = document.createElement("p"); - let remove = templateRemove.cloneNode(true); - - user_rule_host.className = "user-rules-list-item"; - user_rule_name.className = "user-rules-list-item-single"; - user_rule_name.innerText = userRule.name; - user_rule_host.appendChild(user_rule_name); - user_rules_parent.appendChild(user_rule_host); - user_rule_host.appendChild(remove); - - remove.addEventListener("click", () => { - // assume the removal is successful and hide ui element - hide( user_rule_host ); - // remove the user rule - sendMessage("remove_rule", { ruleset: userRule, src: 'options' }); - }); - } - }); - - // HTTPS Everywhere Sites Disabled section in General Settings module - getOption_("disabledList", [], function(item) { - let rule_host_parent = e("disabled-rules-wrapper"); - - // img element "remove button" - let templateRemove = document.createElement("img"); - templateRemove.src = chrome.runtime.getURL("images/remove.png"); - templateRemove.className = "remove"; - - if( item ) { - for (const key of item.disabledList) { - let rule_host = document.createElement("div"); - let remove = templateRemove.cloneNode(true); - let rule_host_site_name = document.createElement("p"); - - rule_host.className = "disabled-rule-list-item"; - rule_host_site_name.className = "disabled-rule-list-item_single"; - rule_host_site_name.innerText = key; - rule_host.appendChild( rule_host_site_name); - rule_host_parent.appendChild(rule_host); - rule_host.appendChild(remove); - - remove.addEventListener("click", () => { - hide( rule_host ); - sendMessage("enable_on_site", key); - }); - } - } - }); - - const add_disabled_site = document.getElementById("add-disabled-site"); - const disabled_site_input = document.getElementById("disabled-site"); - const add_disabled_site_invalid_host = document.getElementById('add-disabled-site-invalid-host'); - disabled_site_input.setAttribute("placeholder", chrome.i18n.getMessage("options_enterDisabledSite")); - function isValidHost(host) { - try { - new URL(`http://${host}/`); - return true; - } catch { - return false; - } - } - add_disabled_site.addEventListener("click", function() { - const host = disabled_site_input.value; - - if (isValidHost(host)) { - hide(add_disabled_site_invalid_host); - sendMessage("disable_on_site", disabled_site_input.value, okay => { - if (okay) { - chrome.tabs.reload(); - } - }); - } else { - show(add_disabled_site_invalid_host); - } - }); - - add_update_channel.addEventListener("click", () => { - const update_channel_name = update_channel_name_div.value; - if(update_channel_name.trim() == "") { - displayError("Error: The update channel name is blank. Please enter another name."); - } else { - update_channel_name_div.value = ""; - sendMessage("create_update_channel", update_channel_name, result => { - if(result == true) { - render_update_channels(); - } else { - displayError("Error: There already exists an update channel with this name."); - } - }); - } - }); - - const update_channels_error_hide = document.getElementById("update-channels-error-hide"); - update_channels_error_hide.addEventListener("click", () => { - update_channels_error.style.display = "none"; - }); - - const update_channels_last_checked = document.getElementById("update-channels-last-checked"); - sendMessage("get_last_checked", null, last_checked => { - let last_checked_string; - if(last_checked) { - const last_checked_date = new Date(last_checked * 1000); - const options = { - year: '2-digit', - month: '2-digit', - day: '2-digit', - hour: '2-digit', - minute: '2-digit', - timeZoneName: 'short' - }; - const customDateTime = new Intl.DateTimeFormat('default', options).format; - last_checked_string = customDateTime(last_checked_date); - } else { - last_checked_string = chrome.i18n.getMessage("options_updatesLastCheckedNever"); - } - update_channels_last_checked.innerText = chrome.i18n.getMessage("options_updatesLastChecked") + last_checked_string; - }); -}); diff --git a/data/extensions/https-everywhere@eff.org/pages/popup/index.html b/data/extensions/https-everywhere@eff.org/pages/popup/index.html deleted file mode 100644 index d9441f2..0000000 --- a/data/extensions/https-everywhere@eff.org/pages/popup/index.html +++ /dev/null @@ -1,105 +0,0 @@ -<!doctype html> -<html> - <head> - <meta charset="utf-8"> - <meta name="viewport" content="width=device-width, initial-scale=1"> - <title data-i18n="about_ext_name"></title> - - <link href="style.css" rel="stylesheet"> - <script src="ux.js"></script> - <script src="../translation.js"></script> - <script src="../util.js"></script> - </head> - <body> - <header> - <div class="logo-container"> - <img src="../../images/HTTPS-Everywhere-Logo.png" alt="HTTPS Everywhere logo"> - </div> - - <small> - <span data-i18n="about_version">Version</span>: <span id="current-version"></span> - <br> - <span id="rulesets-versions"></span> - </small> - </header> - - <section id="disableButton" class="options settings_block" style="visibility: hidden;"> - <div class="onoffswitch switch" aria-label="Toggle on or off"> - <h1 id="onoffswitch_label" data-i18n="menu_globalEnable"></h1> - <span class="slider round"></span> - <input aria-hidden="true" id="onoffswitch" type="checkbox" checked> <label id="onoffswitch__label" for="onoffswitch"> - </label> - </div> - </section> - - <section id="HttpNowhere" class="options settings_block" style="visibility: hidden;"> - <h1 id="HttpNowhere__header"></h1> - <input aria-hidden="true" id="http-nowhere-checkbox" type="checkbox"><label id="http-nowhere-checkbox_label" aria-label="Toggle on or off" for="http-nowhere-checkbox"></label> - <h2 id="HttpNowhere__explained"></h2> - </section> - - <section id="RuleManagement" class="settings_block"> - <section id="settingsForThisSite"> - <h1 data-i18n="chrome_settings_for_this_site_header"></h1> - <h2 data-i18n="chrome_settings_for_this_site_subheader"></h2> - </section> - <section id="disableEnableSection"> - <a href="javascript:void 0" id="disable-on-this-site" class="button" data-i18n="chrome_disable_on_this_site"></a> - <a href="javascript:void 0" id="enable-on-this-site" class="button" data-i18n="chrome_enable_on_this_site"></a> - </section> - <div id="RuleManagement__see_more--prompt" class="see_more__prompt" aria-label="Listen or See more for explanation"> - <span id="RuleManagement__see_more" class="see_more__arrow down"></span> - <span class="see_more__text" data-i18n="menu_seeMore"></span> - </div> - <div class="see_more__content hide"> - <p class="see_more--clarified" data-i18n="chrome_settings_for_this_site_explained"></p> - - <section id="addRuleSection"> - <a href="javascript:void 0" id="add-rule-link" class="button" data-i18n="chrome_add_rule"></a> - <div id="add-new-rule-div" style="display: none"> - <h3 data-i18n="about_add_new_rule"></h3> - <p data-i18n="chrome_always_https_for_host"></p> - <label for="new-rule-host" data-i18n="chrome_host" class="label_nontoggle"></label> - <input size="50" id="new-rule-host" type="text" disabled><br> - <div id="new-rule-regular-text"> - <a href="javascript:void 0" id="new-rule-show-advanced-link" class="button" data-i18n="chrome_show_advanced"></a><br> - </div> - <div id="new-rule-advanced" style="display: none"> - <a href="javascript:void 0" id="new-rule-hide-advanced-link" class="button" data-i18n="chrome_hide_advanced"></a><br> - <label for="new-rule-name" data-i18n="chrome_rule_name" class="label_nontoggle"></label> - <input size="50" id="new-rule-name" type="text"> - <label for="new-rule-regex" data-i18n="chrome_regex" class="label_nontoggle"></label> - <input size="50" id="new-rule-regex" type="text"> - <label for="new-rule-redirect" data-i18n="chrome_redirect_to" class="label_nontoggle"></label> - <input size="50" id="new-rule-redirect" type="text"> - </div> - <button id="add-new-rule-button" class="button" data-i18n="chrome_add_new_rule"></button> - <button id="cancel-new-rule" class="button" data-i18n="chrome_status_cancel_button"></button> - </div> - </section> - - <section id="StableRules" class="rules"> - <h3 data-i18n="chrome_stable_rules"></h3> - <span id="RuleManagement--counter"></span> - <h2 class="description" data-i18n="chrome_stable_rules_description"></h2> - </section> - - <section id="UnstableRules" class="rules"> - <h3 data-i18n="chrome_experimental_rules"></h3> - <h2 class="description" data-i18n="chrome_experimental_rules_description"></h2> - </section> - </div> - </section> - - <section id="resetButton" class="options"> - <a href="javascript:void 0" id="reset-to-defaults" class="button" data-i18n="prefs_reset_defaults"></a> - </section> - - <footer> - <a class="button" id="viewAllRules" href="https://atlas.eff.org/index.html" target="_blank" data-i18n="menu_viewAllRules"></a> - <a class="button" id="aboutTitle" href="https://www.eff.org/https-everywhere" target="_blank" data-i18n="about_title"></a> - <a class="button" id="donateEFF" href="https://supporters.eff.org/donate/support-https-everywhere" target="_blank" data-i18n="menu_donate_eff_imperative"></a> - </footer> - - </body> -</html> diff --git a/data/extensions/https-everywhere@eff.org/pages/popup/style.css b/data/extensions/https-everywhere@eff.org/pages/popup/style.css deleted file mode 100644 index 304f2f8..0000000 --- a/data/extensions/https-everywhere@eff.org/pages/popup/style.css +++ /dev/null @@ -1,313 +0,0 @@ -@import "../main.css"; - -body { - color: var(--text-secondary); - font-family: 'Lucida Grande', 'Segoe UI', Tahoma, 'DejaVu Sans', Arial, sans-serif; - margin: 0; - max-width: 400px; - min-width: 360px; -} - -header { - background-color: var(--light-grey); - color: var(--text-main); - display: flex; - padding: var(--space); -} - -header h1 { - font-size: 2em; -} - -header .logo-container { - margin: var(--space); - width: 85%; -} - -header .logo-container img { - width: 100%; -} - -header small { - color: #000; - display: block; - font-size: .70em; - font-weight: bold; - margin: 1%; - width: 100%; -} - -h1 { - font-size: 16px; - margin: var(--space) auto -} - -h2 { - clear: both; - font-size: 12px; - font-weight: normal; - margin: 0; -} - -h3 { - font-size: 16px; -} - -h1, -h2 { - color: var(--text-main); -} - -footer { - display: inline-flex; - margin: var(--space); -} - -footer a.button { - margin: var(--space); -} - -/* Elements */ -.settings_block { - padding: 5px 1em 20px 1em; - border-bottom: var(--light-grey) solid 1px; -} - -.see_more__prompt { - color: var(--text-main); - cursor: pointer; - font-size: 12px; - float: right; - margin: 5px 0; - padding: 10px 0; -} - -.see_more__arrow { - border: solid var(--darker-blue); - border-width: 0 3px 3px 0; - float: right; - margin-left: 10px; - margin-top: 3px; - padding: 3px; -} - -.see_more__content.show p { - font-size: 12px; - margin: 10px 0; -} - -.down { - transform: rotate(45deg); -} - -.up { - transform: rotate(-135deg); -} - -input[type=checkbox] { - opacity: 0; -} - -label { - background: grey; - border-radius: 25px; - color: var(--text-main); - cursor: pointer; - display: block; - float: right; - font-weight: bold; - height: 30px; - position: relative; - text-indent: -400px; - width: 50px; -} - -label:after { - background: #fff; - border-radius: 90px; - content: ''; - height: 20px; - left: 5px; - position: absolute; - top: 5px; - transition: 0.3s; /* Acts on transform below */ - width: 20px; -} -input:checked+label { - background: var(--https-blue); -} -/* position when checked*/ -input:checked+label:after { - left: calc(100% - 5px); - transform: translateX(-100%); -} - -.label_nontoggle { - background: none; - border-radius: 0; - color: var(--text-main); - display: block; - font-weight: normal; - height: inherit; - position: relative; - text-indent: 0; - width: auto; -} - -.label_nontoggle:after { - background: none; - border-radius: 0; - content: none; - height: auto; - left: initial; - position: relative; - top: initial; - transition: none; - width: auto; -} - -/* Specific rules */ -.rule.checkbox { - clear: both; - margin: 5% auto; -} - -.rule.checkbox .remove { - float: left; -} - -.rule.checkbox label { - font-size: 12px; - font-weight: normal; - height: 25px; - text-indent: -285px; - width: 40px; -} -.rule.checkbox label:after { - border-radius: 20px; - height: 15px; - width: 15px; -} - -#disable-on-this-site { - clear: both; -} - -#disableButton { - display: block; -} - -#HttpNowhere h1, -#disableButton h1 { - float: left; -} - -#RuleManagement { - padding: 5px 1em 10px 1em; -} - -#settingsForThisSite h1 { - float: left; -} - -#addRuleSection label, -#addRuleSection button { - font-size: 14px; - width: 100%; -} - -#addRuleSection input { - background: #fff; - border: 1px solid #000; - float: right; - margin: 5px auto; - padding: 5px; - width: 95%; -} - -#new-rule-advanced, -#new-rule-regular-text { - margin-top: 40px; -} - -#HttpNowhere { - display: block; - padding: 5px 1em; -} - -#StableRules h3 { - float: left; - margin: 10px; -} -#StableRules h2 { - margin-left: 10px; -} -#StableRules #RuleManagement--counter { - background: var(--darker-blue); - border-radius: 20px; - color: #fff; - display: block; - float: left; - font-size: 12px; - font-weight: bold; - height: 15px; - margin-top: 8px; - padding: 5px; - text-align: center; - width: 15px; -} - -/* Event based */ -.see_more--clarified { - font-size: 12px; -} - -/* Hide rules & options if the extension is off. */ -.disabled #RuleManagement, -.disabled #HttpNowhere { - display: none; -} - -/* By default the "Add a rule" link is hidden. It's shown on HTTPS sites only. */ -#addRuleSection { - display: none; -} - -#rulesets-versions { - display: block; - clear: both; -} - -.rulesets-version { - display: block; -} - -#resetButton { - display: inline-flex; - margin: 10px; - width: 95%; -} -#reset-to-defaults { - width: 100%; -} - -/* Initially hide section (until rules get added). */ -section.rules { - display: none; -} - -/* For "see more" content */ -.hide { - height: 0; - opacity: 0; - overflow: hidden; - transition: 0s; - visibility: hidden; -} - -.show { - clear: both; - opacity: 1; - transition: visibility 0s linear 0s, opacity 300ms; - visibility: visible; -} diff --git a/data/extensions/https-everywhere@eff.org/pages/popup/ux.js b/data/extensions/https-everywhere@eff.org/pages/popup/ux.js deleted file mode 100644 index f38f225..0000000 --- a/data/extensions/https-everywhere@eff.org/pages/popup/ux.js +++ /dev/null @@ -1,417 +0,0 @@ -/* global e */ -/* global hide */ -/* global show */ -/* global sendMessage */ -/* global getOption_ */ -/* global setOption_ */ - -"use strict"; - -/** - * Handles rule (de)activation in the popup - */ -function toggleRuleLine(event) { - getTab(activeTab => { - const set_ruleset = { - active: event.target.checked, - name: event.target.parentNode.innerText, - tab_id: activeTab.id, - }; - - sendMessage("set_ruleset_active_status", set_ruleset, () => { - // purge the name from the cache so that this unchecking is persistent. - sendMessage("delete_from_ruleset_cache", set_ruleset.name, () => { - // Now reload the selected tab of the current window. - chrome.tabs.reload(set_ruleset.tab_id); - }); - }); - }); -} - -/** - * @param {object} event - * @description Toggles content for user to view rules and explanations for different modes - */ -function toggleSeeMore(event) { - let target = event.target; - let content; - - if (target !== this) { - content = document.querySelector('.see_more__content'); - } else { - content = target.parentNode.querySelector('.see_more__content'); - } - - let arrow = target.parentNode.querySelector('.see_more__arrow'); - let text = target.parentNode.querySelector('.see_more__text'); - - if(arrow.classList.contains('down')) { - arrow.classList.replace('down', 'up'); - text.innerText = chrome.i18n.getMessage("menu_seeLess"); - } else if (arrow.classList.contains('up')) { - arrow.classList.replace('up', 'down'); - text.innerText = chrome.i18n.getMessage("menu_seeMore"); - } - - if (content.classList.contains('hide')) { - content.classList.replace('hide', 'show'); - } else if (content.classList.contains('show')) { - content.classList.replace('show', 'hide'); - } -} - -/** - * Creates rule lines (including checkbox and icon) for the popup - * @param rulesets - * @param list_div - * @param {string} ruleType - * @returns {*} - */ -function appendRulesToListDiv(rulesets, list_div, ruleType) { - if (rulesets && rulesets.length) { - // template parent block for each ruleset - let templateLine = document.createElement("div"); - templateLine.className = "rule checkbox"; - - // label "container" - let templateLabel = document.createElement("label"); - - // checkbox - let templateCheckbox = document.createElement("input"); - templateCheckbox.type = "checkbox"; - - // label text - let templateLabelText = document.createElement("span"); - - // img "remove" button - let templateRemove = document.createElement("img"); - templateRemove.src = chrome.runtime.getURL("images/remove.png"); - templateRemove.className = "remove"; - - templateLine.appendChild(templateCheckbox); - templateLabel.appendChild(templateLabelText); - templateLine.appendChild(templateLabel); - - let increment = 0; - - for (const ruleset of rulesets) { - increment++; - let line = templateLine.cloneNode(true); - let checkbox = line.querySelector("input[type=checkbox]"); - let label = line.querySelector("label"); - let text = line.querySelector("span"); - - // For each "id" attribute in each checkbox input and "for" attribute in label - checkbox.setAttribute("id", `${ruleType}_ruleset_${increment}`); - label.setAttribute("for", `${ruleType}_ruleset_${increment}`); - - checkbox.checked = ruleset.active; - text.innerText = ruleset.name; - - // Add listener to capture the toggle event - line.addEventListener("click", toggleRuleLine); - - if (ruleset.note && ruleset.note.length) { - line.title = ruleset.note; - - if (ruleset.note === "user rule") { - let remove = templateRemove.cloneNode(true); - line.appendChild(remove); - - remove.addEventListener("click", () => { - sendMessage("remove_rule", { ruleset, src: 'popup' }, () => { - list_div.removeChild(line); - }); - }); - } - } - list_div.appendChild(line); - } - show(list_div); - } -} - -function showHttpNowhereUI() { - // Set up checkbox for HTTP nowhere mode - getOption_('httpNowhere', false, function(item) { - if (item.httpNowhere) { - e('http-nowhere-checkbox').checked = true; - e('HttpNowhere__header').innerText = chrome.i18n.getMessage("menu_encryptAllSitesEligibleOn"); - e('HttpNowhere__explained').innerText = chrome.i18n.getMessage("menu_httpNoWhereExplainedBlocked"); - } else { - e('HttpNowhere__header').innerText = chrome.i18n.getMessage("menu_encryptAllSitesEligibleOff"); - e('HttpNowhere__explained').innerText = chrome.i18n.getMessage("menu_httpNoWhereExplainedAllowed"); - } - e('HttpNowhere').style.visibility = "visible"; - }); -}; - -// Change the UI to reflect extension enabled/disabled -function updateEnabledDisabledUI() { - getOption_('globalEnabled', true, function(item) { - e('onoffswitch').checked = item.globalEnabled; - e('disableButton').style.visibility = "visible"; - // Hide or show the rules sections - if (item.globalEnabled) { - document.body.className = ""; - e('onoffswitch_label').innerText = chrome.i18n.getMessage("menu_globalEnable"); - showHttpNowhereUI(); - } else { - document.body.className = "disabled"; - e('onoffswitch_label').innerText = chrome.i18n.getMessage("menu_globalDisable"); - } - }); -} - -// Toggle extension enabled/disabled status -function toggleEnabledDisabled() { - let extension_toggle_effect = function() { - updateEnabledDisabledUI(); - // The extension state changed, give some time for toggle animation and reload tab - setTimeout(function() { - chrome.tabs.reload(); - window.close(); - }, 1500); - }; - - getOption_('globalEnabled', true, function(item) { - setOption_('globalEnabled', !item.globalEnabled, extension_toggle_effect); - }); -} - -/** - * @description Create the list of rules for a specific tab - * @param activeTab - */ -function listRules(activeTab) { - sendMessage("get_applied_rulesets", activeTab.id, function(rulesets) { - if (rulesets) { - // show the number of potentially applicable rulesets - let counter = rulesets.length; - let counterElement = document.querySelector("#RuleManagement--counter"); - counterElement.innerText = counter; - - const stableRules = rulesets.filter(ruleset => ruleset.default_state); - const unstableRules = rulesets.filter(ruleset => !ruleset.default_state); - - appendRulesToListDiv(stableRules, e("StableRules"), 'stable'); - appendRulesToListDiv(unstableRules, e("UnstableRules"), 'unstable'); - } - - // Only show the "Add a rule" section if we're on an HTTPS page - if (/^https:/.test(activeTab.url)) { - show(e("addRuleSection")); - } - }); -} - -/** - * Fill in content into the popup on load - */ -document.addEventListener("DOMContentLoaded", function () { - getTab(tab => { - const url = new URL(tab.url); - sendMessage("check_if_site_disabled", url.host, disabled => { - if(!disabled) { - listRules(tab); - } - showEnableOrDisable(url, disabled); - }); - }); - - // Set up the enabled/disabled switch & hide/show rules - updateEnabledDisabledUI(); - e('onoffswitch').addEventListener('click', toggleEnabledDisabled); - e('http-nowhere-checkbox').addEventListener('click', toggleHttpNowhere, false); - e('RuleManagement__see_more--prompt').addEventListener('click', toggleSeeMore); - - e('reset-to-defaults').addEventListener('click', () => { - sendMessage("is_firefox", null, is_firefox => { - if (is_firefox) { - sendMessage("reset_to_defaults", null, () => { - window.close(); - }); - } else { - if (confirm(chrome.i18n.getMessage("prefs_reset_defaults_message"))) { - sendMessage("reset_to_defaults", null, () => { - window.close(); - }); - } - } - }); - }); - - // Print the extension's current version. - var the_manifest = chrome.runtime.getManifest(); - var version_info = e('current-version'); - version_info.innerText = the_manifest.version; - - let rulesets_versions = e('rulesets-versions'); - - rulesets_versions.addSpan = function(update_channel_name, ruleset_version_string) { - let timestamp_span = document.createElement("span"); - timestamp_span.className = "rulesets-version"; - timestamp_span.innerText = `${chrome.i18n.getMessage("about_rulesets_version")} ${update_channel_name}: ${ruleset_version_string}`; - this.appendChild(timestamp_span); - }; - - sendMessage("get_update_channel_timestamps", null, timestamps => { - let replaces = timestamps.some(([update_channel, timestamp]) => - update_channel.replaces_default_rulesets && timestamp > 0 - ); - if(!replaces) { - rulesets_versions.addSpan("EFF (Full, Bundled)", the_manifest.version); - } - for(let [update_channel, timestamp] of timestamps) { - if(timestamp > 0) { - let ruleset_date = new Date(timestamp * 1000); - let ruleset_version_string = ruleset_date.getUTCFullYear() + "." + (ruleset_date.getUTCMonth() + 1) + "." + ruleset_date.getUTCDate(); - - rulesets_versions.addSpan(update_channel.name, ruleset_version_string); - } - } - }); - e("aboutTitle").title = chrome.i18n.getMessage("about_title"); - e("add-rule-link").addEventListener("click", addManualRule); - e("disable-on-this-site").addEventListener("click", disableOnSite); - e("enable-on-this-site").addEventListener("click", enableOnSite); -}); - -var escapeForRegex = function( value ) { - return value.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&"); -}; - -function showEnableOrDisable(url, disabled) { - if (["http:", "https:", "ftp:"].indexOf(url.protocol) != -1) { - const disableLink = e("disable-on-this-site"); - const enableLink = e("enable-on-this-site"); - const addRuleSection = e("addRuleSection"); - const resetToDefaults = e('reset-to-defaults'); - if (disabled) { - show(enableLink); - hide(disableLink); - hide(addRuleSection); - hide(resetToDefaults); - } else { - show(disableLink); - hide(enableLink); - } - } else { - const disableEnableSection = e("disableEnableSection"); - hide(disableEnableSection); - } -} - -/** - * Handles the manual addition of rules - */ -function addManualRule() { - getTab(function(tab) { - hide(e("add-rule-link")); - show(e("add-new-rule-div")); - - const url = new URL(tab.url); - - e("new-rule-host").value = url.host; - - const escapedHost = escapeForRegex(url.host); - - e("new-rule-regex").value = `^http://${escapedHost}/`; - e("new-rule-redirect").value = `https://${url.host}/`; - e("new-rule-name").value = "Manual rule for " + url.host; - - e("add-new-rule-button").addEventListener("click", function() { - const params = { - /** - * FIXME: the current implementation forbide users setting custom - * ruleset names... - */ - name: e("new-rule-host").value, - target : [e("new-rule-host").value], - rule: [{ to: e("new-rule-redirect").value, from: e("new-rule-regex").value }], - default_off: "user rule" - }; - sendMessage("add_new_rule", params, function() { - location.reload(); - }); - }); - - e("cancel-new-rule").addEventListener("click", function() { - show(e("add-rule-link")); - hide(e("add-new-rule-div")); - }); - - e("new-rule-show-advanced-link").addEventListener("click", function() { - show(e("new-rule-advanced")); - hide(e("new-rule-regular-text")); - }); - - e("new-rule-hide-advanced-link").addEventListener("click", function() { - hide(e("new-rule-advanced")); - show(e("new-rule-regular-text")); - }); - }); -} - -/** - * Disable HTTPS Everywhere on a particular FQDN - */ -function disableOnSite() { - getTab(function(tab) { - const url = new URL(tab.url); - sendMessage("disable_on_site", url.host); - chrome.tabs.reload(tab.id); - window.close(); - }); -} - -function enableOnSite() { - getTab(function(tab) { - const url = new URL(tab.url); - sendMessage("enable_on_site", url.host); - chrome.tabs.reload(tab.id); - window.close(); - }); -} - -/** - * @description Turns EASE Mode on and off - */ -function toggleHttpNowhere() { - getTab(tab => { - getOption_('httpNowhere', false, item => { - const enabled = !item.httpNowhere; - setOption_('httpNowhere', enabled, () => { - if (enabled) { - chrome.tabs.reload(tab.id); - e('HttpNowhere__header').innerText = chrome.i18n.getMessage("menu_encryptAllSitesEligibleOn"); - e('HttpNowhere__explained').innerText = chrome.i18n.getMessage("menu_httpNoWhereExplainedBlocked"); - } else { - e('HttpNowhere__header').innerText = chrome.i18n.getMessage("menu_encryptAllSitesEligibleOff"); - e('HttpNowhere__explained').innerText = chrome.i18n.getMessage("menu_httpNoWhereExplainedAllowed"); - } - }); - }); - }); -} - -function getTab(callback) { - let url = new URL(window.location.href); - if (url.searchParams.has('tabId')) { - let parentId = Number(url.searchParams.get('tabId')); - return chrome.tabs.get(parentId, callback); - } - chrome.tabs.query({active: true, lastFocusedWindow: true}, tabs => callback(tabs[0])); -} - -// This code fixes a Chromium-specific bug that causes links in extension popup -// to open in regular tab even if the popup is opened in incognito mode. - -document.addEventListener('click', e => { - const { target } = e; - - if (target.matches('a[target="_blank"]')) { - chrome.tabs.create({ url: target.href }); - e.preventDefault(); - } -}); diff --git a/data/extensions/https-everywhere@eff.org/pages/translation.js b/data/extensions/https-everywhere@eff.org/pages/translation.js deleted file mode 100644 index c6c3163..0000000 --- a/data/extensions/https-everywhere@eff.org/pages/translation.js +++ /dev/null @@ -1,8 +0,0 @@ -"use strict"; - -document.addEventListener("DOMContentLoaded", () => { - // Auto-translate all elements with data-i18n attributes - for (const element of document.querySelectorAll("[data-i18n]")) { - element.innerText = chrome.i18n.getMessage(element.getAttribute("data-i18n")).replace(/"/g,"\""); - } -}); diff --git a/data/extensions/https-everywhere@eff.org/pages/util.js b/data/extensions/https-everywhere@eff.org/pages/util.js deleted file mode 100644 index 4e5aea4..0000000 --- a/data/extensions/https-everywhere@eff.org/pages/util.js +++ /dev/null @@ -1,46 +0,0 @@ -/* exported e */ -/* exported hide */ -/* exported show */ -/* exported sendMessage */ -/* exported getOption_ */ -/* exported setOption_ */ - -"use strict"; - -/** - * Element helper functions - */ -function e(id) { - return document.getElementById(id); -} - -function hide(elem) { - elem.style.display = "none"; -} - -function show(elem) { - elem.style.display = "block"; -} - -function sendMessage(type, object, callback) { - chrome.runtime.sendMessage({ type, object }, callback); -} - -/** -* Get an option from global settings -* @param {string} opt -* @param {mixed} defaultOpt -* @param {object} callback -* @returns mixed -*/ -function getOption_(opt, defaultOpt, callback) { - let details = {}; - details[opt] = defaultOpt; - sendMessage("get_option", details, callback); -} - -function setOption_(opt, value, callback) { - var details = {}; - details[opt] = value; - sendMessage("set_option", details, callback); -} |