Created
January 2, 2023 09:36
-
-
Save eruizdechavez/66a1546adb8f8a35cd87357b13886ec2 to your computer and use it in GitHub Desktop.
Mark ALL episodes as Played in Overcast Web UI
This file contains 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
/** | |
* Mark ALL episodes as Played in Overcast Web UI | |
* Requires https://github.com/stevegrunwell/overcast-mark-as-played | |
* | |
* This snippet is run in the JavaScript console on the Episodes list of a Podcast; | |
* it will read and click every Marked as Played button on every episode making | |
* a brief pause between clicks to avoid overloading the API server. | |
*/ | |
console.log('Getting initial button count'); | |
let count = document.querySelectorAll('.overcast-mark-as-played-btn').length; | |
let run = count > 0; | |
console.log('Starting first iteration'); | |
clickMarkAsPlayedButton(); | |
function clickMarkAsPlayedButton() { | |
console.log('Clicking first button found in DOM'); | |
document.querySelector('.overcast-mark-as-played-btn').dispatchEvent(new MouseEvent('click')); | |
console.log('Waiting for DOM to change'); | |
setTimeout(() => { | |
console.log('Getting new button count'); | |
let newCount = document.querySelectorAll('.overcast-mark-as-played-btn').length; | |
if (newCount === count) { | |
throw new Error('Counts did not change after clicking the button'); | |
} else { | |
count = newCount; | |
run = count > 0; | |
console.log(`Button count updated (${count}), starting new iteration`); | |
clickMarkAsPlayedButton(); | |
} | |
}, 1500); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment