sharepoint online – Custom CSS hide O365 header carrying to new site when opened in same tab


I have added a custom css spfx extension which simply hides the O365 header below HubNav modern.
Now issue arises when user clicks on a link which opens in same tab, the site they navigate to is also having the css applied even though my spfx extension is applied to just the hub site home. The new site home page has header hidden, but clears off when refreshed.

Is there any way to clear the css by checking if the page is navigating away?

Any other ideas?