Last active
November 9, 2020 20:13
-
-
Save TfTHacker/94fd043b195af43e3e6fb715bda7409b to your computer and use it in GitHub Desktop.
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
// 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 | |
}) | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you 🙏🏼 It worked like a charm!!! I appreciate it!