-
Notifications
You must be signed in to change notification settings - Fork 0
/
background.html
124 lines (106 loc) · 3.42 KB
/
background.html
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
118
119
120
121
122
<html>
<head>
<script src="common/port.js"></script>
<script src="common/config.js"></script>
<script src="background.js"></script>
<script type = "text/javascript">
function fixRegularExpressions()
{
for (var i=0; i < whitelist.length; i++)
{
if (whitelist[i] == "^(http[s]?:\/\/[a-z0-9\._-]+\.|http[s]?:\/\/)google\.[a-z]+($|\/)")
{
whitelist[i] = "^(http[s]?:\\/\\/[a-z0-9\\._-]+\\.|http[s]?:\\/\\/)google\\.[a-z]+($|\\/)";
}
else if (whitelist[i] == "^(http[s]?:\/\/[a-z0-9\._-]+\.|http[s]?:\/\/)youtube\.[a-z]+($|\/)")
{
whitelist[i] = "^(http[s]?:\\/\\/[a-z0-9\\._-]+\\.|http[s]?:\\/\\/)youtube\\.[a-z]+($|\\/)";
}
else if (whitelist[i] == "^(http[s]?:\/\/[a-z0-9\._-]+\.|http[s]?:\/\/)pezcyclingnews\.[a-z]+($|\/)")
{
whitelist[i] = "^(http[s]?:\\/\\/[a-z0-9\\._-]+\\.|http[s]?:\\/\\/)pezcyclingnews\\.[a-z]+($|\\/)";
}
}
config.set("whitelist", whitelist);
}
if (config.get('currVersion') < 200001006)
{
var currVersion = config.get('currVersion');
// We used incorrectly escaped regular expressions in versions previous to 1.2 so we are trying
// to fix the default ones here
if (currVersion < 100200000)
{
fixRegularExpressions();
}
if (currVersion < 200000000)
{
// document.createEvents is often used legitimately, so we are now allowing it by default
config.set("blockCreateEvents", false);
// The option to show extended tooltips and stripping javascript from links was split so this is reset
config.set("extendedTooltips", false);
}
if (currVersion < 200001006)
{
// Some users were having site compatiblity issues when blocking window targets so we are resetting it for everyone.
config.set("blockWindowTargets", false);
}
config.set('currVersion', 200001006);
config.set('currDisplayVersion', "2.1.6");
}
config.set('globalAllowAll', false);
config.set('tempList', new Array());
const maxBlinks = 6;
var lastAnimatedTab = null;
var animationTimer = null;
if (SAFARI)
{
safari.application.addEventListener("validate", validateCommand, false);
safari.application.addEventListener("command", performCommand, false);
//safari.application.addEventListener("message", handleMessage, false);
for (var i = 0; i < safari.application.browserWindows.length; i++)
{
var currWindow = safari.application.browserWindows[i];
for (var j = 0; j < currWindow.tabs.length; j++)
{
currWindow.tabs[j].url = currWindow.tabs[j].url;
}
}
}
else
{
chrome.tabs.onUpdated.addListener(function(tabid, changeinfo, tab) {
// Do I really need to cancel the animation here?
if (animationTimer && tab.id === lastAnimatedTab)
{
clearTimeout(animationTimer);
lastAnimatedTab = null;
animationTimer = null;
}
if (config.get('showPageActionButton'))
{
if (urlsGloballyAllowed || isAllowed(tab.url))
{
chrome.pageAction.setIcon({path: "IconAllowed.png", tabId: tab.id});
}
else
{
chrome.pageAction.setIcon({path: "IconForbidden.png", tabId: tab.id});
}
chrome.pageAction.show(tab.id);
}
else
{
chrome.pageAction.hide(tab.id);
}
});
chrome.windows.onCreated.addListener(
function(wnd) {
// valid values for type: normal, popup
if (wnd.type === "popup" && config.get("globalAllowAll") !== true && config.get("closeAllPopUpWindows") === true)
chrome.windows.remove(wnd.id);
}
);
}
</script>
</head>
</html>