-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbackground.html
More file actions
33 lines (28 loc) · 949 Bytes
/
background.html
File metadata and controls
33 lines (28 loc) · 949 Bytes
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
<html>
<script type="text/javascript">
var blacklistRegex,
domainRegex = new RegExp('http://([^/]+)', 'i'),
escapeRegex = (function() {
var specials = [ ".", "*", "+", "?", "|", "(", ")", "[", "]", "{", "}", "\\" ];
return new RegExp( "(\\" + specials.join("|\\") + ")", "g" );
})(),
defaultDomains = ['tynt.com', 'intellitxt.com', 'vibrantmedia.com', 'snap.com'].join("\n");
function escapeDomain(s) {
return s.replace(escapeRegex, "\\$1");
}
function rebuildPattern() {
domains = (localStorage['domains'] || defaultDomains);
domains = domains.split("\n").map(escapeDomain);
blacklistRegex = domains.length > 0 ?
"(^|\\.)(" + domains.join("|") + ')$' :
null;
}
rebuildPattern();
// Send regex to content script when they request it.
chrome.extension.onRequest.addListener(
function(request, sender, sendResponse) {
sendResponse(blacklistRegex);
}
);
</script>
</html>