Not fully working - partial fix included
|
|
Hey, there cl3m, thanks for initiating this. I've been annoyed at the _blank at google docs for a really long time and was meaning to make a GM script for it. Your idea is great but it has 2 problems:
function kill_blank(killed) {
var prev_killed = killed;
var a = window.document.getElementsByTagName("a");
var regTarget = /^(_blank|blank|_new|new|_neu|neu|_newwin|newwin)$/i;
for (i=0;i<a.length;i++) {
if (a[i].target.match(regTarget)) {
killed++;
a[i].removeAttribute("target");
}
}
if (killed != prev_killed)
setTimeout (function(){kill_blank(killed)}, 2000);
}
(function (){
kill_blank(0);
}());
2. If you now click around other folders, without reloading the page, the script doesn't fire off because the data for the new folder is retrieved via Ajax but returns JSON, which is then parsed by Javascript locally. I can think of 2 ways of fighting this:
Nevertheless, we're off to a great start here. :) |