Instantly share code, notes, and snippets.

Embed
What would you like to do?
Webページのホイール操作が勝手にスムーススクロールになるのを止めるTamperMonkey Script
// ==UserScript==
// @name Anti MouseWheelEvent Killer
// @description blocking window.mousewheel events
// @namespace https://gist.github.com/epser/
// @version 0.221
// @author eps_r
// @include http://*/*
// @include https://*/*
// @grant none
// @updateURL https://gist.github.com/epser/435a6bc6271fa63a467c1f1e3851a04d/raw/a66d5c2001abf68f55077cbaee1b25d2ed0bf987/anti_mousewheelevent_killer.user.js
// @downloadURL https://gist.github.com/epser/435a6bc6271fa63a467c1f1e3851a04d/raw/a66d5c2001abf68f55077cbaee1b25d2ed0bf987/anti_mousewheelevent_killer.user.js
// @run-at document-start
// ==/UserScript==
(function() {
'use strict';
var fuck = function(add, name) {
return function() {
if(arguments[0] === "mousewheel" ||
arguments[0] === "wheel" ||
arguments[0] === "onmousewheel" ||
arguments[0] === "onwheel" ||
arguments[0] === "DOMMouseScroll"
) {
console.debug("Blocked " + name + ".mousewheel event.");
// fix "overflow: hidden" pages(restore scroll)
window.addEventListener('load', function() {
document.querySelector('html').style.setProperty('overflow', 'auto', 'important');
document.querySelector('body').style.setProperty('overflow', 'auto', 'important');
});
} else {
add.apply(this, arguments);
}
}
};
window.addEventListener = fuck(window.addEventListener, 'window');
document.addEventListener = fuck(document.addEventListener, 'document');
})();
@epser

This comment has been minimized.

Show comment
Hide comment
@epser

This comment has been minimized.

Show comment
Hide comment
@epser

epser Sep 5, 2018

https://gist.github.com/epser/435a6bc6271fa63a467c1f1e3851a04d/revisions#diff-6e93016e5d8c13006831446452544de7

  • 迂闊に全部のページで html { overflow: auto; } を仕掛けたために破綻するページがあった(twitterのページ最下部判定が壊れた)のを雑に修正
  • bodyにもoverflow指定する ( https://audition0902.jp 対策)
  • fuck(); 意味ないのでやめた
Owner

epser commented Sep 5, 2018

https://gist.github.com/epser/435a6bc6271fa63a467c1f1e3851a04d/revisions#diff-6e93016e5d8c13006831446452544de7

  • 迂闊に全部のページで html { overflow: auto; } を仕掛けたために破綻するページがあった(twitterのページ最下部判定が壊れた)のを雑に修正
  • bodyにもoverflow指定する ( https://audition0902.jp 対策)
  • fuck(); 意味ないのでやめた
@epser

This comment has been minimized.

Show comment
Hide comment
@epser

epser Sep 27, 2018

0.22

Owner

epser commented Sep 27, 2018

0.22

@epser

This comment has been minimized.

Show comment
Hide comment
@epser

epser Sep 27, 2018

0.221 document.addEventListener('load') が通らないことがある

Owner

epser commented Sep 27, 2018

0.221 document.addEventListener('load') が通らないことがある

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment