-
Notifications
You must be signed in to change notification settings - Fork 1
/
unchecky.js
45 lines (42 loc) · 1.19 KB
/
unchecky.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
(function(){
var rules = [
{
id: 'offerCheckbox', //id of the element to uncheck
urls: [ //urls to search in
/:\/\/get\.adobe\.com\/(.*?\/)?(reader|flashplayer)\//i
]
}
];
var warning_message = chrome.i18n.getMessage("warning");
for(i = 0; i < rules.length; i++){ //for each rule
var id = rules[i].id;
var urls = rules[i].urls;
for(j = 0; j < urls.length; j++){ //for each url
if(urls[j].test(location.href)){
/* at this time, the DOM tree is ready, but Adobe creates the checkbox
* dynamically, so we have to wait for it, using a timer
*/
setupTimer(id);
break;
}
}
}
function setupTimer(id){
var tmr = setInterval(function(){
var ck = document.getElementById(id);
if(typeof ck !== "undefined" && ck != null){
clearInterval(tmr); //stop searching
if(ck.checked){
ck.click();
}
ck.addEventListener("click", function(evt){ //warn user if manually clicks
if(ck.checked && !confirm(warning_message)){
setTimeout(function(){ //allow the browser to process the event before clicking again
ck.click();
}, 1);
}
}, false);
}
}, 200);
}
})();