summaryrefslogtreecommitdiff
path: root/data/extensions/https-everywhere@eff.org/pages/popup
diff options
context:
space:
mode:
authorRuben Rodriguez <ruben@gnu.org>2018-11-07 23:45:25 -0500
committerRuben Rodriguez <ruben@gnu.org>2018-11-07 23:45:25 -0500
commit9fe427ff45778f53214ce110bf94fe43459491d1 (patch)
tree6e5cb35267234e58677d55141f05e2b8bcb3a43e /data/extensions/https-everywhere@eff.org/pages/popup
parent21250de51aae2f76cb33d4083d7c91d378c0055d (diff)
Updated extensions through running updated data/update-extensions.sh
Diffstat (limited to 'data/extensions/https-everywhere@eff.org/pages/popup')
-rw-r--r--data/extensions/https-everywhere@eff.org/pages/popup/index.html9
-rw-r--r--data/extensions/https-everywhere@eff.org/pages/popup/style.css4
-rw-r--r--data/extensions/https-everywhere@eff.org/pages/popup/ux.js96
3 files changed, 76 insertions, 33 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
index 21dac99..8097c5b 100644
--- a/data/extensions/https-everywhere@eff.org/pages/popup/index.html
+++ b/data/extensions/https-everywhere@eff.org/pages/popup/index.html
@@ -7,7 +7,7 @@
<link href="style.css" rel="stylesheet">
<script src="ux.js"></script>
<script src="../translation.js"></script>
- <script src="../send-message.js"></script>
+ <script src="../util.js"></script>
</head>
<body>
<header>
@@ -25,7 +25,12 @@
</section>
<div id="RuleManagement">
- <section>
+ <section id="disableEnableSection">
+ <a href="javascript:void 0" id="disable-on-this-site" data-i18n="chrome_disable_on_this_site"></a>
+ <a href="javascript:void 0" id="enable-on-this-site" data-i18n="chrome_enable_on_this_site"></a>
+ </section>
+
+ <section id="addRuleSection">
<a href="javascript:void 0" id="add-rule-link" data-i18n="chrome_add_rule"></a>
<div id="add-new-rule-div" style="display: none">
<h3 data-i18n="about_add_new_rule"></h3>
diff --git a/data/extensions/https-everywhere@eff.org/pages/popup/style.css b/data/extensions/https-everywhere@eff.org/pages/popup/style.css
index a1cc358..0d3b805 100644
--- a/data/extensions/https-everywhere@eff.org/pages/popup/style.css
+++ b/data/extensions/https-everywhere@eff.org/pages/popup/style.css
@@ -8,7 +8,7 @@ body {
margin-right: 1em;
margin-top: 0;
margin-bottom: 0;
- min-width: 20em;
+ min-width: 23em;
font-family: 'Lucida Grande', 'Segoe UI', Tahoma, 'DejaVu Sans', Arial, sans-serif;
font-size: 75%;
color: #303942;
@@ -114,7 +114,7 @@ footer {
}
/* By default the "Add a rule" link is hidden. It's shown on HTTPS sites only. */
-#add-rule-link {
+#addRuleSection {
display: none;
}
diff --git a/data/extensions/https-everywhere@eff.org/pages/popup/ux.js b/data/extensions/https-everywhere@eff.org/pages/popup/ux.js
index a35c00c..f50a928 100644
--- a/data/extensions/https-everywhere@eff.org/pages/popup/ux.js
+++ b/data/extensions/https-everywhere@eff.org/pages/popup/ux.js
@@ -1,11 +1,12 @@
+/* global e */
+/* global hide */
+/* global show */
/* global sendMessage */
+/* global getOption_ */
+/* global setOption_ */
"use strict";
-function e(id) {
- return document.getElementById(id);
-}
-
/**
* Handles rule (de)activation in the popup
*/
@@ -77,7 +78,7 @@ function appendRulesToListDiv(rulesets, list_div) {
line.appendChild(remove);
remove.addEventListener("click", () => {
- sendMessage("remove_rule", ruleset, () => {
+ sendMessage("remove_rule", { ruleset, src: 'popup' }, () => {
list_div.removeChild(line);
});
});
@@ -133,7 +134,7 @@ function toggleEnabledDisabled() {
* Create the list of rules for a specific tab
* @param activeTab
*/
-function gotTab(activeTab) {
+function listRules(activeTab) {
sendMessage("get_active_rulesets", activeTab.id, function(rulesets) {
if (rulesets) {
const stableRules = rulesets.filter(ruleset => ruleset.default_state);
@@ -146,9 +147,9 @@ function gotTab(activeTab) {
e("RuleManagement").addEventListener("click", toggleRuleLine);
}
- // Only show the "Add a rule" link if we're on an HTTPS page
+ // Only show the "Add a rule" section if we're on an HTTPS page
if (/^https:/.test(activeTab.url)) {
- show(e("add-rule-link"));
+ show(e("addRuleSection"));
}
});
}
@@ -157,7 +158,15 @@ function gotTab(activeTab) {
* Fill in content into the popup on load
*/
document.addEventListener("DOMContentLoaded", function () {
- getTab(gotTab);
+ 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();
@@ -192,6 +201,8 @@ document.addEventListener("DOMContentLoaded", function () {
});
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);
});
@@ -199,12 +210,25 @@ var escapeForRegex = function( value ) {
return value.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&");
};
-function hide(elem) {
- elem.style.display = "none";
-}
-
-function show(elem) {
- elem.style.display = "block";
+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);
+ }
}
/**
@@ -227,9 +251,14 @@ function addManualRule() {
e("add-new-rule-button").addEventListener("click", function() {
const params = {
- host : e("new-rule-host").value,
- redirectTo : e("new-rule-redirect").value,
- urlMatcher : e("new-rule-regex").value
+ /**
+ * 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();
@@ -253,22 +282,31 @@ function addManualRule() {
});
}
-function toggleHttpNowhere() {
- getOption_('httpNowhere', false, function(item) {
- setOption_('httpNowhere', !item.httpNowhere);
+/**
+ * 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 getOption_(opt, defaultOpt, callback) {
- var details = {};
- details[opt] = defaultOpt;
- sendMessage("get_option", details, callback);
+function enableOnSite() {
+ getTab(function(tab) {
+ const url = new URL(tab.url);
+ sendMessage("enable_on_site", url.host);
+ chrome.tabs.reload(tab.id);
+ window.close();
+ });
}
-function setOption_(opt, value, callback) {
- var details = {};
- details[opt] = value;
- sendMessage("set_option", details, callback);
+function toggleHttpNowhere() {
+ getOption_('httpNowhere', false, function(item) {
+ setOption_('httpNowhere', !item.httpNowhere);
+ });
}
function getTab(callback) {