Я использую MutationObserver, чтобы выяснить, когда загружается событие сценария, и если да, то удалить его и поместить сценарий на нем.
Код: Выделить всё
// ==UserScript==
// @name Block Scripts Before Execution
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Run a script before any other scripts on the page
// @author You
// @match *://*/*
// @grant none
// @run-at document-start
// ==/UserScript==
(function() {
'use strict';
// Use MutationObserver to watch for script elements being added to the DOM
const observer = new MutationObserver((mutationsList, observer) => {
for (let mutation of mutationsList) {
if (mutation.type === 'childList') {
for (let node of mutation.addedNodes) {
if (node.tagName === 'SCRIPT') {
console.log('Blocked script:', node.src || 'inline script');
node.remove(); // Block the script by removing it
}
}
}
}
});
// Start observing the DOM for new script tags
observer.observe(document.head, {
childList: true,
subtree: true
});
})();
Или он будет пакетирован, а затем вызван?< /p>
Потому что обязательно заменить скрипт до запуска window.DOMContentLoaded.>
Подробнее здесь: https://stackoverflow.com/questions/793 ... ll-batched
Мобильная версия