Getting All Articles Referenced in a Wikipedia Article


Demo

I wrote a little bookmarklet that lets you pull all Wikipedia article links referenced in any Wikipedia article. To try it out, create a bookmark with the following code as the link, navigate to a wiki article, and click on the bookmark.

javascript:(function(){var e={isNavLink:function(e){return e.getAttribute("accesskey")!=null||e.parentNode.className.match(/icon/)!=null},isCitationLink:function(e){return e.parentNode.className.match(/citation/)!=null||e.parentNode.parentNode.className.match(/citation/)!=null},isWikiPageLink:function(e){return e.getAttribute("title")!=null&&e.getAttribute("href").indexOf("/wiki/")==0},isSpecialLink:function(e){return e.getAttribute("href").indexOf(":")>=0||e.getAttribute("style")!=null}};var t={};var n=document.links;var r=document.title;var i=document.createElement("h2");var s=document.createElement("div");var o='<table style="font-size: 16px; line-height:20px;">';o+='<thead style="font-weight:bold;"><tr><td>Referenced Articles</td></tr></thead><tbody>';for(var u=0;u<n.length;u++){var a=n[u];if(typeof t[a.href]==="undefined"){t[a.href]=true;if(e.isWikiPageLink(a)&&!e.isNavLink(a)&&!e.isSpecialLink(a)&&!e.isCitationLink(a)){var f=a.getAttribute("href");var l=a.getAttribute("title");o+='<tr><td><a href="'+f+'">'+l+"</a></td></tr>"}}}o+="</tbody></table>";i.innerHTML=r;s.innerHTML=o;document.body.innerHTML="";document.body.appendChild(i);document.body.appendChild(s);document.title=r})();

The unminified source can be found here.

Related Posts

A New Kind of Task Board

A kanban board with dynamic columns

Subdomains in Flask

Using subdomains to identify tenants in a multitenant Flask application

Leveraging Postgresql Schemas for Multitenancy

Segregating web application data by company using Flask and Postgresql

Time Logger for Windows 10 is Out

A time tracking app for Windows 10

Numbers Free for Windows 10 is Out

A simple block game for Windows 10

Using the Google Places API

Finding Nearby Points of Interest with the Google Places API

Using the HTML5 Geolocation API

Getting a users position using the HTML5 Geolocation API

Syntactic Clustering of News Headlines

grouping together news articles by subject using tf-idf weighting

Retrieving Yahoo! Finance Data using YQL

Getting stock information programmatically through Yahoo! Finance

A 16-Step Sequencer in Javascript