Greasy Fork is available in English.

Discussioni » Richieste di creazione

Nitter - Have "Load newest" and "Load more" buttons placed near the top of the page

§
Pubblicato: 19/03/2022

See attached image. I would like a script that allows me to navigate the page much easier without having to scroll to the bottom or top to jump to the adjacent pages. I initially tried making a greasmonkey script where holding down CTRL+SHIFT and pressing left or right on the arrow keys would simulate you pressing the "Load newest" (previous) or "Load more" (next) page, but I do not know how to find a specific HTML element, get the inner HTML tag of those buttons, get the links they point to (the <a href="https://example.com">clickable text</a>), and use window.open.

Here is my beta code that I initally wanted a shortcut key to do that, but then scrapped and wanted 2 additional buttons on the page instead:

// ==UserScript==
// @name         Load more and newest with arrow keys on nitter
// @namespace    nitter.net
// @version      0.2
// @description  F**k having to scroll down and click at the bottom of the page
// @include      https://nitter.net/*
// ==/UserScript==
(function() {
    'use strict';
    document.addEventListener('keydown', ArrowKeyFunction)
})();

function ArrowKeyFunction(e) {
    if (e.shiftKey&&e.ctrlKey) {
        if (e.code == 'ArrowLeft') {
            e.preventDefault()
            
            //When the user presses CTRL+SHIFT+right arrow
        } else if (e.code == 'ArrowRight') {
            e.preventDefault()
            
            //When the user presses CTRL+SHIFT+left arrow
        }
    }
}

Yes, I could just hold down END, but the images don't load instantly, so it would position the scroll to the bottom of the page before that bottom moves further down (along with the "Load more" button), meaning I have to wait till all of them to load first.

Pubblica risposta

Accedi per pubblicare una risposta.