How to customize/remove Chrome yellow highlight from search result hash bang
So I did a google search, which made me land on this question.
As you can see, if you are using Chrome, some content matching the #targetText=xxx
of the hash bang is highlighted:
But in the dev tools, it is nowhere to be found in styles definition, not even in User Agent styles.
How can it be disabled/customized?
Is that me or Google just invited itself into all our websites?
Solution 1:
This feature is described by Chrome in the article ScrollToTextFragmentEnabled group policy. It was only recently added to Chrome and may still be evolving. It is not supported by other browsers except for Microsoft Edge and other variants of Chromium.
Under Windows, group policies are specified in the registry at
HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Google\Chrome
.
This specific policy is set by the DWORD value ScrollToTextFragmentEnabled
whose value is 0
to disable and 1
to enable.
Tested as working on Chrome version 84.
For the Mac, see the answer by storoj.
For Linux, Chrome/chromium settings are stored in the .config
directory in home
.
This hidden folder can be unhidden in nautilus by pressing
CTRL+H (link).
google chrome: ~/.config/google-chrome/Default/Preferences
chromium: ~/.config/chromium/Default/Preferences
The preference name is ScrollToTextFragmentEnabled
. (Not tested by me)
Website designers may elect to disable it for their website by including the
HTTP header Document-Policy: force-load-at-top
.
Unfortunately, users cannot force it on their side, since extensions like
Greasemonkey/Tampermonkey cannot modify received HTTP headers.
The List of Chromium Command Line Switches by Peter Beverloo lists this command-line switch:
--disable-scroll-to-text-fragment : This switch disables the ScrollToTextFragment feature
However, under Windows with Chrome version 84 this switch had no effect.
Solution 2:
Check this reddit thread.
It says that the setting is called ScrollToTextFragmentEnabled
, and it could be disabled via Chrome Enterprise Policy.
This worked on Mac:
$ defaults write com.google.Chrome ScrollToTextFragmentEnabled -bool false
In Windows create chrome.reg
with contents:
Windows Registry Editor Version 5.00
; chrome version: 84.0.4147.125
[HKEY_LOCAL_MACHINE\Software\Policies\Google\Chrome]
"ScrollToTextFragmentEnabled"=dword:00000000
and then double-click it to apply the changes.
For more examples you can download "Chrome ADM/ADMX Templates" from https://chromeenterprise.google/browser/download/, and check policy_templates/windows/examples/chrome.reg