06/11/11 19:19:14 F1CM0Yl50
>>78
aioSelectionAsURL(); を呼べば動くでしょ。
勝手にdrag and go 仕様にしてみた。えらいてきとー。
/* Original by @authorGomita */
contentAreaDNDObserver.onDragOver = function(aEvent, aFlavour, aDragSession) {
aEvent.target.setAttribute("dragover", "true");
return (aDragSession.canDrop = true);
};
contentAreaDNDObserver.onDrop = 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);
};
getBrowser().addEventListener("dragover", function(aEvent) { nsDragAndDrop.dragOver(aEvent, contentAreaDNDObserver); }, false);