mirror of
https://github.com/Jonnyan404/memos-bber.git
synced 2026-04-25 03:58:37 +09:00
右键菜单的一系列改进
This commit is contained in:
+38
-6
@@ -2,14 +2,46 @@ chrome.runtime.onInstalled.addListener(() => {
|
||||
chrome.contextMenus.create(
|
||||
{
|
||||
type: 'normal',
|
||||
title: chrome.i18n.getMessage("sendTo") + '“%s”',
|
||||
id: 'Memos-send',
|
||||
contexts: ['all']
|
||||
title: chrome.i18n.getMessage("sendTo"),
|
||||
id: 'Memos-send-selection',
|
||||
contexts: ['selection']
|
||||
},
|
||||
)
|
||||
chrome.contextMenus.create(
|
||||
{
|
||||
type: 'normal',
|
||||
title: chrome.i18n.getMessage("sendLinkTo"),
|
||||
id: 'Memos-send-link',
|
||||
contexts: ['link', 'page']
|
||||
},
|
||||
)
|
||||
chrome.contextMenus.create(
|
||||
{
|
||||
type: 'normal',
|
||||
title: chrome.i18n.getMessage("sendImageTo"),
|
||||
id: 'Memos-send-image',
|
||||
contexts: ['image']
|
||||
},
|
||||
)
|
||||
})
|
||||
let tempCont=''
|
||||
chrome.contextMenus.onClicked.addListener(info => {
|
||||
tempCont += info.selectionText + '\n'
|
||||
chrome.storage.sync.set({open_action: "save_text",open_content:tempCont});
|
||||
let tempCont=''
|
||||
switch(info.menuItemId){
|
||||
case 'Memos-send-selection':
|
||||
tempCont = info.selectionText + '\n'
|
||||
break
|
||||
case 'Memos-send-link':
|
||||
tempCont = (info.linkUrl || info.pageUrl) + '\n'
|
||||
break
|
||||
case 'Memos-send-image':
|
||||
tempCont = `` + '\n'
|
||||
break
|
||||
}
|
||||
chrome.storage.sync.get({open_action: "save_text", open_content: ''}, function(items) {
|
||||
if(items.open_action === 'upload_image') {
|
||||
alert(chrome.i18n.getMessage("picPending"));
|
||||
} else {
|
||||
chrome.storage.sync.set({open_action: "save_text", open_content: items.open_content + tempCont});
|
||||
}
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user