Bookmarklet to show anchors

Recently found this bookmarklet that visualizes anchor tags in a web page (elements with an ID and anchor tags with a name). Unfortunately Chrome doesn’t like it because it loads jQuery. It also contains a base64 image of anchor. Nowadays you don’t need jQuery for simple tasks and there’s probably an emoji that suits your needs. So, there you go, a simpler bookmarklet:

javascript:Array.prototype.filter.call(document.querySelectorAll('[id],a'),function(e){if(e.nodeName!='A'||e.getAttribute('name')){e.insertAdjacentHTML('beforebegin','<a href="#'+(e.id?e.id:'')+(e.name?e.name:'')+'">&'+'#x2693;</a>')}});

Updated: added an anchor tag around the anchor emoji with the actual bookmark.

Advertisements