a php developer weblog

blog Closed!
calin view of the web development world

2005/8/12

gmail: do all links have to open in a new window?

@ 08:11 AM (33 months, 15 days ago)
Despite Gmail fighting Greasemonkey scripts, or locking greasemonkey users away, I wonder if people would still be willing to write fixes for gmail usability issues. One problem I noticed is that, not matter what, all links in all emails open in a new window. This contradicts Adsense, which is kind of external focused and still succeeded in not implementing a setting for opening links in a new window after so many years.

Updated: after a short research, I found that such a Greasemonkey script already exists: "remove the javascript call that opens a new window for links in messages in Gmail" (src here). Btw, did I say that Greasemonkey rocks? But since the recent gmail change, this fix doesn't work anymore. Google seems to have fun fighting with the firefox js community. Anyway, I mailed the creator of the script the fixed version, hopefully he will put it live fast. Until he does it, here's the fixed script:

  1. // ==UserScript==
  2. // @name        GMail Single Window
  3. // @namespace   http://www.arantius.com/misc/greasemonkey/
  4. // @description Remove the javascript call that opens a new window for links in messages in Gmail.
  5. // @include     http*://mail.google.com/*
  6. // ==/UserScript
  7.  
  8. //
  9. // Originally written by Anthony Lieuallen of http://www.arantius.com/
  10. // Licensed for unlimited modification and redistribution as long as
  11. // this notice is kept intact.
  12. //
  13. // Changed by Calin Uioreanu, 12.08.2005
  14. // - changed domain name (gmail->mail)
  15. // - removed the target=_blank from all gmail links
  16. //
  17.  
  18. dump('===== Load Gmail Single Window =====n');
  19.  
  20. (function(){
  21. var res = document.evaluate("//a[contains(./@onclick, 'top.js.OpenExtLink')]",
  22.         document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
  23. var i, el;
  24. for (i=0; el=res.snapshotItem(i); i++) {
  25.         el.removeAttribute('onclick');
  26.         el.removeAttribute('target');
  27. }
  28. })()
Script highlighting by Qbnz.com.