Add shortcut

This commit is contained in:
Anton Vakhrushev 2018-08-23 09:16:44 +03:00
parent c5a6d8fc53
commit a10e24198e
3 changed files with 20 additions and 11 deletions

BIN
icons/postify-48.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

View File

@ -11,6 +11,7 @@
},
"permissions": [
"activeTab",
"notifications",
"tabs"
],
"background": {
@ -19,5 +20,12 @@
"browser_action": {
"default_icon": "icons/postify-32.png",
"default_title": "Postify"
},
"commands": {
"_execute_browser_action": {
"suggested_key": {
"default": "Ctrl+Shift+D"
}
}
}
}

View File

@ -1,17 +1,18 @@
console.log('Load!');
const APP_NAME = 'Postify';
function onGot(tabInfo) {
var tab = tabInfo[0];
var url = tab.url;
console.log(url);
function sendUrl(url) {
browser.notifications.create({
"type": "basic",
"iconUrl": browser.extension.getURL("icons/postify-48.png"),
"title": APP_NAME,
"message": url,
});
}
function onError(error) {
console.log(`Error: ${error}`);
}
function sendCurrentUrl() {
browser.tabs.query({currentWindow: true, active: true}).then(onGot, onError);
function sendCurrentUrl(args) {
if (args.url) {
sendUrl(args.url)
}
}
browser.browserAction.onClicked.addListener(sendCurrentUrl);