Skip to content

Instantly share code, notes, and snippets.

@almas
Forked from ckocyigit/immich-trasher.js
Created June 1, 2025 08:49
Show Gist options
  • Save almas/47c1994ab79f6540e8ff1421dc6c288a to your computer and use it in GitHub Desktop.
Save almas/47c1994ab79f6540e8ff1421dc6c288a to your computer and use it in GitHub Desktop.
Immich frontend duplicates button smasher - (made in minutes, works on my machine, no guarantees :)
(function() {
const buttonLabelPattern = /^Trash \d+$/;
const interval = 1000;
const checkInterval = 500;
let clickIntervalId = null;
let checkTimeoutId = null;
function clickButton() {
const buttons = document.querySelectorAll('button');
for (let button of buttons) {
if (button.innerText.trim().match(buttonLabelPattern)) {
button.click();
console.log(`Button "${button.innerText.trim()}" pressed`);
return;
}
}
console.warn(`button not found`);
}
function waitForButton() {
const buttons = document.querySelectorAll('button');
for (let button of buttons) {
if (button.innerText.trim().match(buttonLabelPattern)) {
console.log(`Button "${button.innerText.trim()}" found! clicking...`);
clickIntervalId = setInterval(clickButton, interval);
return;
}
}
console.log(`Waiting for trash button...`);
checkTimeoutId = setTimeout(waitForButton, checkInterval);
}
waitForButton();
window.stopSpamming = function() {
if (clickIntervalId !== null) {
clearInterval(clickIntervalId);
console.log("Stopped clicking...");
}
if (checkTimeoutId !== null) {
clearTimeout(checkTimeoutId);
console.log("Stopped checking...");
}
};
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment