Get a real surge protector, not a cheap one.
Yes, as long as the extension cord actually has a proper surge protector built in — most do, but the cheap ones barely count.
The key spec is the joule rating. For a computer, you want at least 1,000 joules. Lower than that and you’re basically buying a power strip with a fancy light. Also check the clamping voltage — 330V is standard. Higher means less protection.
One thing nobody tells you: surge protectors wear out. Every big spike eats into that joule budget. So if you’ve had the same power strip for five years, it might be doing nothing. And never daisy-chain surge protectors — that’s a fire risk, not more protection.
Your computer is worth more than a ten-dollar extension cord.