Enhanced word highlight

Enhanced keywords highlight for Search Engines and All !

Daily installs
Total installs
112 1 1
Applies to
All sites

A powerful word highlight script that can do not just highlight. | 这是一个强大的高亮关键词脚本,强大不只是高亮!

Notice | 提醒

Tested under Firefox with Greasemonkey. Some enhanced functions may not be available in other browsers(see "For Chrome Users" below).仅在搭配 Greasemonkey 扩展的 Firefox 上测试通过。有些增强功能可能无法在其他浏览器上运作(请见下“给 Chrome 用户的提醒”)。
If you are a Readability addon user, note that the script will only work when activated AFTER activating Readability. Good solution is not currently available.如果你使用 Readability 扩展,要注意这脚本必须在激活 Readability 后才能激活,否则不能起作用。目前还没很好的解决方案。
Since Firefox4 uses Ctrl-/ to toggle Addon bar, I change the shortcut keys to activate the keyword input box to Alt-/ , while Alt-. (that is Alt key and Period key) replace the old shortcut Alt-/ to edit keywords.因为 Firefox4 使用了 Ctrl-/ 开闭附加组件栏,所以将调用关键词输入框的快捷键更换为Alt-/,而原来编辑关键词用的 Alt-/ 更改为 Alt-.(Alt键加句点键)。

For Chrome Users | 给 Chrome 用户的提醒

Better install this Chrome extension: Tampermonkey before installing this script to enable the script's full function in Chrome.请安装这个 Chrome 扩展再安装该脚本,以使该脚本全功能可用:Tampermonkey

Introduction | 简介

Enhanced word highlight is an enhanced version of "word highlight" script, which has the original features below:
  • Auto-highlight: Automatically highlight search keywords in Google result pages as well as pages opened from Google result pages;
  • Inherit-highlight: highlighted keywords will also be automatically highlighted in subsequent pages in the same tab/window;
  • Manually add keywords (support regular expression) to highlight in any pages with "Alt-/" shortcut;
  • Provide a map and counts of highlighted keywords;
  • Let you quickly navigate through the keywords on the map or word by word on the panel.
... and my enhanced and additional features:
  • Auto-highlight also covers search keywords in MORE result pages (e.g. Bing);
  • A "Lock" button to store one set of keywords and highlight them on whatever pages;
  • Stylized panel and keyword input box with a more usable and slim look;
  • You can press "Alt-/" shortcut once and input your keywords multiple times (press "Enter" to add while immediately get the highlight), with "Esc" to exit; or input multiple keywords separated by space at once;
  • Seamless highlight style;
  • More handy approaches to navigate through highlight occurrences, such as clicking a keyword on the panel, or even just scroll the mouse wheel over it;
  • Strengthened auto-pager tools support;
  • And more...
