Last active
July 6, 2025 07:14
-
-
Save oxyflour/19ccafe870af0bf6dd9e26a69616c7f6 to your computer and use it in GitHub Desktop.
scroll and click next
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name My Script | |
// @namespace http://tampermonkey.net/ | |
// @version 1.0 | |
// @description 快捷键示例 | |
// @match https://www.ravelry.com/* | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
let started = true | |
function scrollDown() { | |
window.scrollBy({ | |
top: 5, | |
behavior : "smooth" | |
}) | |
const [_, link] = document.querySelectorAll('a.next_page') | |
if (link) { | |
const { bottom } = link.getBoundingClientRect() | |
if (bottom < window.innerHeight) { | |
setTimeout(() => link.click(), 3000) | |
} | |
} | |
if (started) { | |
setTimeout(scrollDown, 100) | |
} | |
} | |
document.body.addEventListener('keyup', function onKeyDown(evt) { | |
if (evt.key === 'Escape') { | |
started = false | |
} else if (evt.key === 'X' && evt.ctrlKey && evt.shiftKey) { | |
started = true | |
scrollDown() | |
} | |
}) | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment