Getting cookies in a google chrome extension

I am trying to get a cookie specifically from a domain using this code: The problem is that the alert always says undefined. However, if I change to it works properly. How do I save the value to use later? Update: It appears that if I call alert(ID) from the chrome console after the script runs, it works. How can I set my code to wait until chrome.cookies.get finishes running? Answer Almost all Chrome API calls are asynchronous, so you need to use callbacks to run code in order:

How to get YouTube URL in background?

For my school project, I need to extract Video URL from Youtube from a Chrome extension. It means I should play a video on Youtube and I need the URL of that video displayed in my chrome extension body. How should I get this video URL using Javascript? Answer window.location.href if you are on the page playing a video.

Disable / Enable Chrome Extension Via Browser Action / Icon

The chrome extension I am developing inserts content scripts and css onto every page of a website. However, the user may have a certain page or pages he or she does not want the extension to run on, so it would be great if I could set up the browser action as basically a toggle on / off. What I’d like to do is something like this: Any help would be greatly appreciated! Answer Such API is not provided. But two possible workarounds exist: I. You can use the “disabled” flag variable and update it from your background page. Background