Block online_current.js

Blocks the online_current.js script from loading

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         Block online_current.js
// @namespace    https://instructure-uploads.s3.amazonaws.com/
// @version      1.0
// @description  Blocks the online_current.js script from loading
// @match        *://*.instructure.com/*
// @match        *://instructure-uploads.s3.amazonaws.com/*
// @run-at       document-start
// @grant        none
// ==/UserScript==

(function() {
    var observer = new MutationObserver(function(mutations, observer) {
        var scripts = document.querySelectorAll("script[src*='online_current.js']");
        scripts.forEach(script => {
            script.remove(); // Remove the script if found
            console.log("Blocked: " + script.src);
        });
    });

    observer.observe(document, { childList: true, subtree: true });

    // Prevent the script from being added dynamically
    const originalCreateElement = document.createElement;
    document.createElement = function(tagName, options) {
        if (tagName.toLowerCase() === 'script') {
            const scriptElement = originalCreateElement.apply(this, arguments);
            Object.defineProperty(scriptElement, 'src', {
                set: function(value) {
                    if (value.includes('online_current.js')) {
                        console.log("Blocked script injection: " + value);
                        return;
                    }
                    scriptElement.setAttribute('src', value);
                },
                get: function() {
                    return scriptElement.getAttribute('src');
                }
            });
            return scriptElement;
        }
        return originalCreateElement.apply(this, arguments);
    };
})();