-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontent.js
48 lines (39 loc) · 1006 Bytes
/
content.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
var finger = chrome.extension.getURL('images/finger.png');
var style = $('<style>.f-trump { cursor: url(' + finger + ') 12 2, auto !important; }</style>');
$('head').append(style);
$.expr[":"].Contains = $.expr.createPseudo(function(arg) {
return function( elem ) {
return $(elem).text().toUpperCase().indexOf(arg.toUpperCase()) >= 0;
};
});
function tagTrump(){
$('body :not(script):Contains(trump)').each(function (){
if ($(this.children).find(':Contains(trump)').length === 0){
$(this).addClass('f-trump');
}
});
}
function observe(){
function process(){
tagTrump();
}
var timeout;
function setDelay(){
clearTimeout(timeout);
timeout = setTimeout(process, 500);
}
var config = {
attributes: true,
childList: true,
characterData: true,
subtree: true
};
var observer = new MutationObserver(function (mutations) {
setDelay();
});
observer.observe(document, config);
}
tagTrump();
$(function (){
observe();
});