-
Notifications
You must be signed in to change notification settings - Fork 4
/
top.js
55 lines (48 loc) · 1.84 KB
/
top.js
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
47
48
49
50
51
52
53
54
55
/* jshint esversion:6 */
// the config itself.
var current_config = null;
var current_settings = null;
var runReplacementOnce = function(elems = null, img_elems = null) {
var tc = new TextChanger(current_settings, current_config);
tc.run(elems);
var ic = new ImageChanger(current_settings, current_config);
ic.run(img_elems);
};
function getRunnableActions(config_actions, items) {
// generate a shortened list of actions that the user has enabled
var actions_to_run = [];
var action_names = Object.keys(current_config.actions);
for (var i = 0; i < action_names.length; i++) {
var action_name = action_names[i];
var enable_this = true;
if (items.hasOwnProperty('enabled_actions') &&
items.enabled_actions.hasOwnProperty(action_name)) {
enable_this = items.enabled_actions[action_name];
} else if (current_config.actions[action_name].hasOwnProperty('default_enabled')) {
enable_this = Boolean(config_actions[action_name].default_enabled);
}
if (enable_this) actions_to_run.push(action_name);
}
return actions_to_run;
}
var ct = new ControlTimers(runReplacementOnce);
function init() {
set_initial_url(function() {
chrome.storage.local.get(null,
function(settings) {
current_settings = settings;
ct.preconfig_init(settings);
if (settings.hasOwnProperty('insult_style')) {
createAndSetStyle(defaults.insult_cssname, settings.insult_style);
}
loadConfig(settings, function(err, res) {
if (!err) {
current_config = res;
ct.postconfig_init(res,settings);
}
});
});
});
}
log("starting");
setTimeout(init, 500);