Skip to content

Instantly share code, notes, and snippets.

@satyr
Created February 3, 2009 16:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save satyr/57590 to your computer and use it in GitHub Desktop.
Save satyr/57590 to your computer and use it in GitHub Desktop.
Find Amid
/*==uc/==
@name Find Amid
@author satyr
@description Places the found item in the middle.
@include main
@include ~^chrome://global/content/view(?:Partial)?Source\.xul
@compatibility Firefox 3.5+
@version 2010-05-15
@original http://gist.github.com/346668
@original 8. of http://mayokara.info/deadspace/#d20090202
==/uc==*/
setTimeout(function FindAmid(){
const FT = self.gFindBar || document.getElementById('FindToolbar');
for each(let name in ['_find', '_findAgain']){
FT[name +'Original'] = FT[name];
FT[name] = eval(String(<![CDATA[0,function @Amid(x){
var res = this.@Original(x), win = this._currentWindow;
var sc = win && this._getSelectionController(win);
if(sc)
sc.getSelection(sc.SELECTION_NORMAL).QueryInterface(Ci.nsISelection2)
.scrollIntoView(sc.SELECTION_ANCHOR_REGION, true, 50, 50);
return res;
}]]>).replace(/@/g, name));
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment