Add current url detection

This commit is contained in:
Anton Vakhrushev 2018-08-22 17:42:02 +03:00
parent 949106ce50
commit c5a6d8fc53
2 changed files with 24 additions and 11 deletions

View File

@ -9,18 +9,15 @@
"strict_min_version": "45.0"
}
},
"content_scripts": [
{
"matches": [
"*://*.mozilla.org/*"
],
"js": [
"postify.js"
]
}
"permissions": [
"activeTab",
"tabs"
],
"background": {
"scripts": ["postify.js"]
},
"browser_action": {
"default_icon": "icons/postify-32.png",
"default_title": "Beastify"
"default_title": "Postify"
}
}

View File

@ -1 +1,17 @@
console.log('Yeah!')
console.log('Load!');
function onGot(tabInfo) {
var tab = tabInfo[0];
var url = tab.url;
console.log(url);
}
function onError(error) {
console.log(`Error: ${error}`);
}
function sendCurrentUrl() {
browser.tabs.query({currentWindow: true, active: true}).then(onGot, onError);
}
browser.browserAction.onClicked.addListener(sendCurrentUrl);