Skip to content

prevent tampermonkey scripts from running on your website / online game

Notifications You must be signed in to change notification settings

emlinhax/anti-tampermonkey

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 

Repository files navigation

anti-monkey

prevent tampermonkey scripts from running on your website / online game.
this also works against tampermonkey's "instant injection" mode :)

how it works:

whenever tampermonkey injects a script, it has to run that script somehow.
turns out that it has to modify the "document" root for that (reference).
to catch this, we just register a mutation observer and wait for a script to be injected! \

code

this code has to be placed into a script tag with the "defer" attribute.
i recommend putting it above everything else due to execution order. \

const observer = new MutationObserver((mutations) => {
    mutations.forEach((mutation) => {
        if(mutation.addedNodes != null && mutation.addedNodes.length > 0)
        {
            for(var addedNode of mutation.addedNodes)
            {
                if(addedNode.innerHTML.includes("==UserScript=="))
                {
                    alert("cheater detected!")  // do whatever you want here. ban player, close tab, whatever
                }
            }
        }
        console.log(mutation)
    });
});

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

About

prevent tampermonkey scripts from running on your website / online game

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published