Greasy Fork is available in English.

Prevent Spacebar Doing Page Down

When the Spacebar key is received outside a text entry area, discard it

< 脚本Prevent Spacebar Doing Page Down的反馈

提问/评论

§
发表于:2019-02-28

Not so useful because

Hi, thanks for your work in this idea, but it prevents not only scrolling, also the Keyboard function of the Space Bar to Stop/Start a Media Player...

§
发表于:2019-02-28

You mean if the site has a global-level intercept for the spacebar? True, this script will prevent the page from receiving the spacebar outside of editable fields.

If there's a site where you don't want the script to run, you can exclude it. The method for adding a user exclude varies among Greasemonkey, Tampermonkey, and Violentmonkey.

In Violentmonkey, when you view the code of the script, there is a "Settings" tab next to the "Code" tab. In the @excludes box, type or paste the domain of the site where you don't want the script to run, with an asterisk at the end. For example:

https://www.youtube.com/*

The next YouTube page you load, when you look at the scripts enabled on the page, this one won't be listed.

§
发表于:2019-03-01

Oh, i want that the spacebar works as a button for a media player, so i think it would not be the right idea to exclude specific websites from the function. The function itself must be modified to trigger mediaplayer behavior but prevents scrolling.

§
发表于:2019-03-01

Okay, if you figure out how to do that, please let me know. Until then, you can disable or uninstall this script.

§
发表于:2019-03-04

Oh, i want that the spacebar works as a button for a media player, so i think it would not be the right idea to exclude specific websites from the function. The function itself must be modified to trigger mediaplayer behavior but prevents scrolling.

§
发表于:2019-03-05

Sorry for double post

§
发表于:2019-03-26
编辑于:2019-03-28

@Maxx said: Oh, i want that the spacebar works as a button for a media player... & @"Jefferson Scher" said: Okay, if you figure out how to do that, please let me know. Until then, you can disable or uninstall this script.

This following code adds an "exception" for using back the Spacebar on most html video players like Youtube, Vimeo, Facebook, etc...

I only found twitter where the Spacebar is still not working for videos. That's because the player's controls elements are located outside of the video frame (html). I don't really have time right now to fix this issue. Anyway, it seems to works on most websites, which is a good start.

Just add the following javascript at line #18. (Don't replace or remove any of the original code, just add it.)

If you have any problem related to this code, just tell me.

// LINE #18
// EXCEPTINON: VIDEO FRAME
if (key.target.nodeName == "video") return;
// EXCEPTINON: ANY ELEMENTS INSIDE THE VIDEO FRAME
var i, VideoElements = document.getElementsByTagName("video");
for (i = 0; i < VideoElements.length; i++) {
    if (document.getElementsByTagName("video")[i].contains(key.target)) return;
}
§
发表于:2019-03-26
编辑于:2019-03-28

Oh, by the way... I just want to thanks Jefferson Scher for his script! That stupid Spacebar scrolling "Feature" was annoying me way too much...

Chrome is not bad but it really lacks of settings, especially for disabling these annoyances.

:smiley:

§
发表于:2020-06-09

Hi, I love your tweak! However, this script does not prevent scrolling in GitHub. Are you able to reproduce this?

§
发表于:2020-06-09

@Jason1923 said: Hi, I love your tweak! However, this script does not prevent scrolling in GitHub. Are you able to reproduce this?

Hmm, with Github it could be a Content Security Policy (CSP) issue: sites can instruct the browser not to run injected scripts, and that can block user scripts from running, at least in Firefox. I don't know about other browsers.

发表回复

登录以发表回复。