This repository has been archived on 2020-10-11. You can view files and clone it, but cannot push or open issues or pull requests.
angularjs-batarang/inject.js

21 lines
642 B
JavaScript
Raw Normal View History

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
2014-08-04 22:42:58 +00:00
var script = window.document.createElement('script');
2014-10-14 18:54:47 +00:00
script.src = chrome.extension.getURL('dist/hint.js');
2014-08-06 21:46:25 +00:00
eventProxyElement.addEventListener('batarangDataEvent', function () {
var eventData = eventProxyElement.innerText;
chrome.extension.sendMessage(eventData);
});
2014-08-04 22:42:58 +00:00
html.setAttribute('ng-hint', '');
html.appendChild(script);