Skip to content

Instantly share code, notes, and snippets.

@oxyflour
Last active July 6, 2025 07:14
Show Gist options
  • Save oxyflour/19ccafe870af0bf6dd9e26a69616c7f6 to your computer and use it in GitHub Desktop.
Save oxyflour/19ccafe870af0bf6dd9e26a69616c7f6 to your computer and use it in GitHub Desktop.
scroll and click next
// ==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