Chrome extensions: make chrome.tabs.query() synchronous

asynchronous, google-chrome-extension, javascript

Solution

Unless there is some hidden functionality in the query function this is not possible. http://developer.chrome.com/extensions/tabs.html#method-query

Problem

I am currently using this code: ``` url = "unknown"; chrome.tabs.query({'active': true, 'lastFocusedWindow': true}, function(tabs) { console.log(tabs); //test, prints one-element array as expected url = tabs[0].url; }); $("#url_div").html(url); ``` to get current URL, but `chrome.tabs.query()` is asynchronous, how can I make it synchronous? (i.e. add `asynch: false` somewhere) I know I could set the URL inside the query, or call another function from there, but best would be (example is simplifed) if it wasnt asynch.

Original source