-
Notifications
You must be signed in to change notification settings - Fork 2
/
inject.js
16 lines (16 loc) · 763 Bytes
/
inject.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
/**
* injectScript - Inject internal script to available access to the `window`
*
* @param {type} file_path Local path of the internal script.
* @param {type} tag The tag as string, where the script will be append (default: 'body').
* @see {@link http://stackoverflow.com/questions/20499994/access-window-variable-from-content-script}
* @author nok - https://gist.github.com/nok/a98c7c5ce0d0803b42da50c4b901ef84
*/
function injectScript(file_path, tag) {
var node = document.getElementsByTagName(tag)[0];
var script = document.createElement('script');
script.setAttribute('type', 'text/javascript');
script.setAttribute('src', file_path);
node.appendChild(script);
}
injectScript(chrome.runtime.getURL('contentScript.js'), 'body');