-
Notifications
You must be signed in to change notification settings - Fork 0
/
options.js
117 lines (94 loc) · 4.08 KB
/
options.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
String.prototype.trim = function () {
return this.replace(/^\s*/, "").replace(/\s*$/, "");
}
function $(id) { return document.getElementById(id); }
function lines(s)
{
var links = (s ? s.split('\n') : []);
if (links)
{
for (var i = 0; i < links.length; i++)
{
if (links[i])
links[i] = links[i].trim();
if (!links[i] || links.length === 0)
{
links.splice(i, 1);
i--;
}
}
links.sort();
}
return links;
}
function init() {
$('highlight').innerText = "Ver. " + config.get('currDisplayVersion') + " - " + $('highlight').innerText;
$('useBlacklistMode').checked = config.get('useBlacklistMode');
$('whitelist').value = whitelist.join('\n');
$('blacklist').value = blacklist.join('\n');
showHideLists();
$('blockWindowOpen').checked = config.get('blockWindowOpen');
$('closeAllPopUpWindows').checked = config.get('closeAllPopUpWindows');
$('blockWindowPrompts').checked = config.get('blockWindowPrompts');
$('blockJSContextMenuAndClickIntercept').checked = config.get('blockJSContextMenuAndClickIntercept');
$('blockWindowMovingAndResize').checked = config.get('blockWindowMovingAndResize');
$('blockUnescapeEval').checked = config.get('blockUnescapeEval');
$('blockJSSelection').checked = config.get('blockJSSelection');
$('blockJSTimers').checked = config.get('blockJSTimers');
$('blockJSPrint').checked = config.get('blockJSPrint');
$('blockOnUnload').checked = config.get('blockOnUnload');
$('blockWindowTargets').checked = config.get('blockWindowTargets');
$('reloadCurrentTabOnToggle').checked = config.get('reloadCurrentTabOnToggle');
$('extendedTooltips').checked = config.get('extendedTooltips');
$('stripJSFromLinkLocations').checked = config.get('stripJSFromLinkLocations');
$('showBlockedBlinks').checked = config.get('showBlockedBlinks');
$('showPageActionButton').checked = config.get('showPageActionButton');
if (SAFARI)
{
$('showPageActionButton').enabled = false;
$('showPageActionButton').style.display = 'none';
$('div_showPageActionButton').style.display = 'none';
}
$('blockCreateEvents').checked = config.get('blockCreateEvents');
showReadyButtons();
}
function save() {
config.set('useBlacklistMode', $('useBlacklistMode').checked);
config.set('whitelist', lines($('whitelist').value));
$('whitelist').value = config.get('whitelist').join('\n');
config.set('blacklist', lines($('blacklist').value));
$('blacklist').value = config.get('blacklist').join('\n');
config.set('blockWindowOpen', $('blockWindowOpen').checked);
config.set('closeAllPopUpWindows', $('closeAllPopUpWindows').checked);
config.set('blockWindowPrompts', $('blockWindowPrompts').checked);
config.set('blockJSContextMenuAndClickIntercept', $('blockJSContextMenuAndClickIntercept').checked);
config.set('blockWindowMovingAndResize', $('blockWindowMovingAndResize').checked);
config.set('blockUnescapeEval', $('blockUnescapeEval').checked);
config.set('blockJSSelection', $('blockJSSelection').checked);
config.set('blockJSTimers', $('blockJSTimers').checked);
config.set('blockJSPrint', $('blockJSPrint').checked);
config.set('blockOnUnload', $('blockOnUnload').checked);
config.set('blockWindowTargets', $('blockWindowTargets').checked);
config.set('reloadCurrentTabOnToggle', $('reloadCurrentTabOnToggle').checked);
config.set('extendedTooltips', $('extendedTooltips').checked);
config.set('stripJSFromLinkLocations', $('stripJSFromLinkLocations').checked);
config.set('showBlockedBlinks', $('showBlockedBlinks').checked);
config.set('showPageActionButton', $('showPageActionButton').checked);
config.set('blockCreateEvents', $('blockCreateEvents').checked);
showSavedButtons();
}
function handleStorageChangeUpdateLists(event)
{
//if (SAFARI)
//alert("handleStorageChangeUpdateLists");
if (event.key === "whitelist")
{
$('whitelist').value = config.get('whitelist').join('\n');
}
else if (event.key === "blacklist")
{
$('blacklist').value = config.get('blacklist').join('\n');
}
}
// Bug: Safari does not fire "storage" events
window.addEventListener("storage", handleStorageChangeUpdateLists, false);