Add copy links to markdown

复制链接到 Markdown
This commit is contained in:
2024-09-05 02:19:59 +08:00
parent a95d919b0e
commit ef23dda691
4 changed files with 53 additions and 1 deletions
+35
View File
@@ -0,0 +1,35 @@
const initContextMenus = async () => {
chrome.contextMenus.onClicked.addListener(async (info) => {
switch (info.menuItemId) {
case "copy_markdown_links":
case "copy_markdown_links_full":
let tab: chrome.tabs.Tab;
[tab] = await chrome.tabs.query({ active: true, lastFocusedWindow: true });
if (tab && !tab.url.includes("chrome")) {
const messageType = info.menuItemId === "copy_markdown_links"
? "toolbox:copyLinkToMarkdown"
: "toolbox:copyLinkToMarkdownFull";
return await chrome.tabs.sendMessage(tab.id, { type: messageType });
}
break;
}
});
chrome.contextMenus.create({
title: "复制链接为 Markdown",
contexts: ["page"],
id: "copy_markdown_links",
});
chrome.contextMenus.create({
title: "复制完整链接为 Markdown",
contexts: ["page"],
id: "copy_markdown_links_full",
});
};
export default initContextMenus;
+4
View File
@@ -1 +1,5 @@
import initContextMenus from "./bindContextMenus";
initContextMenus();
export {};