this post was submitted on 27 Oct 2024
33 points (100.0% liked)

Programming

17343 readers
272 users here now

Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!

Cross posting is strongly encouraged in the instance. If you feel your post or another person's post makes sense in another community cross post into it.

Hope you enjoy the instance!

Rules

Rules

  • Follow the programming.dev instance rules
  • Keep content related to programming in some way
  • If you're posting long videos try to add in some form of tldr for those who don't want to watch videos

Wormhole

Follow the wormhole through a path of communities !webdev@programming.dev



founded 1 year ago
MODERATORS
 

A bookmarklet is a bookmark whose URL is JavaScript code instead of a site. It might be, for example,

javascript:document.querySelector('video').playbackRate = Number(prompt("speed")) || 1; void(0)

// formatted version:
javascript:
document
  .querySelector('video')
  .playbackRate = 
  Number(prompt("speed")) || 1; 
void(0)

so that if you click the bookmark, it sets the speed of the video to whatever you want (e.g. 3.7).

You could also run this directly in the URL bar (in some cases -- I think desktop Chrome does that), or you can simply type alert() into the dev console (desktop Firefox prefers this for security reasons).

Is running my own arbitrary JS like this a thing on mobile? I'm on Android but I'm not sure if Brave disabled it -- I vaguely remember it working once, but it doesn't anymore. No luck on Firefox either. Maybe there's a workaround?

you are viewing a single comment's thread
view the rest of the comments
[–] fool@programming.dev 2 points 1 week ago

I see, I forgot about tampermonkey. At that point I can also just paste a bookmarklet into the script space itself and enable when needed.

Firefox-based mobile browsers unload pages for me when I tab away (maybe it's a Samsung killer thing? all outside of the scope of this question tho), which could be an issue, but if I'm careful then this method should do it. Thanks!