Skip to content

Instantly share code, notes, and snippets.

@TfTHacker
Last active November 9, 2020 20:13
Show Gist options
  • Save TfTHacker/94fd043b195af43e3e6fb715bda7409b to your computer and use it in GitHub Desktop.
Save TfTHacker/94fd043b195af43e3e6fb715bda7409b to your computer and use it in GitHub Desktop.
// roam/js code snippet to add crossing out completed todos
// also adds the CSS classname custom-strikethrough for css mods
;(()=>{
if( typeof window.roamhacker_checkboxStrikeout != 'undefined') return;
window.roamhacker_checkboxStrikeout = {};
const scanCheckboxes = () => {
document.querySelectorAll('.check-container input').forEach( (element)=>{
var span = element.parentElement.parentElement.parentElement
if(element.checked) {
span.classList.add('custom-strikethrough')
span.style.textDecoration='line-through'
} else {
span.classList.remove('custom-strikethrough')
span.style.textDecoration='none'
}
})
}
scanCheckboxes()
var observerCheckBoxes = new MutationObserver(scanCheckboxes);
observerCheckBoxes.observe(document.querySelector('#app'), {
childList: true,
subtree: true
})
})();
@vikramguptamd
Copy link

Thank you 🙏🏼 It worked like a charm!!! I appreciate it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment