Google-chrome – How to replace a link’s text with the absolute `href` URL

browser-addonsfirefoxgoogle-chrome

Using an extension for Firefox or Google Chrome, how can I modify all links on a page such that

<a href="www.google.com">Google</a>

becomes

<a href="http://www.google.com">http://www.google.com</a>

?

EDIT

Tampermonkey is Greasemonkey alternative for Google Chrome.

Best Answer

I wrote you a simple Greasemonkey userscript to replace
<a href="URL">TEXT</a> with <a href="ABSOLUTE_URL">ABSOLUTE_URL</a>:

// ==UserScript==
// @name        Replace Link Text with URL
// @namespace   http://igalvez.net
// @description Replaces <a href="URL">TEXT</a> with <a href="ABSOLUTE_URL">ABSOLUTE_URL</a>
// @version     1.0
// @require     http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js
// ==/UserScript==

$("a").each(function() {
    var url = this.href;
    $(this).attr('href', url);
    $(this).text(url);       
});

Note: This will break most page layouts, as URL's can be quite long.

example

Related Question