Skip to content

Instantly share code, notes, and snippets.

@DanH42
Last active May 24, 2018 21:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DanH42/e3bc5ad5f9db518c6e7727f74a503e02 to your computer and use it in GitHub Desktop.
Save DanH42/e3bc5ad5f9db518c6e7727f74a503e02 to your computer and use it in GitHub Desktop.
Disables smooth scrolling on ALL websites
// ==UserScript==
// @name RoughScroll
// @namespace net.tampermonkey.roughscroll
// @version 0.2.2
// @description Disables smooth scrolling on ALL websites
// @author Hayden Schiff (oxguy3), Dan Hlavenka
// @updateURL https://gist.githubusercontent.com/DanH42/e3bc5ad5f9db518c6e7727f74a503e02/raw
// @match *://*/*
// @exclude https://www.google.com/maps*
// @grant none
// ==/UserScript==
/* jshint -W097 */
'use strict';
/*
HEY YOU! PRO-TIP:
If you want to save some bandwidth by not downloading smooth scrolling scripts,
add the following rules to the custom filters list on your favorite ad blocking
browser extension:
/jquery.nicescroll*.js
/jquery.smoothscroll*.js
/jquery.smooth-scroll*.js
/jquery-smoothscroll*.js
/jquery-smooth-scroll*.js
/nicescroll*.js
/smoothscroll*.js
/smooth-scroll*.js
/mousewheel-smooth-scroll
/surbma-smooth-scroll
/dexp-smoothscroll.js
*/
(function(){
// Classes to check against only the direct event target
var targetClasses = [
"ace_content" // ACE Editor
];
// Classes to check anywhere in the event path
var pathClasses = [
"gm-style" // Google Maps embeds
];
// a million thanks to Arnavion for showing me this trick
// source: http://stackoverflow.com/a/35611393/992504
document.body.addEventListener("wheel", function(event){
var i, j;
for(j in targetClasses)
if(event.target.classList.contains(targetClasses[j]))
return;
for(i in event.path){
if(event.path[i].classList === undefined)
continue;
for(j in pathClasses)
if(event.path[i].classList.contains(pathClasses[j]))
return;
}
event.stopPropagation();
}, true);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment