-
-
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 :)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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