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": [
|
"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"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
21
postify.js
21
postify.js
@ -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);
|
||||||
|
Loading…
Reference in New Issue
Block a user