How to remove citations and hyperlinks in wikipedia before you print or copy to word

CodeGuy
March 17, 2016

Ever wondered people struggling to remove citation numbers and links from Wikipedia articles. Printing an article from Wikipedia is straight forward using the printable view but you still you could face some hassles.
A citation is a reference to a published or unpublished source so you see markers like, [1], [2]...[citation needed] etc. Let us remove by using Chrome or Firefox browser web dev tools. It has been so simple yet,

You can also use this bookmarklet,


To remove citations: Open the Inspector by pressing CTRL + SHIFT + I 
Paste (press CTRL+V) the following code > then press enter from your developer Console. 
You can find some of the code snippets to remove all hyperlinks also.


To remove Citations


1
2
3
4
5
6
var element = document.getElementsByTagName("sup");

for (index = element.length - 1; index >= 0; index--) 
{
 element[index].parentNode.removeChild(element[index]);
};

To remove Hyperlinks

1
2
3
4
5
6
7
8
var element = document.getElementsByTagName("a");
for (index = element.length - 1; index >= 0; index--) 
{
 element[index].removeAttribute("href");
};

//optional to make it simple text
document.body.innerHTML = document.body.innerHTML.replace(/<a/g, "\<span").replace(/<\/a/g, "\<\/span");

0 comments

Do not spam.

Like us on Facebook

Blog Archive