A lightweight extension for SD WebUI Forge / reForge that automatically enables ADetailer when you trigger a post-process hires fix on an already-generated image, then disables it once generation completes.
Running ADetailer on every generation is expensive — it adds a full inpaint pass even when you don't need it. But clicking ✨ (hires fix post-process) without ADetailer means faces won't be corrected at the final resolution. Manually toggling the checkbox each time is friction.
This extension hooks into the ✨ hires fix button and manages the ADetailer checkbox automatically:
- You click ✨ on a finished image.
- If ADetailer is off — the extension enables it and remembers it did so.
- Generation runs (hires pass + ADetailer inpaint).
- When generation completes — ADetailer is automatically turned back off (only if the extension enabled it for this run).
- If ADetailer was already on when you clicked ✨ — it is left on and not touched on completion.
After each batch, the script injects small circular checkboxes (class adhc-sel) on txt2img thumbnail buttons inside the gallery strip (not the main preview viewer):
- Thumbnails are resolved under
#txt2img_gallery: container.thumbnailsor[class*='thumbnails'], thenbuttonelements that contain an<img>. - Buttons whose
idor any ancestoridup to#txt2img_gallerycontainsselectedorpreview(case-insensitive) are skipped — avoids the large viewer slot.
✨ behavior:
- No checkboxes ticked, or only one thumbnail in the strip — same as above (single hires pass on whatever is currently selected).
- One or more checkboxes ticked and two or more thumbnails — builds a sorted queue of indices, then runs hires sequentially: select thumbnail → enable ADetailer if needed → ✨ → wait for completion → next item. Queue mode uses programmatic ✨ clicks guarded so the handler does not re-enter. After the queue finishes, injected checkboxes are removed and the selection list resets.
During active generation (#txt2img_interrupt visible), gallery MutationObserver updates do not touch the DOM (debounced reinjection otherwise).
Via URL:
- Open Extensions -> Install from URL
- Paste:
https://github.com/KazeKaze93/adetailer-hires-sync.git - Click Install, then Apply and restart UI
Manual:
Clone or download this repo into your extensions/ folder, then restart the WebUI.
- SD WebUI Forge or reForge (tested on reForge by Panchovix)
- ADetailer extension installed and configured
Pure frontend — no Python backend. One JS file is loaded via the standard WebUI script mechanism (javascript/adetailer_hires_sync.js, ES5-compatible).
#txt2img_upscale(✨): click handler enables ADetailer when unchecked (tracksautoEnabledByScript), arms completion observer, or starts multi-thumb queue processing when applicable.[id*="adetailer"] input[type="checkbox"]: ADetailer enable toggle (clicked only when the script decides to turn it on for hires).#txt2img_interrupt:MutationObserveron thestyleattribute — whendisplaygoes from visible generation state tononewhileautoEnabledByScriptis true, completion runs (toggle ADetailer off, disconnect observer; if a queue is active, schedule the next item after a short delay).#txt2img_gallery:MutationObserver(debounced) reinjects thumbnail checkboxes after gallery DOM updates; injects one-off#adhc-sel-stylesintodocument.headfor checkbox appearance.
If the extension does not trigger, verify selectors in DevTools (F12 -> Console):
// ADetailer checkbox
gradioApp().querySelector('[id*="adetailer"] input[type="checkbox"]')
// Hires fix button
gradioApp().querySelector('#txt2img_upscale')
// Interrupt button (used for completion detection)
gradioApp().querySelector('#txt2img_interrupt')
// Gallery root (thumbnails + preview live here)
gradioApp().querySelector('#txt2img_gallery')All must return an element where relevant, not null. If any returns null, update the selectors in javascript/adetailer_hires_sync.js to match your build.
MIT