Last active
August 29, 2015 14:26
-
-
Save rococodogs/7f6c4ac2bf4c3cff4b44 to your computer and use it in GitHub Desktop.
bookmarklet to report number of empty links (`<a href="#"></a>') exist on a page. also provides the element
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 emptyLinkReport () { | |
| var collection = [] | |
| var emptyLinks = document.querySelectorAll('a[href="#"]') | |
| Array.prototype.forEach.call(emptyLinks, function (a) { collection.push([a.innerText, a]) }) | |
| // report total | |
| console.log('%d empty links found!', collection.length) | |
| collection.forEach(function (pair,idx) { | |
| // link text | |
| console.log('[%d]: %s', idx + 1, pair[0]) | |
| // element | |
| console.log('[%d]: ', idx + 1, pair[1]) | |
| }) | |
| } |
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(){var l=[];Array.prototype.forEach.call(document.querySelectorAll('a[href="#"]'),function(a){l.push([a.innerText, a]);});console.log('%d empty links found!', l.length);l.forEach(function(e,i){console.log('[%d]: %s', i+1,e[0]);console.log('[%d]: ', i+1, e[1]);});})() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment