// ==UserScript==
// @name           _blank Must Die
// @namespace      http://maxkueng.com/gmscripts
// @description    Removes the target attribute from hyperlinks that open a new browser window.
// @version        1.3bf
// @author         Max Kueng and Bo Frederiksen
// @homepage       http://maxkueng.com/
// @include        *
// ==/UserScript==

(function (){
	var a = window.document.getElementsByTagName("a");
	var regTarget = /^(_blank|blank|_new|new|_neu|neu|_newwin|newwin)$/i;
	for (var i=0;i<a.length;i++) {
		if (a[i].target.match(regTarget)) {
			if (top.location===this.location) {
				a[i].removeAttribute("target");
			} else {
				a[i].setAttribute("target", "_top");
			}
		}
	}
})();
