Page 1 of 1

Toggle highlighting in Results.

Posted: Wed May 12, 2021 9:30 am
by jsfiddler
Refering to the post: highlighted-keywords-hinder-quick-reading-8843#p25092, a possible solution would be to use the following bookmarklet, which changes the class of the highlights (<span class="search">HIGHLIGHT</span>), such that the css-rules which highlight those words do not apply anymore and the text can be read more quickly. Furthermore, for the duration of the session, the user choice is stored inside the browsers SessionStorage, in order for the highlights to be restored (toogled) if wanted.

Heres the code:

Code: Select all

javascript:if (!Number(sessionStorage.getItem('searchHighlightToggle'))==1) { sessionStorage.setItem('searchHighlightToggle',1); document.querySelectorAll('.search').forEach(e=>e.setAttribute('class','noHighlighting')); }else { sessionStorage.setItem('searchHighlightToggle',0); document.querySelectorAll('.noHighlighting').forEach(e=>e.setAttribute('class','search')); }