I am working on a chrome extension. My manifest.json contains the entry
"content_scripts": [
{
    "matches": ["file:///C:/Example/*"],
    "css": ["my-styles.css"],
    "js": ["content-script.js"],
    "run_at": "document_end"    
 }],    
In the file content-script.js I need to get the url address of the active tab. I tried to define a variable, but it raises error "Uncaught ReferenceError: tabs is not defined"
var url = tabs[0].url;
I also tried defining a function to get the url, but it is also not working, raising error "Uncaught TypeError: Cannot read properties of undefined (reading 'query')"
function get_base_url() {
    var base_url = '';
    chrome.tabs.query({
        active: true,
        lastFocusedWindow: true
    }, function(tabs) {
        base_url = tabs[0].url;
        return base_url;
    }); 
}
