Detect whether a url is opened

I want my extension to listen for when a url in “matches” key in “content-scripts” is opened. I read that background scripts should handle this type of event but dont know how to put them into code.