summaryrefslogtreecommitdiff
path: root/data/extensions/https-everywhere@eff.org/pages
diff options
context:
space:
mode:
Diffstat (limited to 'data/extensions/https-everywhere@eff.org/pages')
-rw-r--r--data/extensions/https-everywhere@eff.org/pages/cancel/index.html2
-rw-r--r--data/extensions/https-everywhere@eff.org/pages/cancel/ux.js19
-rw-r--r--data/extensions/https-everywhere@eff.org/pages/debugging-rulesets/index.html2
-rw-r--r--data/extensions/https-everywhere@eff.org/pages/devtools/index.html2
-rw-r--r--data/extensions/https-everywhere@eff.org/pages/options/index.html8
-rw-r--r--data/extensions/https-everywhere@eff.org/pages/options/style.css49
-rw-r--r--data/extensions/https-everywhere@eff.org/pages/options/ux.js99
-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
-rw-r--r--data/extensions/https-everywhere@eff.org/pages/send-message.js7
-rw-r--r--data/extensions/https-everywhere@eff.org/pages/util.js46
12 files changed, 297 insertions, 46 deletions
diff --git a/data/extensions/https-everywhere@eff.org/pages/cancel/index.html b/data/extensions/https-everywhere@eff.org/pages/cancel/index.html
index 94a4799..8357ab4 100644
--- a/data/extensions/https-everywhere@eff.org/pages/cancel/index.html
+++ b/data/extensions/https-everywhere@eff.org/pages/cancel/index.html
@@ -10,7 +10,9 @@
<body>
<h1 id="https-everywhere"><img src="../../images/banner-red.png" alt="HTTPS Everywhere" /></h1>
<p data-i18n="cancel_he_blocking_explainer"></p>
+ <p id="url-paragraph"><span id="url-label">URL: </span><a href="#" id="originURL"></a></p>
<script src="../translation.js"></script>
+ <script src="../util.js"></script>
<script src="ux.js"></script>
</body>
</html>
diff --git a/data/extensions/https-everywhere@eff.org/pages/cancel/ux.js b/data/extensions/https-everywhere@eff.org/pages/cancel/ux.js
index d7475dd..8afb4fb 100644
--- a/data/extensions/https-everywhere@eff.org/pages/cancel/ux.js
+++ b/data/extensions/https-everywhere@eff.org/pages/cancel/ux.js
@@ -1,3 +1,5 @@
+/* global sendMessage */
+
"use strict";
let observer;
@@ -9,6 +11,7 @@ document.addEventListener("DOMContentLoaded", () => {
} else {
observer.observe(explainer, {childList: true});
}
+ displayURL();
});
function replaceLink(explainer){
@@ -19,3 +22,19 @@ function replaceLink(explainer){
link.innerText = linkText;
explainer.innerHTML = explainer.innerHTML.replace(linkText, link.outerHTML);
}
+
+function displayURL() {
+ const cancelURL = new URL(window.location.href);
+ const originURL = decodeURI(cancelURL.searchParams.get('originURL'));
+ const originURLLink = document.getElementById('originURL');
+ originURLLink.innerText = originURL;
+
+ originURLLink.addEventListener("click", function() {
+ if (confirm(chrome.i18n.getMessage("chrome_disable_on_this_site") + '?')) {
+ const url = new URL(originURL);
+ sendMessage("disable_on_site", url.host, () => {
+ window.location = originURL;
+ });
+ }
+ });
+}
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
index bd6f743..d3e9122 100644
--- a/data/extensions/https-everywhere@eff.org/pages/debugging-rulesets/index.html
+++ b/data/extensions/https-everywhere@eff.org/pages/debugging-rulesets/index.html
@@ -19,7 +19,7 @@
<textarea id="codemirror-textarea"></textarea>
<button type="button" id="save-button">Save</button>
<div id="saved-text">Saved!</div>
- <script src="../send-message.js"></script>
+ <script src="../util.js"></script>
<script src="ux.js"></script>
</body>
</html>
diff --git a/data/extensions/https-everywhere@eff.org/pages/devtools/index.html b/data/extensions/https-everywhere@eff.org/pages/devtools/index.html
index 02711dc..940de8b 100644
--- a/data/extensions/https-everywhere@eff.org/pages/devtools/index.html
+++ b/data/extensions/https-everywhere@eff.org/pages/devtools/index.html
@@ -3,7 +3,7 @@
<head>
<meta charset="utf-8">
<title></title>
- <script src="../send-message.js"></script>
+ <script src="../util.js"></script>
<script src="ux.js"></script>
</head>
<body></body>
diff --git a/data/extensions/https-everywhere@eff.org/pages/options/index.html b/data/extensions/https-everywhere@eff.org/pages/options/index.html
index d72d279..f351d17 100644
--- a/data/extensions/https-everywhere@eff.org/pages/options/index.html
+++ b/data/extensions/https-everywhere@eff.org/pages/options/index.html
@@ -19,6 +19,12 @@
<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>
</div>
<div class="section-wrapper" id="advanced-settings-wrapper">
@@ -49,6 +55,6 @@
<script src="ux.js"></script>
<script src="../translation.js"></script>
- <script src="../send-message.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
index 0e7b545..d1ff21e 100644
--- a/data/extensions/https-everywhere@eff.org/pages/options/style.css
+++ b/data/extensions/https-everywhere@eff.org/pages/options/style.css
@@ -15,6 +15,49 @@ body{
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**/
+.disabled-rules-wrapper-header {
+ font-weight: bold;
+ padding-left: 5px;
+}
+img.remove{
+ cursor: pointer;
+ float: right;
+ height: 15px;
+ margin: 10px 0 0 8%;
+ width: 15px;
+}
+.disabled-rule-list-item:last-of-type {
+ border-bottom: none;
+}
+.disabled-rule-list-item {
+ border-bottom: 1px solid #ccc;
+ display: inline-flex;
+ margin-left: 5%;
+ width: 80%;
+}
+.disabled-rule-list-item p {
+ width: 100%;
+}
+
.section-header{
margin-bottom: 10px;
}
@@ -78,10 +121,14 @@ textarea.update-channel-jwk {
height: 250px;
}
-input.update-channel-path-prefix {
+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;
diff --git a/data/extensions/https-everywhere@eff.org/pages/options/ux.js b/data/extensions/https-everywhere@eff.org/pages/options/ux.js
index 7a4306c..deaacd9 100644
--- a/data/extensions/https-everywhere@eff.org/pages/options/ux.js
+++ b/data/extensions/https-everywhere@eff.org/pages/options/ux.js
@@ -1,4 +1,7 @@
/* global sendMessage */
+/* global getOption_ */
+/* global e */
+/* global hide */
"use strict";
@@ -116,6 +119,28 @@ document.addEventListener("DOMContentLoaded", () => {
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');
+ 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 = pinned;
+ 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);
@@ -139,7 +164,7 @@ document.addEventListener("DOMContentLoaded", () => {
update_channel_delete.innerText = chrome.i18n.getMessage("options_delete");
update_channel_controls_column_right.appendChild(update_channel_delete);
- const clearer = document.createElement('div');
+ clearer = document.createElement('div');
clearer.className = "clearer";
update_channel_div.appendChild(clearer);
@@ -153,7 +178,8 @@ document.addEventListener("DOMContentLoaded", () => {
sendMessage("update_update_channel", {
name: update_channel.name,
jwk: JSON.parse(update_channel_jwk.value),
- update_path_prefix: update_channel_path_prefix.value
+ update_path_prefix: update_channel_path_prefix.value,
+ scope: update_channel_scope.value
}, () => {
render_update_channels();
});
@@ -207,6 +233,75 @@ document.addEventListener("DOMContentLoaded", () => {
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.extension.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");
+
+ if( 0 === item.disabledList.length ){
+ hide(rule_host_parent);
+ return;
+ }
+ // img element "remove button"
+ let templateRemove = document.createElement("img");
+ templateRemove.src = chrome.extension.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);
+ });
+ }
+ }
+ });
+
add_update_channel.addEventListener("click", () => {
const update_channel_name = update_channel_name_div.value;
if(update_channel_name.trim() == ""){
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) {
diff --git a/data/extensions/https-everywhere@eff.org/pages/send-message.js b/data/extensions/https-everywhere@eff.org/pages/send-message.js
deleted file mode 100644
index da8adf5..0000000
--- a/data/extensions/https-everywhere@eff.org/pages/send-message.js
+++ /dev/null
@@ -1,7 +0,0 @@
-/* exported sendMessage */
-
-"use strict";
-
-function sendMessage(type, object, callback) {
- chrome.runtime.sendMessage({ type, object }, callback);
-}
diff --git a/data/extensions/https-everywhere@eff.org/pages/util.js b/data/extensions/https-everywhere@eff.org/pages/util.js
new file mode 100644
index 0000000..4e5aea4
--- /dev/null
+++ b/data/extensions/https-everywhere@eff.org/pages/util.js
@@ -0,0 +1,46 @@
+/* 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);
+}