[LIBRARY] InjectorLib

Contains several functions for injecting html/js/css

Questo script non dovrebbe essere installato direttamente. È una libreria per altri script da includere con la chiave // @require https://update.greatest.deepsurf.us/scripts/40894/266335/%5BLIBRARY%5D%20InjectorLib.js

  1. // ==UserScript==
  2. // @name [LIBRARY] InjectorLib
  3. // @namespace http://thebone.ml/tampermonkey
  4. // @version 1.0
  5. // @updateURL http://thebone.ml/tampermonkey/ressource
  6. // @downloadURL http://thebone.ml/tampermonkey/
  7. // @description Contains several functions for injecting html/js/css
  8. // @author TheBone
  9. // ==/UserScript==
  10.  
  11. function inject_srcjs(link) {
  12. $('<script type="text/javascript" src="' + link + '"/>').appendTo($('head'));
  13. }
  14. function inject_rawjs(jsstring) {
  15. $('<script type="text/javascript">' + jsstring + '</string>').appendTo($('head'));
  16. }
  17. function inject_headhtml(htmlstring) {
  18. $(htmlstring).appendTo($('head'));
  19. }
  20. function inject_bodyhtml(htmlstring) {
  21. $(htmlstring).appendTo($('body'));
  22. }
  23. function inject_customhtml(htmlstring, appendto) {
  24. $(htmlstring).appendTo($(appendto));
  25. }
  26. function inject_globalcss(css) {
  27. var head, style;
  28. head = document.getElementsByTagName('head')[0];
  29. if (!head) {
  30. return;
  31. }
  32. style = document.createElement('style');
  33. style.type = 'text/css';
  34. style.innerHTML = css;
  35. head.appendChild(style);
  36. }