Enhanced word highlight 是 “word highlight” 脚本的增强版本,除了原脚本的如下特性外:
  • 自动高亮:在 Google 搜索结果页以及从中打开的页面中自动高亮搜索关键词;
  • 继承高亮:在已有高亮关键词的情况下,在同一标签/窗口浏览的其他页面中的相同关键词也会被高亮;
  • 按下 “Alt-/” 组合键可以手动输入关键词(支持正则表达式)在任何页面上高亮;
  • 提供已高亮关键词的分布图和计数;
  • 通过分布图和面板可以快速找到高亮关键词的位置。
  • 能够在其他网站(例如百度)的搜索结果页面自动高亮搜索关键词;
  • 添加了“Lock”按钮,可以储存一组关键词并使之在任何页面均高亮;
  • 面板和添加关键词的输入框样式更轻巧更美观;
  • 现在只需要按一次 “Alt-/” 组合键就可以多次添加关键词(按回车添加并立即高亮),添加完了按“Esc”键就可以关闭;也可以一次输入多个关键词,用空格分隔;
  • 高亮样式与原文本无缝结合;
  • 更方便查找高亮关键词位置,可点击高亮面板上的关键词或直接在关键词上滚动滚轮;
  • 增强的自动翻页工具支持;
  • 以及更多……


  • To highlight words: If you are on Google web search and any supported search result pages, search keywords are automatically highlighted. On an ordinary page, press "Alt-/" to activate the keyword input box, then enter keywords for highlight.
  • To enter keywords for highlight*: After activating the keyword input box by "Alt-/", you can input a set of keywords separated by space, or input one by one and press "Enter" -- or click the "→" button on the right -- between them, or mix the two methods. Newly submitted keywords will by default be added to the highlight list. Press "Esc" or click the "X" button to close the keyword input box. #Tips: regular expression is also supported**.
  • To highlight keywords in selected text: Select the target text, press "Alt-/" shortcut and the keywords in the selected text will instantly highlighted. By pressing "Alt-/" shortcut first then select the target text and press "Alt-/" shortcut again, you will get a copy of selected text in the keyword input box, which you can edit before highlight.
  • To highlight a whole new set of keywords: After activating the keyword input box by "Alt-/", click the checkbox in the left of the keyword input box; the label will turn from "Add" to "New", indicating that newly inputted keywords will now replace the old ones, that is, only new keywords will be highlighted and old highlight will be gone.
  • To navigate between occurrences of a highlighted keyword: Move the cursor to the keyword on the panel, LEFT click the keyword to navigate to its next occurrence; RIGHT click the keyword to navigate to its previous occurrence. #Tips: You can also use "n" and "Shift-n" shortcut keys to navigate to next/previous whatever keyword's occurrences; you can also hover the cursor over a keyword and scroll the mouse wheel to navigate. [For OLD versions: click the keyword or the Down Arrow button below the keyword to navigate to its next occurrence; click the Up Arrow button above the keyword to navigate to its previous occurrence.]
  • To toggle highlight of a keyword: Just click on the checkbox at the top-right corner of the keyword.
  • To toggle highlight of all keywords: Just click on the "O" button on the panel. #Tips: You can also use "Alt-," (Alt key and the comma key) shortcut key to do this.
  • To refresh highlight: If the content of the page change dynamically, you can refresh highlight by pressing "r" key.
  • To disable highlight: Just click on the "X" button on the panel. *IMPORTANT*: When highlight is disabled, auto-highlight in the current window / tab will also be disabled. However locked keywords will not be affected.
  • To restore highlight after disabling: Similar to "To enter keywords for highlight". When you press "Alt-/" without selecting any text, the "old" keywords will be shown in the keyword input box, which you can press "Enter" or click the "→" button to re-highlight them.
  • To check all the occurrences of highlighted keywords and scroll through them: Move the cursor over the panel and a highlight map will appear; click or drag on the map and the page will scroll to the corresponding position.
  • To edit keywords for highlight: Click on the "E" button on the panel, edit them separated by space, then press "Enter" or click the "E" button (orange) when finish. #Tips: You can also use "Alt-." (Alt key and the period key) shortcut key to edit keywords.
  • To lock keywords for highlight: Click on the green "L" button and the current keywords will be stored; hence all pages will be highlighted with the same set of keywords, including search result pages that would otherwise have their search keywords highlighted. *IMPORTANT*: No action will erase the locked keywords except "unlock".
  • To unlock keywords for highlight: Click on the orange "L" button and the stored keywords will be erased. You can change stored keywords to edited keywords by clicking twice on this button.
  • To minimize the panel: Double click on the left handler on the panel, and the panel will minimize to the right of the window, only showing the left handler. To restore the panel, double click again on the left handler.
  • * About highlight limitation: Because of some limitation of javascript, it is not possible to highlight short keyword and then highlight a extended one, for example, when you want to highlight "she" when you had before highlight "he" in the same page without a refresh, you got no "she" highlighted.
  • ** About highlighting Regular Expression: Under default config of the script, you have to uncheck the checkbox on the keyword input box (thus "New") to enter and highlight a regular expression if there are existing highlighted keywords. If you prefer to add regular expressions to highlight, the "Sort keywords" config (see "Advanced Config" below) must be disabled.


  • 高亮关键词:如果你打开了 Google 的网页搜索结果页面或者脚本支持的其他搜索结果页面,搜索关键词就会自动高亮。在一个普通页面中,你可以按 “Alt-/” 组合键去激活关键词输入框添加需要高亮的关键词。
  • 添加要高亮的关键词*:用 “Alt-/” 组合键激活关键词输入框后,你可以在其中添加关键词,既可以用空格分隔的方式一次输入多个关键词,也可以一次输入一个、每次按 “Enter” 键或点击输入框右边的 “→” 按钮添加,甚至两种方法并用。新添加的关键词默认会加到高亮关键词列表后面。按 “Esc” 键或点击 “X” 按钮可关闭关键词输入框。#提示:支持正则表达式**。
  • 将选中文本添加为高亮关键词:选中要高亮的文本,按下 “Alt-/” 组合键,选中文本中的关键词将会立即被高亮。如果按下 “Alt-/” 组合键激活关键词输入框,选中的文本然后再按下 “Alt-/” 组合键,选中文本就自动添加到输入框中,可供你编辑后再行高亮。
  • 高亮全新一组关键词:用 “Alt-/” 组合键激活关键词输入框后,点击关键词输入框左边的复选框,复选框的标注会从 “Add” 变成 “New” ,表明其后添加的关键词会取代旧的关键词——旧的高亮会去除,只有新添加的关键词会被高亮。
  • 查找高亮关键词的位置:将鼠标指针移动到高亮面板、你想要查找的关键词上,左键点击关键词查找该关键词下一个出现位置,右键点击关键词查找该关键词的上一个出现位置。#提示:按 “n” 和 “Shift-n” 快捷键可以向上/向下按顺序查找任意关键词位置;也可以将鼠标指针放在关键词上滚动鼠标滚轮查找位置。【适用于旧版:点击关键词或关键词下面出现的下三角箭头查找该关键词下一个出现位置,点击关键词上面出现的上三角箭头查找该关键词的上一个出现位置。】
  • 切换一个关键词的高亮:点击该关键词右上角的复选框即可。
  • 切换所有关键词的高亮:点击高亮面板上的 “O” 按钮即可。#提示:按 “Alt-,”(Alt键加逗号键)快捷键也可以。
  • 刷新高亮:在动态更新内容的页面上,要刷新高亮新的内容时,请按 “r” 键。
  • 禁用高亮:点击高亮面板上的 “X” 按钮即可。*注意*:禁用高亮后,在该窗口/标签页的自动高亮也会同时禁用;但锁定关键词高亮不受影响。
  • 禁用后恢复高亮:跟“添加要高亮的关键词”一样。要是你在没选中文本的情况下按 “Alt-/” 组合键,原有的关键词会在关键词输入框中显示,你可以直接按 “Enter” 键或点击 “→” 按钮重新高亮它们。
  • 查看所有关键词的位置和滚动页面:将鼠标指针移动到高亮面板上,一幅高亮分布图就会显示出来;在分布图上点击或拖动,页面将滚动到对应的位置。
  • 编辑已高亮的关键词:点击高亮面板上的 “E” 按钮,在出现的文本框中编辑关键词,每个之间用空格分隔,然后按 “Enter” 键或点击 “E” 按钮(橙色)结束编辑。#提示:按 “Alt-.”(Alt键加句点键)快捷键可以编辑关键词。
  • 锁定要高亮的关键词:点击高亮面板上绿色的 “L” 按钮,当前高亮的关键词组就会被储存起来,其后所有页面都将高亮该组关键词,连在其他情况下会自动高亮搜索关键词的页面也会只高亮该组关键词。*注意*:除了“解锁”操作外任何操作都不会清除储存的关键词。
  • 解锁要高亮的关键词:点击高亮面板上橙色的 “L” 按钮,储存的关键词将会被清除。你可以在编辑过高亮关键词之后通过双击此按钮将储存的关键词更新为当前关键词。
  • 最小化高亮面板:双击高亮面板的左边手柄,高亮面板会最小化到窗口的右边,只显示出这条左边手柄。要恢复最小化,双击那条左边手柄。
  • * 高亮限制:由于某些 javascript 的限制,此脚本将不能做到先高亮一短关键词然后高亮其延长词,例如当你想在高亮过“he”的页面上不经过刷新而高亮“she”,你将不可能达到目的。
  • ** 高亮正则表达式: 在脚本的默认设置下,如果已经有高亮的关键词,你需要清空关键词输入框的复选框(也就是选“New”),然后才能输入并高亮一条正则表达式。如果你希望添加正则表达式到高亮而不是取代,请将“排列关键词”设置(见下面的“高级设置”)禁用。

