Load external script

Tool to let you load external scripts

Dieses Skript sollte nicht direkt installiert werden. Es handelt sich hier um eine Bibliothek für andere Skripte, welche über folgenden Befehl in den Metadaten eines Skriptes eingebunden wird // @require https://update.greatest.deepsurf.us/scripts/33853/222461/Load%20external%20script.js

  1. // ==UserScript==
  2. // @name Load external script
  3. // @description Tool to let you load external scripts
  4. // @version 1
  5. // @author A Meaty Alt
  6. // @grant none
  7. // ==/UserScript==
  8.  
  9. function loadScript(scriptURL) {
  10. 'use strict';
  11. function httpGetAsync(theUrl, callback) {
  12. var xmlHttp = new XMLHttpRequest();
  13. xmlHttp.onreadystatechange = function() {
  14. if (xmlHttp.readyState == 4 && xmlHttp.status == 200)
  15. callback(xmlHttp.responseText);
  16. }
  17. xmlHttp.open("GET", theUrl, true); // true for asynchronous
  18. xmlHttp.send(null);
  19. }
  20. return new Promise(function(resolve){
  21. httpGetAsync(scriptURL, function(response){
  22. var s = document.createElement("script");
  23. s.text = response;
  24. document.getElementsByTagName("head")[0].appendChild(s);
  25. resolve();
  26. });
  27. });
  28.  
  29. }