diff options
Diffstat (limited to 'data/extensions/https-everywhere@eff.org/pages/popup')
3 files changed, 0 insertions, 835 deletions
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(); - } -}); |