跪拜 Guibai
← All articles
Frontend · HTML

A `setInterval` Script Deleted 14 Pages of Social Posts While Its Author Played Mahjong Link

By hauk0101 ·
Read original on juejin.cn ↗ Google Translate ↗ Alt translation

Every developer hits a repetitive browser task that a platform offers no bulk action for. Knowing how to inspect the DOM, identify the trigger elements, and script a timed loop in the console turns a multi-hour clickfest into a background job that finishes while you do something else.

Summary

Faced with 14 pages of old short posts on Juejin's content-management dashboard, a developer reverse-engineered the delete flow through the browser's DevTools. The UI required clicking a dropdown delete item, then confirming a modal — a two-step sequence that repeated identically for every post. Rather than click through it manually, they located the relevant CSS classes (`byte-dropdown-item` and `btn-confirm`) and triggered the actions from the console.

A `setInterval` loop calling a `deleteShortMsg` function every two seconds automated the entire cleanup. The script clicked the first available delete element, waited one second for the confirmation modal, then clicked confirm. While it ran, the author stepped away to play Mahjong Link.

The technique generalizes beyond deleting social posts: the same pattern of inspecting DOM events, abstracting a multi-step flow, and driving it with timed console scripts applies to any repetitive browser-based task or lightweight headless scraping job.

Takeaways
Juejin's short-post deletion requires two clicks per post: a dropdown delete item and a confirmation modal button.
The delete trigger uses class `byte-dropdown-item`; the confirm button uses class `btn-confirm`.
A `setInterval` calling a delete function every two seconds cleared 14 pages of posts unattended.
The script waits one second between triggering delete and clicking confirm to allow the modal to render.
Some UI triggers depend on `mouseenter` events, not just clicks, so inspect event listeners before scripting.
The same DOM-inspection-and-script pattern works for lightweight headless-browser scraping.
Conclusions

Platforms that lack bulk-delete features push users toward browser automation as the only practical escape hatch, which is a product gap, not a hack.

The two-second interval is conservative; tightening it risks race conditions where the modal hasn't appeared before the confirm click fires.

Hardcoding class names makes the script brittle — a CSS refactor on Juejin's side would break it instantly, but for a one-off cleanup that trade-off is irrelevant.

Concepts & terms
DOM scripting via DevTools console
Using the browser's developer console to locate HTML elements by class name or selector and programmatically trigger clicks, bypassing the need for manual interaction.
setInterval automation
A JavaScript function that repeatedly executes a callback at a fixed time delay, useful for automating repetitive browser actions when no bulk operation exists.
Source: juejin.cn ↗ Google Translate ↗ Backup ↗