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 | |
}) | |
})(); |
Author
TfTHacker
commented
Sep 30, 2020
- Create a new page in your Roam Graph (Name it whatever you want)
- in a block type {{[[roam/js]]}} then ENTER
- in the new block below the one you just typed into, press tab (this second block needs to be directly underneath the block from step 2 and needs to be indented under that block)
- type /Code Block (forward slash for commands
- Then you will see in the block a CODE editor. Very small. Paste the code from above into that code editor
- In the code editor, change the code type to "Javascript" -- there is a list of supported coding languages in upper right hand corner of the code block
- Press the button in the [[roam/js]] block to activate the code
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