Files
Home-Toolbox-Plugin/contents/copy.ts
T
Paul ef23dda691 Add copy links to markdown
复制链接到 Markdown
2024-09-05 02:19:59 +08:00

14 lines
427 B
TypeScript

chrome.runtime.onMessage.addListener((req) => {
// 复制精简链接
if (req.type === "toolbox:copyLinkToMarkdown") {
const link = `${location.origin}${location.pathname}`;
navigator.clipboard.writeText(`[${document.title}](${link})`);
}
// 复制完整链接带参数
if (req.type === "toolbox:copyLinkToMarkdownFull") {
navigator.clipboard.writeText(`[${document.title}](${location.href})`);
}
});