Created
February 3, 2009 16:14
-
-
Save satyr/57590 to your computer and use it in GitHub Desktop.
Find Amid
This file contains 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
/*==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