Fix missing page title on context menu share (#14)
This commit is contained in:
parent
eebbfa3225
commit
5c032ac8ee
@ -74,6 +74,7 @@ async function createContextMenu() {
|
|||||||
|
|
||||||
// Function for handling context menu clicks
|
// Function for handling context menu clicks
|
||||||
chrome.contextMenus.onClicked.addListener(async function (info, tab) {
|
chrome.contextMenus.onClicked.addListener(async function (info, tab) {
|
||||||
|
console.log(info, tab)
|
||||||
// Open settings page if requested
|
// Open settings page if requested
|
||||||
if (info.menuItemId === 'edit-servers') {
|
if (info.menuItemId === 'edit-servers') {
|
||||||
chrome.runtime.openOptionsPage()
|
chrome.runtime.openOptionsPage()
|
||||||
@ -82,15 +83,12 @@ chrome.contextMenus.onClicked.addListener(async function (info, tab) {
|
|||||||
// Set link and description
|
// Set link and description
|
||||||
var shareLink = ''
|
var shareLink = ''
|
||||||
var shareText = ''
|
var shareText = ''
|
||||||
if (info.linkUrl) {
|
if (info.selectionText) {
|
||||||
shareLink = info.linkUrl
|
|
||||||
shareText = 'Type something here'
|
|
||||||
} else if (info.selectionText) {
|
|
||||||
shareLink = info.pageUrl
|
shareLink = info.pageUrl
|
||||||
shareText = '"' + info.selectionText + '"'
|
shareText = '"' + info.selectionText + '"'
|
||||||
} else {
|
} else {
|
||||||
shareLink = info.pageUrl
|
shareLink = info.pageUrl
|
||||||
shareText = 'Type something here'
|
shareText = tab.title
|
||||||
}
|
}
|
||||||
// Open popup
|
// Open popup
|
||||||
createPopup(info.menuItemId, shareLink, shareText, tab)
|
createPopup(info.menuItemId, shareLink, shareText, tab)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user