Skip to content

Instantly share code, notes, and snippets.

@Griever
Created July 7, 2011 14:54
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 Griever/1069687 to your computer and use it in GitHub Desktop.
Save Griever/1069687 to your computer and use it in GitHub Desktop.
AutoPagerize の継ぎ足し後もページ内検索の強調をする
// ==UserScript==
// @name AutoPagerizeFindHighlight
// @description AutoPagerize の継ぎ足し後もページ内検索の強調をする
// @namespace http://d.hatena.ne.jp/Griever/
// @author Griever
// @license MIT License
// @compatibility Firefox 5
// @charset UTF-8
// @include main
// @version 0.0.1
// @note 拡張などで複数のワードを強調していても1つ目のワードしか強調しないのは仕様
// @note GM 版の AutoPagerize でも動くと思う
// ==/UserScript==
({
init: function() {
//gBrowser.mPanelContainer.addEventListener("GM_AutoPagerizeNextPageLoaded", this, false);
gBrowser.mPanelContainer.addEventListener("DOMContentLoaded", this, false)
window.addEventListener("unload", this, false);
},
uninit: function() {
//gBrowser.mPanelContainer.removeEventListener("GM_AutoPagerizeNextPageLoaded", this, false);
gBrowser.mPanelContainer.removeEventListener("DOMContentLoaded", this, false);
window.removeEventListener("unload", this, false);
},
handleEvent: function(event) {
switch(event.type){
case "DOMContentLoaded":
event.target.addEventListener("GM_AutoPagerizeNextPageLoaded", this, true);
break;
case "GM_AutoPagerizeNextPageLoaded":
var win = event.target.defaultView;
var controller = gFindBar._getSelectionController(win);
var sel = controller.getSelection(controller.SELECTION_FIND);
if (sel.rangeCount == 0)
return;
gFindBar._highlightDoc(true, sel.getRangeAt(0).toString(), win)
break;
case "unload":
this.uninit();
break;
}
},
}).init();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment