Block online_current.js

Blocks the online_current.js script from loading

  1. // ==UserScript==
  2. // @name Block online_current.js
  3. // @namespace https://instructure-uploads.s3.amazonaws.com/
  4. // @version 1.0
  5. // @description Blocks the online_current.js script from loading
  6. // @match *://*.instructure.com/*
  7. // @match *://instructure-uploads.s3.amazonaws.com/*
  8. // @run-at document-start
  9. // @grant none
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. var observer = new MutationObserver(function(mutations, observer) {
  14. var scripts = document.querySelectorAll("script[src*='online_current.js']");
  15. scripts.forEach(script => {
  16. script.remove(); // Remove the script if found
  17. console.log("Blocked: " + script.src);
  18. });
  19. });
  20.  
  21. observer.observe(document, { childList: true, subtree: true });
  22.  
  23. // Prevent the script from being added dynamically
  24. const originalCreateElement = document.createElement;
  25. document.createElement = function(tagName, options) {
  26. if (tagName.toLowerCase() === 'script') {
  27. const scriptElement = originalCreateElement.apply(this, arguments);
  28. Object.defineProperty(scriptElement, 'src', {
  29. set: function(value) {
  30. if (value.includes('online_current.js')) {
  31. console.log("Blocked script injection: " + value);
  32. return;
  33. }
  34. scriptElement.setAttribute('src', value);
  35. },
  36. get: function() {
  37. return scriptElement.getAttribute('src');
  38. }
  39. });
  40. return scriptElement;
  41. }
  42. return originalCreateElement.apply(this, arguments);
  43. };
  44. })();