-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontent_inject.js
35 lines (30 loc) · 947 Bytes
/
content_inject.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
var injectScript = function(func) {
var actualCode = '(' + func + ')();';
var script = document.createElement('script');
script.textContent = actualCode;
(document.head||document.documentElement).appendChild(script);
script.remove();
}
var injectCss = function(domRoot, src) {
var li = domRoot.createElement('link');
li.type = 'text/css';
li.rel = 'stylesheet';
li.href = chrome.extension.getURL(src);
domRoot.head.appendChild(li);
}
var injectHooks = function() {
var _oldViewRecord = viewRecord;
viewRecord = function(args) {
_oldViewRecord.apply(this, arguments);
var event = new Event('afterViewRecord');
document.body.dispatchEvent(event);
}
viewRecord._overridenMethod = _oldViewRecord;
// For development
//viewRecord('753','33','',window,'','','','','','','','');
}
var removeHooks = function() {
if (!!(viewRecord._overridenMethod)) {
viewRecord = viewRecord._overridenMethod;
}
}