Skip to content

Instantly share code, notes, and snippets.

@w-e-w
Last active August 25, 2024 04:07
Show Gist options
  • Save w-e-w/a6d4279418cd1379c633124823f140d1 to your computer and use it in GitHub Desktop.
Save w-e-w/a6d4279418cd1379c633124823f140d1 to your computer and use it in GitHub Desktop.
Civitai click "Show more" Tampermonkey
// ==UserScript==
// @name Civitai click "Show more"
// @namespace w-e-w
// @version 1.4
// @description Automatically click the "Show more" button and other specific buttons when they appear on the page
// @author https://github.com/w-e-w
// @match https://civitai.com/models/*
// @match https://civitai.com/images/*
// @icon https://civitai.com/favicon.ico
// @grant none
// ==/UserScript==
(function() {
'use strict';
function clickButton() {
document.querySelectorAll('.mantine-Text-root.mantine-Anchor-root.mantine-Spoiler-control.mantine-1d2wsk, .text-sm.mantine-12i30r7')
.forEach(button => {
const text = button.textContent.trim().toLowerCase();
if (button.offsetParent && !["show less", "hide"].includes(text)) {
button.click();
}
});
}
const observer = new MutationObserver(mutations => {
if (mutations.some(mutation => mutation.type === 'childList')) {
clickButton();
}
});
observer.observe(document.body, { childList: true, subtree: true });
clickButton(); // Initial check
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment