If clicking links is redirecting you to advertisements, then your system may be too compromised to save without a lot of expert intervention, and a reformat might be in order.
That said, Malwarebytes is the first tool you should try: https://www.malwarebytes.org/ (this is a valid link, so if it takes you anywhere besides the Malwarebytes site, then the issue is with your computer). Once you've ensured that there's no malware on your system, try CCleaner to clean out the leftovers: https://www.piriform.com/ccleaner