14 lines
427 B
TypeScript
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})`);
|
|
}
|
|
});
|