Advanced Config | 高级设置

Part I: Basic Settings | 第一部分:基本设定项

By selecting the "Enhanced word highlight Advanced Config" item from the Greasemonkey menu, you can change the following configs to your preference. If you are not using Greasemonkey, you may need to change them in "// #### Config II #### " section in code. Since the code include Chinese characters, an editor that supports multiple text encoding is required.从 Greasemonkey 的菜单中选择“Enhanced word highlight 高级设置”项,然后就可以根据你自己需要可以更改以下设置。如果你没有使用 Greasemonkey,你可能需要在代码中的“// #### Config II #### ”区修改相应的代码。因为代码包含中文字符,编辑代码需要的编辑器必须支持多种文本编码。
What auto-pager tool do you mostly use?

⚪ Autopagerize GM script
⚪ Autopager extension
⚪ Other (can handle all auto-pager tools but works slow)
The script originally supports Autopagerize GM script. If you use Autopagerize, select the first option (default).

With AutoPager Firefox Extension, the new page content will be highlighted instantly; by selecting the second option will enable the script to also refresh the map and keyword count.

If you are using other auto-pager tools, such as GoogleMonkeyR GM script, select the last option to let the script detect page change and totally refresh the highlight.

# The script uses an economical way to detect page height change in options two and three, thus there will be some delay between page change and highlight renewal. However, since the script has to go over all the content every time the new page is inserted, as page grows longer, the time required to renew will increase.

