Tested with ViolentMonkey on Firefox
Script is buggy, but that makes it better I guess
Tested with ViolentMonkey on Firefox
Script is buggy, but that makes it better I guess
| // ==UserScript== | |
| // @name PainScroll | |
| // @copyright Made by @[email protected] | |
| // @author Kura | |
| // @description Scrolling made more painful. And rewarding? | |
| // @version 1.0 | |
| // @namespace z0ne | |
| // @match *://*/* | |
| // @downloadURL https://gist.github.com/cking/f14c4d5302d1a982b08b3f9ba8a8bc26/raw/painscroll.user.js | |
| // @homepageURL https://gist.github.com/cking/f14c4d5302d1a982b08b3f9ba8a8bc26 | |
| // @grant GM_setValue | |
| // @grant GM_getValue | |
| // ==/UserScript== | |
| function rand(min, max) { const rounds = parseInt(Math.random() * 10) | |
| let rnd = Math.random() | |
| for (let i = 0; i <= rounds; i++) { | |
| rnd += Math.random() | |
| } | |
| rnd -= parseInt(rnd) | |
| min = min || 0 | |
| max = max || 1 | |
| const v = rnd * (max - min) + min | |
| if (max <= 1) { | |
| return v | |
| } | |
| return parseInt(v) | |
| } | |
| function chance(min) { | |
| return rand() > min | |
| } | |
| let lastPosition = { | |
| x: 0, | |
| y: 0 | |
| } | |
| function onScroll(ev) { | |
| const offset = { | |
| x: lastPosition.x - ev.pageX, | |
| y: lastPosition.y - ev.pageY | |
| } | |
| lastPosition.x = ev.pageX | |
| lastPosition.y = ev.pageY | |
| if (!chance(0.75)) { | |
| return | |
| } | |
| const x = jumpScroll(offset.x) | |
| const y = jumpScroll(offset.y) | |
| window.scrollBy(x, y) | |
| } | |
| function jumpScroll(offset) { | |
| if (offset == 0) { | |
| return 0 | |
| } | |
| if (chance(0.25)) { | |
| return 0 | |
| } | |
| let modifier = chance(0.66) ? 1 : -1 | |
| modifier *= rand(0, 32) | |
| return offset * modifier | |
| } | |
| document.addEventListener("DOMMouseScroll", onScroll) | |
| document.addEventListener("mousewheel", onScroll) |