Skip to content

Instantly share code, notes, and snippets.

@maujim
Last active April 1, 2024 22:35
Show Gist options
  • Save maujim/293b6045d1330c23e715b487efc21744 to your computer and use it in GitHub Desktop.
Save maujim/293b6045d1330c23e715b487efc21744 to your computer and use it in GitHub Desktop.
// Use something like https://caiorss.github.io/bookmarklet-maker/ to convert this to a bookmarklet
// clicks the first visible 'next' button on https://news.ycombinator.com/
let x = () => {
let content_filter = link => link.textContent.includes('next');
let visibility_filter = link => (link.getBoundingClientRect().top >= 0 && link.getBoundingClientRect().bottom <= window.innerHeight);
let fuse = 'on';
document.querySelectorAll('a.clicky').forEach(link => {
if (content_filter(link) && visibility_filter(link) && fuse === 'on') {
link.click();
fuse = 'off';
}
})
if (fuse === 'on') {
console.log("no 'next' buttons visible on page");
Notification.requestPermission().then(
_ => alert ("no 'next' buttons visible on page")
)
}
};
x();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment