-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathvk-chrome-injector.js
59 lines (53 loc) · 1.37 KB
/
vk-chrome-injector.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
49
50
51
52
53
54
55
56
57
58
59
function addScript(url) {
var s = document.createElement('script');
s.src = chrome.extension.getURL(url);
(document.body||document.documentElement).appendChild(s);
}
function startWaitingForjQuery() {
var s = document.createElement('script');
s.id = 'jQuerycheckah';
s.innerHTML = "function checkJq() {\
if (typeof jQuery !== 'undefined') {\
jQuery(document.body).append(jQuery('<div id=\"jQueryhere\">'));\
jQuery('#jQuerycheckah').remove();\
} else {\
setTimeout(checkJq, 0);\
}\
}\
\
checkJq();";
document.head.appendChild(s);
hasJq = 0;
}
function isjQueryLoaded() {
if (hasJq == 1)
return hasJq;
var here = document.getElementById('jQueryhere');
if (here !== null) {
here.parentNode.removeChild(here);
hasJq = 1;
} else {
hasJq = 0;
}
return hasJq;
}
function addScriptIfjQuery(url) {
if (isjQueryLoaded()) {
addScript(url);
} else {
setTimeout(function() {addScriptIfjQuery(url)}, 0);
}
}
function addStylesheet(url) {
var s = document.createElement('link');
s.rel = 'stylesheet';
s.href = chrome.extension.getURL(url);
(document.head||document.documentElement).appendChild(s);
}
addScript('jquery.js');
startWaitingForjQuery();
addScriptIfjQuery('autocomplete.js');
addScriptIfjQuery('scrollock.js');
addScriptIfjQuery('stavklassobject.js');
addScriptIfjQuery('vk.js');
addStylesheet('stavklass.css');