Add action button

This commit is contained in:
Corbin Davenport 2022-12-18 16:51:11 -05:00
parent 4de44b6cba
commit ee924b97b5
2 changed files with 29 additions and 5 deletions

View File

@ -70,7 +70,6 @@ chrome.contextMenus.onClicked.addListener(async function (info, tab) {
resolve(data.userServer)
})
})
console.log('Retrieved server:', server)
// Open settings if needed
if (!server) {
chrome.runtime.openOptionsPage()
@ -96,3 +95,22 @@ chrome.contextMenus.onClicked.addListener(async function (info, tab) {
createPopup(server, shareLink, shareText, tab)
}
})
// Function for action button
chrome.action.onClicked.addListener(async function (tab) {
// Check if there is a saved server
var server = await new Promise(function (resolve) {
chrome.storage.sync.get(function (data) {
resolve(data.userServer)
})
})
// Open settings if needed
if (!server) {
chrome.runtime.openOptionsPage()
return false
}
// Open popup
var shareLink = tab.url
var shareText = tab.title
createPopup(server, shareLink, shareText, tab)
})

View File

@ -9,13 +9,19 @@
"page": "settings.html",
"open_in_tab": false
},
"omnibox": {
"keyword": "wiki"
"action": {
"default_icon": {
"16": "img/icon_x16.png",
"32": "img/icon_x32.png",
"48": "img/icon_x48.png"
},
"default_title": "Share this page to Mastodon"
},
"permissions": [
"contextMenus",
"storage",
"notifications"
"notifications",
"activeTab"
],
"minimum_chrome_version": "93",
"background": {