Skip to content

Instantly share code, notes, and snippets.

@s-shin
Last active August 29, 2015 14:17
Show Gist options
  • Select an option

  • Save s-shin/a7994023621ea8097604 to your computer and use it in GitHub Desktop.

Select an option

Save s-shin/a7994023621ea8097604 to your computer and use it in GitHub Desktop.
Anchor Bookmarklet
(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 = "&para;";
a.style.fontSize = "0.5em";
a.style.margin = "0 0.5em";
el.appendChild(a);
}
})();
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="&para;",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