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": [ "permissions": [
"activeTab", "activeTab",
"notifications",
"tabs" "tabs"
], ],
"background": { "background": {
@ -19,5 +20,12 @@
"browser_action": { "browser_action": {
"default_icon": "icons/postify-32.png", "default_icon": "icons/postify-32.png",
"default_title": "Postify" "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) { function sendUrl(url) {
var tab = tabInfo[0]; browser.notifications.create({
var url = tab.url; "type": "basic",
console.log(url); "iconUrl": browser.extension.getURL("icons/postify-48.png"),
"title": APP_NAME,
"message": url,
});
} }
function onError(error) { function sendCurrentUrl(args) {
console.log(`Error: ${error}`); if (args.url) {
sendUrl(args.url)
} }
function sendCurrentUrl() {
browser.tabs.query({currentWindow: true, active: true}).then(onGot, onError);
} }
browser.browserAction.onClicked.addListener(sendCurrentUrl); browser.browserAction.onClicked.addListener(sendCurrentUrl);