⚪ Autopagerize GM 脚本
⚪ Autopager 扩展
⚪ 其他(能应付任何自动翻页工具但运作较慢)
脚本本身支持 Autopagerize GM脚本 ,所以使用 Autopagerize 的用户请选择第一项(默认)。

使用 Firefox 扩展 AutoPager 的话,自动翻页页面会被自动高亮;选择第二项的话将允许脚本刷新分布图和计数。

如果你使用的是其他自动翻页工具,例如 GoogleMonkeyR GM脚本,可选择第三项让脚本检测页面变化刷新高亮。

# 选择第二或第三项的话,脚本会使用一种较经济的手段检测页面高度变化,所以高亮更新会相对于页面变化稍有延迟。不过,由于每次插入自动翻页页面脚本都要检查全部页面内容,在随着自动翻页不断增长的页面上,更新高亮需要会消耗越来越长的时间。
Turn off highlight of short keywords by default?

⚪ Don't turn off
⚪ One-letter/digit word
⚪ One- and two-letter/digit word
Not highlight short keywords, i.e. words formed by only one or two letters and numbers, but still leave them on the panel.

⚪ 否
⚪ 是;针对单个字母/数字
⚪ 是,针对单/两个字母/数字'
Disable auto-highlight (auto-capture keywords for highlight) ?

⚪ Enable
⚪ Completely disable
⚪ Disable on pages opened from supported search results
⚪ Disable on supported search result pages
Stop auto-highlight function, including on search results and subsequent pages. Selecting the third option will only stop auto-highlight function on subsequent pages from search results, while the fourth does the opposite. This config does not affect inherit-highlight and highlight for locked keywords.

⚪ 不禁用
⚪ 完全禁用
⚪ 仅在从支持的搜索结果中打开的页面上禁用
⚪ 仅在支持的搜索结果页面上禁用
☐ Sort keyword for more accurate highlight (Recommended, except for regular expression users)
Sort keywords will arrange longer keyword first, which presents a more reasonable result, which however, will need a bit longer time to process when adding and changing keywords, although that normally will not be noticeable. Nevertheless, there are always circumstances that you prefer "straight-forward" highlighting, or "short word first" rule, or you are on an old computer, or to enable adding regular expressions, under which you would like to turn this option off instead.
☐ 排列关键词以更准确高亮(推荐;需要高亮正则表达式的用户除外)
☐ Save panel position
Just to save the panel position the last time you move it.
☐ 保存面板位置
☐ Show indicator bar when navigating
Display a long semi-transparent bar when navigating through keywords, indicating which row the current keyword is in.
☐ 查找关键词时显示指示条

Part II: Special Settings | 第二部分:特殊设定项

