06/11/10 18:50:59 fdRwTvPP0
/**
* A user script for userChrome.js extension.
* @nameExtended 'Open Selection in new Tab' gesture
* @descriptionOpen all URLs in selection by 'Open Selection in new Tab' command of All-in-One Gestures
* @compatibilityFirefox 2.0, All-in-One Gestures 0.18.0
* @authorGomita
* @version2006.10.22
* @permalinkURLリンク(amb.vis.ne.jp) */
aioSelectionAsURL = function()
{
// getBrowserSelection function couldn't be apply since it removes all line breaks.
var win = document.commandDispatcher.focusedWindow;
var sel = win.getSelection().toString();
if ( !sel ) return;
// process each lines
var flag = false;
sel = sel.split("\n");
sel.forEach(function(str)
{
// extract strings which may be URL (not strict)
str = str.match(/([a-zA-Z0-9\+\$\;\?\.%,!#~\*\/:@&=_-]+)/);
if ( !str || str[1].indexOf(".") < 0 ) return;
str = str[1];
if ( str.indexOf("URLリンク(")) == 0 ) str = "h" + str;
// Open in a background tab
gBrowser.loadOneTab(str, null, null, null, true, false);
flag = true;
});
// If the selection doesn't contain URL, we does Web-Search it.
if ( !flag )
BrowserSearch.loadSearch(sel, true);
};