forked from angular/batarang
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinject.js
28 lines (20 loc) · 821 Bytes
/
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
if (document.cookie.indexOf('__ngDebug=true') != -1) {
bootstrapHint();
}
function bootstrapHint () {
chrome.extension.sendMessage('refresh');
var html = document.getElementsByTagName('html')[0];
var eventProxyElement = document.createElement('div');
eventProxyElement.id = '__ngBatarangElement';
eventProxyElement.style.display = 'none';
html.appendChild(eventProxyElement);
// inject into the application context from the content script context
var script = window.document.createElement('script');
script.src = chrome.extension.getURL('dist/hint.js');
eventProxyElement.addEventListener('batarangDataEvent', function () {
var eventData = eventProxyElement.innerText;
chrome.extension.sendMessage(eventData);
});
html.setAttribute('ng-hint', '');
html.appendChild(script);
}