Quit Safari. Download and run Malwarebytes for Mac to look for any ad/malware that has been installed on your Mac. Malwarebytes will also remove the infestation(s) if it finds any. It is highly recommended in these support communities, and is not an anti-virus tool.
One you have finished with Malwarebytes, press and hold the shift key, and launch Safari again. If you already have the Developer menu item, press option+command+E to clear the browser cache. Otherwise, visit Safari Preferences : Advanced panel and select Show Develop menu in menu bar, and perform the preceding sentence to clear cache. Also, on the Safari application menu, select Clear History : [all history] and select Clear History. Quit Safari, and relaunch normally.
Is the anysearchmanager still present?