It Works On Reloading the browser but not all the time.
The solution metioned by @Martin Schneider works but if u are working with manifest v3 then try using
chrome.scripting.executeScript
Instead of
chrome.tabs.executeScript
Also make sure if having host_permission should match the content_scripts matches in the manifest file