I went to the Apple web site (where I frequently got a pop up insisting I was infected, like I have been getting at most sites; may have solved that... may)
There are two separate things that can be causing your problem. One is a malicious extension in Safari, and the other is a malicious ad pushed to the Web site(s) you are visiting. I wrote an entire article about this, back when a malicious ad could pretend to be holding your Mac for ransom:
Scary Internet Scam Becoming Disturbingly Common
https://tidbits.com/2015/07/07/scary-internet-scam-becoming-disturbingly-common/
If you are getting those scam ads on a lot of different Web sites, especially Apple's, it is unlikely that you are dealing with malicious ads coming from a poisoned ad network. (Apple's Web site doesn't subscribe to an ad network). So an ad blocker won't do you any good in this case. In any case, I just want to let folks know that instead of using an ad blocker, I've been using a new browser that has the built-in ability to block ads and trackers, and I'm loving it:
Brave (free)
https://brave.com
It turns out that if ads and trackers are blocked, and hence don't have to be loaded, your browser becomes quite a bit faster!
So, how do you get rid of the malicious extension that is causing you problems? Most folks will recommend MalwareBytes, a popular adware removal tool:
MalwareBytes (free/pay)
https://www.malwarebytes.com
But since the MalwareBytes folks developed their commercial version, the product installs way too much garbage and is too hard to remove for my tastes. Instead I now recommend the similar:
DetectX (free, $10 requested)
https://sqwarq.com/detectx/
Apple is rumored to be dropping the ability to add extensions in a future version of Safari, which will make this a non-problem for Safari users.