Warning: Changing the advanced configs below requires editing the script source code. You should only change the code according the following instruction within the "// #### Config I ####" section. Since the code include Chinese characters, an editor that supports multiple text encoding is required (e.g. Notepad++).警告:修改以下高级设置需要编辑脚本源代码,请按照说明修改代码中“// #### Config I ####”区。因为代码包含中文字符,编辑代码需要的编辑器必须支持多种文本编码(例如 Notepad++)。
// List of url patterns; Array('NAME', 'KEYWORD_PREFIX', 'URL_PATTERN')
urlArr[0] = ['Google',	 'q=',	 'www.google.'];
Identifying search sites with url patterns to get search keywords for highlight.用于从特定url特征中提取搜索关键词用于高亮。
// List of IDs of query input boxes; Array('#SEARCHBOX_ID#', 'SEARCHPAGE SPEC_URL')
query_id[0] = new Array('query', '');// most common
Identifying the search box in other websites with url filter to get search keywords for highlight.用于在特定网址下的页面中找到搜索输入框并提取搜索关键词用于高亮。
// keybinds
var KEY_NEXT = 'n';// "n"Next occurrence
Set the shortcut keys to launch certain functions.设置指定功能的快捷键。
// delay of highlighting (ms)
var delay = 500;
Delay set to postpone highlight action, avoid conflict.设置脚本将延迟多久开始高亮,以免发生冲突。
// instant highlight selected keywords
var instant = true;
Set whether pressing Alt-/ instantly add selected text as keywords to highlight.设置是否在按下 Alt-/ 快捷键时自动将选中文本作为关键词高亮。
// restore focus and scroll position after closing keyword input box with shortcut key?
// mainly useful for keyboard navigation, not recommend for mouse navigation.
var refocus = false;
Useful for keyboard navigation (such as arrow key scrolling), which retore focus after using "Esc" to exit keyword input box. If you don't feel any trouble, do touch it.仅适用于使用键盘操作的用户,用于纠正用快捷键关闭关键词输入框时焦点跳到页尾而妨碍方向键滚动页面的问题。如果你不是因为这个问题而烦恼,绝不要更改这设置。
// minimize the panel initially?
var panel_hide = false;
provide initial-minimized-state panel for auto-highlight.为自动高亮提供面板初始最小化状态。

Part III: Calling Functions with Mouse Gesture | 第三部分:用鼠标手势调用功能

For heavy users of mouse gesture, requires a mouse gesture addon that support gesture comand customization.此部分适合鼠标手势重度使用者,需要支持自定义手势命令的鼠标手势组件配合使用。
Call the keyword input box.调出关键词输入框。
Call the disable-highlight command.调用停用高亮命令。

Credit | 鸣谢

This script cannot be born without the original script (Version 1.0.9) by os0x.

Thank grea for code and idea contribution.

And many who offer tips, ideas, references and suggestions.
多谢原作者 os0x ,在它的原脚本(版本1.0.9)基础上才能诞生这脚本。

多谢网友 grea 提供代码和好主意。


Update Log | 更新记录


Version 1.5.0: Add support for more search sites other than Google, as well as their subsequent pages; add config option to disable auto-highligh in search result pages; add in-code config for restore focus after using Esc key exiting keyword input; change behavior, pressing Ctrl-/ when focused in keyword input box will close the box; fix behavior, now quoted keywords can sustain; code refinement; since I have to add encoding convertion functions to handle Baidu keywords, the size of the script grows significantly. | 为更多搜索网站、以及从他们打开的页面提供自动高亮支持;添加在搜索结果页禁用自动高亮的设置项;在代码中添加“按Esc退出关键词输入框”时恢复焦点的选项;行为变更,在焦点在关键词输入框时按 Ctrl-/ 组合键将关闭该框;行为修正,现在用半角双引号引住的关键词不会再被拆散;代码优化;由于要添加转换代码页的函数去处理百度的关键词,脚本的体积现在大了很多。


Version 1.5.5: Behavior change: pressing Ctrl-./ when text is selected outside of text input area now will instantly add selected text as keywords to highlight; "Add/New" keyword input status will last until web page refresh; when highlight is disabled, existing keywords now will not automatically be added to the new keywords for highlight in the same window / tab, but by pressing Ctrl-/ without selecting text, they will be shown in the keyword input box; period dot is no longer a keyword separator; quoted keywords now work properly (finanlly); Add external calling code (for like mouse gesture) "content.window.wrappedJSObject.EWH_iSearch();" to call the keyword input box; Other bug fixes and code improvement.| 行为变更:当有文本框外的文本被选中时按 Ctrl-/ 组合键将自动将选中文本作为关键词高亮;“Add/New”(添加/全新)输入关键词状态将持续至页面刷新;在禁用高亮后,下次在同一窗口/标签页添加高亮关键词时不再自动将之前的关键词加上,但在不选中文本按 Ctrl-/ 组合键时这些关键词仍会显示在关键词输入框中;句点不再作为关键词分隔符使用;半角双引号(")括住的关键词终于正常处理了;添加外部调用代码(用于鼠标手势调用)“content.window.wrappedJSObject.EWH_iSearch();”调出关键词输入框;其他修正和代码改进。


Version 1.5.5a: Fix a bug that cause an error that halt the script when running in non-GM environment; Fix a bug that cause keyword cleaning-up failure in some circumstances; Add external calling code (for like mouse gesture) "content.window.wrappedJSObject.EWH_cClose();" to call the disable-highlight command.| 修正一个会导致脚本在非GM环境中出错不能运行的问题;修正一个会在某些情况下导致清理关键词失败的问题;添加外部调用代码(用于鼠标手势调用)“content.window.wrappedJSObject.EWH_cClose();”调用停用高亮命令。


Version 1.5.6: Fix and improve the function to toggle all highlight, which makes it work under Opera (11 beta); Add a button to lock highlight map; Behavior change: now on non main-search-engine pages, inherited keywords will have higher priority. | 修正和改进切换所有关键词高亮的函数,使其在 Opera (11 beta) 下可用;添加锁定高亮分布图的按钮;行为变更:现在在非主要搜索引擎页面内,继承的关键词拥有更高优先级。


Version 1.5.7: Add support to new addon.mozilla.org search pages; Refine styles; Behavior change: now you can only move the panel by dragging the left handler; Behavior change: now you cannot drag the panel when it's minimized; Add an option in code to provide initial-minimized-state panel for auto-highlight; Add a line to improve language determination (thanks SoIN); Change the shortcut keys to activate the keyword input box: Alt-/ to activate, while Alt-. (that is Alt and Period) to edit keywords. | 添加对新 addon.mozilla.org 搜索页面的支持;改进样式;行为变更:现在只能通过拖动左边的手柄来移动面板;行为变更:面板最小化后不能拖动;增加代码中设置项:为自动高亮提供面板初始最小化状态;添加一行代码增强语言判断(多谢SoIN);调用关键词输入框的快捷键更换,Alt-/为调用关键词输入,Alt-.为编辑关键词。


Version 1.5.7a: Fix the key shortcut problem, now the shortcut for editing keyword work, and the shortcut for toggling all highlight changed to Alt-, ; Refine style; Enable the script to work in iframes (test); other small fixes. | 修正快捷键问题,现在编辑关键词的快捷键可正常使用了,而切换全部高亮的快捷键改为 Alt-, ;样式改进;在 iframe 中启用脚本(测试);其他小修正。


Version 1.5.7b: Fix the keyword getting issue for Google's redirection. | 修正 Google 重定向造成提取关键词的问题。


Version 1.5.9: 修复百度utf-8字符集问题。

Version 1.6.0: Add exclusion to https Googld Map. | 添加对Google Map的https排除。


Version 1.6.2: Thanks to YFdyh000, shortcut keys work again in new versions (36+) of Firefox. | 感谢 YFdyh000 ,修正了原脚本在新版Firefox按键失效的问题。


Version 1.6.3: Fix the problem that highlight map didn't respond to mouse click in new versions (36+) of Firefox. | 修正了原脚本在新版Firefox点击高亮分布图失效的问题。

Version 1.6.4: Add fade-out effect to the indicator-bar; fix a layout problem of the config dialog in some webpages; add a primitive skip-word-list that store the words the user don't need to highlight. | 调整了指示条的显示效果;修正设置对话框在某些网页的错位问题;添加了跳过高亮单词列表的初始功能版本。