Last active
June 24, 2020 03:09
-
-
Save epser/435a6bc6271fa63a467c1f1e3851a04d to your computer and use it in GitHub Desktop.
Webページのホイール操作が勝手にスムーススクロール(余韻スクロール)になるのを止めるUserScript(TamperMonkey)
This file contains 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 Anti MouseWheelEvent Killer | |
// @description blocking window.mousewheel events | |
// @namespace https://gist.github.com/epser/ | |
// @version 0.26 | |
// @author eps_r | |
// @include http://*/* | |
// @include https://*/* | |
// @exclude http://*.google.com/* | |
// @exclude https://*.google.com/* | |
// @exclude https://*.amazon.com/* | |
// @exclude https://*.amazon.co.jp/* | |
// @exclude https://twitter.com/* | |
// @exclude https://*.twitter.com/* | |
// @grant none | |
// @updateURL https://gist.githubusercontent.com/epser/435a6bc6271fa63a467c1f1e3851a04d/raw/anti_mousewheelevent_killer.user.js | |
// @downloadURL https://gist.githubusercontent.com/epser/435a6bc6271fa63a467c1f1e3851a04d/raw/anti_mousewheelevent_killer.user.js | |
// @run-at document-start | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
let fuck = function(add, name) { | |
return function() { | |
if(arguments[0].match(/^(mousewheel|wheel|onmousewheel|onwheel|DOMMouseScroll)$/)) { | |
console.debug("Blocked: " + name + "." + arguments[0]); | |
// fix "overflow: hidden" pages(restore scroll) | |
['DOMContentLoaded', 'load'].forEach( (timing) => { | |
window.addEventListener(timing, function() { | |
document.querySelector('html').style.setProperty('overflow', 'auto', 'important'); | |
document.querySelector('body').style.setProperty('overflow', 'auto', 'important'); | |
}); | |
}); | |
} else { | |
add.apply(this, arguments); | |
} | |
} | |
}; | |
let blockTargetElements = [ | |
[window, "window"], | |
[document, "document"], | |
[document.querySelector("html"), "<html>"] | |
]; | |
blockTargetElements.forEach( (elm) => { | |
elm[0].addEventListener = fuck(elm[0].addEventListener, elm[1]); | |
}); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
0.26(報告ありがとうございます)