Auto-expand show more, spoilers and comments
Comment sections collapsed to three entries. Long posts cut off with "read more". FAQs hidden in accordions. The content is on the page — just stashed behind a button. This rule clicks all those buttons for you.
The pattern
Expand buttons have one of two tells: text like "show more" / "read more", or an aria-expanded="false" attribute. The rule catches both and clicks.
The rule
The rule's JavaScript:
const RE = /show more|read more|see more|expand|view all/i;
function expandAll() {
document.querySelectorAll('button, a, [role="button"]').forEach(el => {
if (el.dataset.jzExpanded) return;
const hit = RE.test(el.textContent || '')
|| el.getAttribute('aria-expanded') === 'false';
if (hit) {
el.dataset.jzExpanded = '1';
el.click();
}
});
}
expandAll();
new MutationObserver(expandAll)
.observe(document.body, { childList: true, subtree: true });
How it works
A text regex plus aria-expanded
One regular expression, a few wording variants, the i flag ignores case. Independently we check aria-expanded="false" — the standard accordion attribute, which works even without matching text.
The jzExpanded marker
After clicking an element we set data-jz-expanded on it. Next time the function skips it. Without that marker we would loop: a click expands the section, the section changes the DOM, the MutationObserver fires the function, it clicks the same button again.
MutationObserver
Comments and lists often load after the page starts. The MutationObserver watches the whole <body> and calls expandAll every time something is added to the DOM — so buttons that did not exist at start get expanded too.
Pitfalls
- False positives. A "show more products" that loads the shop endlessly will also be clicked. If it gets in the way, narrow the regex or the selector to a specific container.
- A mutation storm. On very dynamic pages
expandAllfires often. It works because thejzExpandedmarker makes every later pass cheap — it skips what is already clicked. - Spoilers with a warning. Expanding a spoiler or sensitive content is your decision — the rule does not tell "show more" apart from "show adult content".
See also
- Examples — more ready-made JS rules
- Auto-pager — a related browsing-automation pattern
- Output Console — watch what the rule clicks
Install JustZix — and stop clicking "show more" over and over.
Rate this post
No ratings yet — be the first.