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
2014-10-22 07:43:29 -07:00

21 lines
642 B
JavaScript

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);