(Note: updated with a more reliable representation of the link.)
(Note: updated again to support news:<newsgroup-name> links.)
Here’s an obscure hack.
Firefox 3 supports web protocol handlers (f.e. sending mailto: links to Gmail), while Google Groups archives Usenet. But as far as I can tell, Google Groups doesn’t support news: links, even though Firefox can send them to it. It does, however, support retrieving messages by their IDs or newsgroup names, which news: links contain.
So how could we get Google Groups to load news: links passed to it by Firefox?
The solution is to pass them to an intermediary that extracts the IDs/names from the links and passes them to Google Groups. Here’s a data: URL that does that:
data:text/html,
<html><body><script>
var url = '%s';
var stripPrefix = /^news:(\/\/[^\/]+\/)?/;
if (/@/.test(url))
window.location = 'http://groups.google.com/groups?selm='+url.replace(stripPrefix, '');
else
window.location = 'http://groups.google.com/group/'+url.replace(stripPrefix, '');
</script></body></html>
Unfortunately, it isn’t easy to configure Firefox to use this URL as the news: protocol handler. Manually hacking mimeTypes.rdf is most unpleasant, while window.navigator.registerProtocolHandler only registers http(s): URLs.
But it’s possible to construct a javascript: URL that does the same thing registerProtocolHandler does, namely call the handler service and register the handler with it directly.
The only trick is that you have to enter and run it in the Error Console, which has chrome privileges. Otherwise the URL won’t have the privileges it needs to register the handler.
Here’s a javascript: URL that registers the handler:
To use it, copy the URL, open the Error Console (Tools > Error Console or Ctrl/Command+Shift+J), paste the URL into the evaluation field, and press the Evaluate button.
Once you’ve done that, try it out with these links:
- news:mozilla.support.firefox
- news://news.mozilla.org/mozilla.support.firefox
- news:37604264.65F502CD@netscape.com
- news://news.mozilla.org/37604264.65F502CD@netscape.com
When you click one, Firefox will ask you what you want to do with the link, and Google Groups should be an option on the list.
For the curious, here’s a nicely formatted version of the code inside that javascript: URL, which is based on WCCR_addProtocolHandlerButtonCallback:
javascript:
var Cc = Components.classes;
var Ci = Components.interfaces;
var handler = Cc['@mozilla.org/uriloader/web-handler-app;1'].createInstance(Ci.nsIWebHandlerApp);
handler.name = 'Google Groups';
handler.uriTemplate = "data:text/html,
<html><body><script>
var url = '%s';
var stripPrefix = /^news:(\/\/[^\/]+\/)?/;
if (/@/.test(url))
window.location = 'http://groups.google.com/groups?selm='+url.replace(stripPrefix, '');
else
window.location = 'http://groups.google.com/group/'+url.replace(stripPrefix, '');
</script></body></html>";
var eps = Cc['@mozilla.org/uriloader/external-protocol-service;1'].getService(Ci.nsIExternalProtocolService);
var handlerInfo = eps.getProtocolHandlerInfo('news');
handlerInfo.possibleApplicationHandlers.appendElement(handler, false);
handlerInfo.alwaysAskBeforeHandling = true;
var hs = Cc['@mozilla.org/uriloader/handler-service;1'].getService(Ci.nsIHandlerService);
hs.store(handlerInfo);
window.location = "data:text/html,
<body>
<p>The news: link handler for Google Groups has been installed.
Try it with these links:</p>
<ul>
<li><a href='news:mozilla.support.firefox'>news:mozilla.support.firefox</a></li>
<li><a href='news://news.mozilla.org/mozilla.support.firefox'>news://news.mozilla.org/mozilla.support.firefox</a></li>
<li><a href='news:37604264.65F502CD@netscape.com'>news:37604264.65F502CD@netscape.com</a></li>
<li><a href='news://news.mozilla.org/37604264.65F502CD@netscape.com'>news://news.mozilla.org/37604264.65F502CD@netscape.com</a></li>
</ul>
</body>";
Of course Google Groups could make this hack moot by simply supporting news: links and protocol handler registration natively. For info on how to do that, Google Groups, see the news: URL standard in RFC 1738 and these subsequent IETF drafts, then read the Devmo docs on window.navigator.registerProtocolHandler.
Actually it would be nice if the javascript link wasn’t escaped like that, since copying the link to the error console gives an error on the first %20 occurence π
Is it possible to adjust it so links that are just to newsgroups without a message id work? Such as from http://onestep.on.ca/findajob/usenet.cfm and the 2 examples in the second paragraph at http://en.wikipedia.org/wiki/Usenet#Introduction
mardeg: I’ve updated the post so the javascript: URL is just regular text in the page that you can copy and paste, which should fix the copy-paste problem.
I bet I could make links to newsgroups also work. I’ll look into that.
I modified it myself, here you go π
(couldn’t do code tags in this post so using tinyurl)
mardeg: it looks like we both modified it at the same time, as I was updating the blog post when you posted your comment. π
It would have been nice if you had used an active news post so that the link stood a chance of working in a real news client…
This does not work with NoScript unless JS is allowed globally which essential disables most of NoScript’s functions.
@SanderG
I asked about a workaround for noscript. Lo and behold! π
I just found this little hack.
Thanks for solving a small annoying problem for me.
I’m completely googlyfied now. π