Skip to content

Instantly share code, notes, and snippets.

@hsinewu
Created February 6, 2017 08:38
Show Gist options
  • Save hsinewu/c7e19fa6a26489e188c4ae88e57510f4 to your computer and use it in GitHub Desktop.
Save hsinewu/c7e19fa6a26489e188c4ae88e57510f4 to your computer and use it in GitHub Desktop.
webextension tab url
{
"manifest_version": 2,
"name": "Tab url",
"description": "Shows url of the current page",
"version": "1.0",
"browser_action": {
"default_icon": "icon.png",
"default_popup": "popup.html"
},
"permissions": [
"tabs"
]
}
<div id="info"></div>
<script src="popup.js"></script>
var queryInfo = {
active: true,
lastFocusedWindow: true
}
chrome.tabs.query(queryInfo, function (tabs) {
var url = tabs[0].url;
info.textContent = url
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment