gmscripts
gmscripts copied to clipboard
Only scroll after long press
Hey it's me again, with a new feature! No problem if you don't want to merge this. But I'm pleased with it, so I wanted to share.
I found right-click problematic on Linux due to the context menu, and middle-click problematic for security, because it kept pasting my clipboard into random websites!
So I thought of an alternative:
- Enable scrolling on left-click, but before entering scroll mode, the user must left-click-and-hold for 500ms (a "long press").
I have not change this script's default behaviour. To try the new feature, set:
-
startAfterLongPress = true
and -
mouseBtn = 1
You can also try this feature, already enabled, in my fork: Scroll Everywhere [fork] by joeywwiddle - Greasy Fork
Additional:
- [x] I added a ripple animation to indicate to the user when the scroll mode has started. We also change the cursor icon, but there is a long-standing issue that on some areas of some websites the page's cursor appears to override ours.
- [x] With or without this feature, the clicks we make to invoke our scroller will also send click events to OTHER listeners on the page or in other userscripts. I tried to prevent these events from being passed as much as possible.
Details: I added a little code to mute
click
events if we have just done some scrolling. (But at this time,mouseup
events are not muted, and mutingmousedown
events is probably impossible, since we don't know at that time whether the mousedown is intended for our scroller or for something else.) - [x] Added my code which partially prevent paste events when using middle-click on Linux.
- [x] Wow! I made it work for ANY scrollable element on the page, not only the page body. This required quite a few changes.
- [ ] Test whether that last change has affected the default modes. So far I have only tested on my own settings.
- [ ] Perhaps we should get it working in iframes now, if we can.
- [ ] When clicking on a native element, mousemove events are not sent to the page listeners. This results in the feature erroneously detecting and animating a long-click. This is really just a cosmetic problem, because it doesn't actually scroll, because it isn't receiving mousemove events. I managed to prevent this happening for scrollbars, but still need to work on some other native widgets, such as drop-down menus.
Because this feature is intended for (but not limited to) the left mouse button, but that button is used for lots of other things, there may be some edge-cases to deal with.
Please leave me a couple of weeks to iron them all out...!