Skip to content

Instantly share code, notes, and snippets.

@SebastianGrans
Last active November 28, 2022 08:29
Show Gist options
  • Save SebastianGrans/3c85de8c84e32a7a9af93a7b33018356 to your computer and use it in GitHub Desktop.
Save SebastianGrans/3c85de8c84e32a7a9af93a7b33018356 to your computer and use it in GitHub Desktop.
Disable scroll hijacking

Some websites hijack the scrollwheel in order to implement smooth scrolling and other annoying stuff. The following javascript snippet can disable such features.

Create a bookmark, and add the javascript code to the address part of the bookmark. When you stumble upon a hijacking website, you simply click on the bookmark.

You can also use extensions like tampermonkey to automate this process.

Source: https://superuser.com/a/1263145

javascript:(function(){document.getElementsByTagName("body")[0].addEventListener("wheel",function (event) {if (event.target.classList.contains('ace_content')) {return;}event.stopPropagation();}, true);})();

The same code in a more readable form:

javascript: (function() {
    document.getElementsByTagName("body")[0].addEventListener("wheel", function(event) {
        if (event.target.classList.contains('ace_content')) {
            return;
        }
        event.stopPropagation();
    }, true);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment