在搜索引擎和任意网页获得增强的高亮!
< Spätná väzba na Enhanced word highlight
The only way I can recreate your result is to search some keywords on a supported search site with auto-highlight enabled, go to Ewh's Advanced Config and switch auto-highlight to "Disable for search keywords". Then the search site page will auto refresh and the "old" search keywords are still highlighted.
This is the result of Ewh's inheriting highlight feature, which will keep highlighting the same set of keywords in the same session (e.g. same tab or same window) where a set of keywords were once highlighted.
Therefore, if you search for different keywords in the same session, you will find the highlighted keywords will not change. If you search again in a new session, you will find nothing is highlighted.
If you don't want inheriting highlight to bother, switch auto-highlight to "Completely disable".
The only way I can recreate your result is to search some keywords on a supported search site with auto-highlight enabled, go to Ewh's Advanced Config and switch auto-highlight to "Disable for search keywords". Then the search site page will auto refresh and the "old" search keywords are still highlighted.
This is the result of Ewh's inheriting highlight feature, which will keep highlighting the same set of keywords in the same session (e.g. same tab or same window) where a set of keywords were once highlighted.
Therefore, if you search for different keywords in the same session, you will find the highlighted keywords will not change. If you search again in a new session, you will find nothing is highlighted.
If you don't want inheriting highlight to bother, switch auto-highlight to "Completely disable".
@hzhbest - thanks for your reply. I did try to set auto-highlight to "Completely disable", but the problem is the popup menu that's normally shown on the webpage will also completely disappear. What I want is to keep the popup menu on the page and manually toggle the highlight myself, by clicking on the O button in the popup menu.
I ended up modifying the code (I barely know what I'm doing). I got it working the way I wanted by changing a few lines:
change line 321 to this:
no_auto_hili: 1,
change line 325 to this:
no_init_hili: 1,
change line 1280 to this:
if (CFG.no_auto_hili == 1) return true; // 如果不自动高亮,直接退出
by changing the above, I keep the popup menu with no words highlighted. Whenever I need to highlight something, I expand the popup menu, click on E button to add keywords that I want to highlight, then I click the O button to toggle highlight on/off. If I refresh the page, the popup menu is still there, but no words are added and nothing is automatically highlighted.
I did encountered strange things that sometimes on DDG the Advanced Config dialog box didn't show when clicking the script addon menu.
And what's spooky was that could return normal in the same session without any modification to Ewh code. What's spooky too was that only happened on DDG.
Now I finally figure out. That is caused by DDG's hidden iframes that will direct the command to call the Advanced Config dialog box into itself. In another word, the dialog box was shown, but in an invisible iframe. This "bug" I can fix.
-------
I am not sure what you called "popup menu" mean the script addon menu or the highlight panel of Ewh.
As I can understand, what you want is just to turn "When enable auto-highlight, auto highlight keywords on page?..." to "No", which equal to [CFG.no_init_hili:1].
Hi again,
By "popup menu", I meant the highlight panel that is displayed on the page. Here's a screenshot showing what I mean:
https://imgur.com/xSXDnDN
I've just uninstalled the script and installed the latest v1.8.4 version. As you can see in the screenshot, the word "test" is highlighted, but I have auto-highlight set to disabled:
https://imgur.com/7C3HSeg
I only want the highlight to work when I manually toggle the O button in the highlight panel.
Ah, I found a better fix that works the way I want. I just need to comment out the highlight(document.body); line in the resetup function. This will allow the webpage to stop highlighting automatically, but still allows me to manually toggle the highlighting on/off.
function resetup() {
//if (!setuped) {setup(); return;}
restore_words(); //??????
word_lists.forEach(function (item) { item.item.parentNode.removeChild(item.item); }); //????????
//highlight(document.body); //??? words ????
layers = xp_all.get(); //????
word_lists = create_inputlist(words); //????????
draw_wordmap(); //?????
}
Oh now I get it, if set to "No", Ewh should STAY suspended when the page change, which should only be triggered to refresh highlight when Ewh is active.
That is a point I neglected when adding the initial off-highlight setting on demand.
Ready to fix.
Thanks, new version is working great now!
@hzhbest - just noticed another bug. Even though I have auto-highlight set to disabled, but when I type a comment on Youtube, the highlight turns on.
I think I figured out why. The keyboard shortcut to refresh highlight is the 'R' key. If you type any word that contains the letter 'R', such as "great", then it triggers the highlight to on. I'm simply typing a comment in the comment reply box and when the 'R' key is triggered, highlighting is triggered too.
I think it'd be best to set the highlight to a key combination, like ALT+R or something.
// keybinds
const KEY_NEXT = 'M-n'; // "Alt-n" Next occurrence
const KEY_PREV = 'N'; // "Shift-n" Previous occurrence
const KEY_SEARCH = 'M-/'; // "Alt-/" Add keywords
const KEY_OFF = 'M-,'; // "Alt-," Suspend highlight
const KEY_CLOSE = 'C-M-/'; // "Ctrl-Alt-/" Disable highlight
const KEY_EDIT = 'M-.'; // "Alt-." Edit highlight
const KEY_REFRESH = 'M-r'; // "Alt-r" Refresh highlight
Well, that should not happen since Ewh will neglect key press in input fields, such as the search input box. But Youtube use a 'div' element as an input box for comment.
New release will come later. But a fix for this can just be quicker:
# Line 1811 (Under function "keyhandler")
} else if (/^(?:input|textarea)$/i.test(evt.target.localName)) {
=>
} else if (/^(?:input|textarea)$/i.test(evt.target.localName) || evt.target.contentEditable) {
Auto-highlight is set to disabled, and yet it still highlights words on DuckDuckGo