Seperis (seperis) wrote,
Seperis
seperis

  • Mood:

pretty much anything will work for me

As literally everything seems to be on its way to hell or trying to lodge itself in my spine, I needed some kind of triumph. Like, one I could actually see and use.

In general, this mood requires me to build something or code something; as I can't bend my back at all, I went to coding and tried to think of something code-related that I really needed in a language I knew or could learn quickly. The project needed to be large enough to require all my attention but small enough I could finish it in a day or two because I need a hit of triumph like whoa.

...and while reading tumblr, PgDn once again jumped straight to the bottom instead of scrolling and my momentarily dramatic rage was replaced by the realization I had a Project: a bookmarklet to go to the top of any webpage. Yes, you'd think my Project would be something to fix the problem of PgDn (only happens in tumblr), but no; it reminded me when I'm on AO3 sometimes a fic is very long and I want to jump back to the top instantly while in the middle. Go with it, okay?

So for Project ScrollToTop, I would need Javascript DOM and I girded myself for some intensive searching, which actually took roughly five minutes to find and ten minutes to write because fuck my life, the one time I want a challenge, I don't get one. There's a command for this. Just--right there ready to go.

In case anyone wants them:


/**
 * Scrolls to top of any webpage
 * Compatible with Safari, Chrome, Firefox, Opera
*/
javascript:void function(){var body=document.body;var html=document.documentElement;body.scrollIntoView();html.scrollIntoView();}();





/**
 * Scrolls to bottom of any webpage
 * Compatible with Safari, Chrome, Firefox, Opera
*/
javascript:void function(){var body=document.body;var html=document.documentElement;body.scrollIntoView(false);html.scrollIntoView(false);}();



So that was anticlimactic and required nothing more than the ability to cut and paste basic commands into the template. Triumph? I'll take it.

Posted at Dreamwidth: https://seperis.dreamwidth.org/1075145.html. | You can reply here or there. | comment count unavailable comments
Tags: coding
Subscribe
  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 0 comments