Add shortcut
This commit is contained in:
parent
c5a6d8fc53
commit
a10e24198e
BIN
icons/postify-48.png
Normal file
BIN
icons/postify-48.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.0 KiB |
@ -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"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
23
postify.js
23
postify.js
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user