Greasy Fork is available in English.

Prevent Spacebar Doing Page Down

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

< Commentaires sur Prevent Spacebar Doing Page Down

Question / commentaire

§
Posté le: 28/02/2019

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...

§
Posté le: 28/02/2019

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.

§
Posté le: 01/03/2019

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.

§
Posté le: 01/03/2019

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

§
Posté le: 04/03/2019

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.

§
Posté le: 05/03/2019

Sorry for double post

§
Posté le: 26/03/2019
Édité le: 28/03/2019

@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;
}
§
Posté le: 26/03/2019
Édité le: 28/03/2019

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:

§
Posté le: 09/06/2020

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

§
Posté le: 09/06/2020

@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.

Poster une réponse

Connectez-vous pour poster une réponse.