Add action button
This commit is contained in:
parent
4de44b6cba
commit
ee924b97b5
|
@ -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()
|
||||
|
@ -95,4 +94,23 @@ chrome.contextMenus.onClicked.addListener(async function (info, tab) {
|
|||
// Open popup
|
||||
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)
|
||||
})
|
|
@ -6,16 +6,22 @@
|
|||
"homepage_url": "https://github.com/corbindavenport/share-to-mastodon",
|
||||
"description": "Share links to Mastodon in one click!",
|
||||
"options_ui": {
|
||||
"page": "settings.html",
|
||||
"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": {
|
||||
|
|
Loading…
Reference in New Issue