My greasemonkey script have two javascript file, How can I make sure my second file doesn't load until the first file completes ?
// ==UserScript==
// @name hello greasemonkey
// @namespace http://localhost/test_monkey/
// @description noob studing
// @include http://localhost/test_monkey/test_monkey.html
// ==/UserScript==
loadJsOrCssFile('http://localhost/test_monkey/js/first.js', 'js');`
loadJsOrCssFile('http://localhost/test_monkey/js/second.js', 'js');`
function loadJsOrCssFile(sFileName, sFileType) {
if (sFileType == 'js') {
var sFileref = document.createElement('script');
sFileref.setAttribute('type', 'text/javascript');
sFileref.setAttribute('src', sFileName);
}
else if (sFileType == 'css') {
var sFileref = document.createElement('link');
sFileref.setAttribute('rel', 'stylesheet');
sFileref.setAttribute('type', 'text/css');
sFileref.setAttribute('href', sFileName);
}
if (typeof sFileref != 'undefined')`enter code here`
document.getElementsByTagName('head') [0].appendChild(sFileref);
}
There is a setting in the TamperMonkey script settings for each script called "run at" and you can set that to "document-end"
I am not as familiar with GreaseMonkey, but maybe there is a similar setting?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With