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.
Open the Chrome menu (click the 3-dot menu in the upper-right corner of Chrome) Click Settings. Scroll to the On Startup section at the bottom of the page. Click to enable the setting Continue where you left off.
Close the chrome://inspect/#pages page. You can use sendkeys Ctrl & 1 to move to the first tab and the use the sendkeys Ctrl & Tab to iterate through the tabs.
Windows & Linux: Ctrl + t. Mac: ⌘ + t.
From there, the tab ID is accessible via 'sender.tab.id'. See http://code.google.com/chrome/extensions/messaging.html for more info. You received this message because you are subscribed to the Google Groups "Chromium-extensions" group.
Unless there is some hidden functionality in the query function this is not possible. http://developer.chrome.com/extensions/tabs.html#method-query
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With