summaryrefslogtreecommitdiff
path: root/data/extensions/https-everywhere@eff.org/pages/util.js
blob: 4e5aea4f9acdcfbcdd7f046c777edb2510812493 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
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);
}