-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathextra.js
More file actions
36 lines (36 loc) · 783 Bytes
/
extra.js
File metadata and controls
36 lines (36 loc) · 783 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
34
35
36
(function(){
var tids = {}, tid = 0;
window.setTimeout = function(cb, t) {
var ctn = 0;
tid++;
while(tid in tids) {
tid++;
}
var data = {
cmd: 'setTimeout',
t: t,
tid: tid
};
var curtid = tid;
chrome.extension.sendRequest(data, function(response){
if (response.state === 'complete' && (curtid in tids)) {
if (typeof cb === 'function')
cb();
else if (typeof cb === 'string') {
eval(cb);
}
delete tids[curtid];
}
});
tids[tid] = tid;
return tid;
}
window.clearTimeout = function(tid) {
var data = {
cmd: 'clearTimeout',
tid: tid
};
chrome.extension.sendRequest(data, function(){});
delete tids[tid];
}
})();