Last active
August 29, 2015 14:17
-
-
Save s-shin/a7994023621ea8097604 to your computer and use it in GitHub Desktop.
Anchor Bookmarklet
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
| (function() { | |
| var elsWithId = document.querySelectorAll("*[id]"); | |
| var IGNORE_TAGS = { | |
| SCRIPT: true, | |
| IFRAME: true | |
| }; | |
| for (var i = 0, len = elsWithId.length; i < len; ++i) { | |
| var el = elsWithId[i]; | |
| if (IGNORE_TAGS[el.tagName]) { | |
| continue; | |
| } | |
| var a = document.createElement("a"); | |
| a.href = "#" + el.id; | |
| a.innerHTML = "¶"; | |
| a.style.fontSize = "0.5em"; | |
| a.style.margin = "0 0.5em"; | |
| el.appendChild(a); | |
| } | |
| })(); |
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
| javascript:!function(){for(var a=document.querySelectorAll("*[id]"),b={SCRIPT:!0,IFRAME:!0},c=0,d=a.length;d>c;++c){var e=a[c];if(!b[e.tagName]){var f=document.createElement("a");f.href="#"+e.id,f.innerHTML="¶",f.style.fontSize="0.5em",f.style.margin="0 0.5em",e.appendChild(f)}}}(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment