Created
June 15, 2024 08:18
-
-
Save ckocyigit/dd3e4d87e1f1ede6c208bcf516b9798a 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