Created
May 5, 2009 16:09
-
-
Save satyr/107030 to your computer and use it in GitHub Desktop.
Automatically copies the selected text on Ubiquity panel.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function startup_autocopy(){function cmd_(){} | |
getU(autocopy); | |
function autocopy(U){ | |
U.__msgPanel.addEventListener('mouseup', function copy(e){ | |
var s = e.view.getSelection() +''; | |
s && CmdUtils.copyToClipboard(s); | |
}, true); | |
} | |
function getU(fn){ | |
waitU(Utils.currentChromeWindow); | |
Cc['@mozilla.org/observer-service;1'].getService(Ci.nsIObserverService) | |
.addObserver({ | |
observe: function(subject, topic, data){ | |
subject.addEventListener('load', this, false); | |
}, | |
handleEvent: function({originalTarget: doc}){ | |
doc.removeEventListener('load', this, false); | |
if(doc.location.href === 'chrome://browser/content/browser.xul') | |
waitU(doc.defaultView); | |
}, | |
}, 'toplevel-window-ready', false); | |
function waitU(W){ | |
if(W.gUbiquity) fn(W.gUbiquity, W); | |
else Utils.setTimeout(function(){ waitU(W) }, 42); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment