Last active
May 24, 2018 21:27
-
-
Save DanH42/e3bc5ad5f9db518c6e7727f74a503e02 to your computer and use it in GitHub Desktop.
Disables smooth scrolling on ALL websites
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==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