summaryrefslogtreecommitdiff
path: root/data/extensions/https-everywhere@eff.org/util.js
diff options
context:
space:
mode:
authorRuben Rodriguez <ruben@gnu.org>2018-02-25 20:04:31 -0500
committerRuben Rodriguez <ruben@gnu.org>2018-02-25 20:04:31 -0500
commit229240370f009a7ba1dc31f57bcfcbd2cf785d0a (patch)
treedefa51219f44d19451bbcfd1e8298eadb1e3f4b7 /data/extensions/https-everywhere@eff.org/util.js
parentf2a3be07039056c76e3ca4e6040ec900ba64f376 (diff)
Updated extensions
- HTTPS Everywhere updated to 2018.1.11 - "goteo.org payments with free JS" updated to 1.1 - "LibreJS compatible Pay.gov" updated to 1.3 - "Reveal hidden HTML" updated to 1.6 - Enabled WebRTC, but prevent leaking the LAN ip.
Diffstat (limited to 'data/extensions/https-everywhere@eff.org/util.js')
-rw-r--r--data/extensions/https-everywhere@eff.org/util.js65
1 files changed, 65 insertions, 0 deletions
diff --git a/data/extensions/https-everywhere@eff.org/util.js b/data/extensions/https-everywhere@eff.org/util.js
new file mode 100644
index 0000000..30ef70b
--- /dev/null
+++ b/data/extensions/https-everywhere@eff.org/util.js
@@ -0,0 +1,65 @@
+"use strict";
+
+(function(exports) {
+
+var VERB = 1;
+var DBUG = 2;
+var INFO = 3;
+var NOTE = 4;
+var WARN = 5;
+// FYI: Logging everything is /very/ slow. Chrome will log & buffer
+// these console logs even when the debug tools are closed. :(
+
+// TODO: Add an easy UI to change the log level.
+// (Developers can just type DEFAULT_LOG_LEVEL=VERB in the console)
+var DEFAULT_LOG_LEVEL = NOTE;
+console.log("Hey developer! Want to see more verbose logging?");
+console.log("Type this into the console: DEFAULT_LOG_LEVEL=VERB");
+console.log("Accepted levels are VERB, DBUG, INFO, NOTE and WARN, default is NOTE");
+
+function log(level, str) {
+ if (level >= DEFAULT_LOG_LEVEL) {
+ if (level === WARN) {
+ // Show warning with a little yellow icon in Chrome.
+ console.warn(str);
+ } else {
+ console.log(str);
+ }
+ }
+}
+
+/**
+ * Load a file packaged with the extension
+ *
+ * @param url: a relative URL to local file
+ */
+function loadExtensionFile(url, returnType) {
+ var xhr = new XMLHttpRequest();
+ // Use blocking XHR to ensure everything is loaded by the time
+ // we return.
+ xhr.open("GET", chrome.extension.getURL(url), false);
+ xhr.send(null);
+ // Get file contents
+ if (xhr.readyState !== 4) {
+ return;
+ }
+ if (returnType === 'xml') {
+ return xhr.responseXML;
+ }
+ if (returnType === 'json') {
+ return JSON.parse(xhr.responseText);
+ }
+ return xhr.responseText;
+}
+
+Object.assign(exports, {
+ VERB,
+ DBUG,
+ INFO,
+ NOTE,
+ WARN,
+ log,
+ loadExtensionFile
+});
+
+})(typeof exports == 'undefined' ? require.scopes.util = {} : exports);