Last active
December 25, 2018 12:09
-
-
Save ryo-utsunomiya/a3e27dfdeb360860f073dec718229661 to your computer and use it in GitHub Desktop.
A simple code snippet to apply syntax highlight with current page
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
(d => { | |
let e = d.createElement('link'); | |
e.rel = 'stylesheet'; | |
e.href = 'https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.13.1/styles/github.min.css'; | |
d.body.appendChild(e); | |
e = d.createElement('script'); | |
e.src = 'https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.13.1/highlight.min.js'; | |
e.onload = () => { | |
e = document.createElement('script'); | |
e.src = 'https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.13.0/languages/javascript.min.js'; | |
e.onload = () => { | |
d.querySelectorAll('pre').forEach(hljs.highlightBlock); | |
} | |
d.body.appendChild(e); | |
}; | |
d.body.appendChild(e); | |
})(document); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Bookmarklet version is here: https://gist.github.com/ryo-utsunomiya/5ef047e4fef5bcaf9cd8538471c26085