Compare commits

..

No commits in common. "803b6b8e10f77796cd63f5ded072edbedccbd472" and "a95d919b0ec7b4b5a54d603edca8813cac90d22b" have entirely different histories.

6 changed files with 4 additions and 56 deletions

View File

@ -1,35 +0,0 @@
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;

View File

@ -1,5 +1 @@
import initContextMenus from "./bindContextMenus";
initContextMenus();
export {}; export {};

View File

@ -5,7 +5,7 @@ import type { ReactNode, PropsWithChildren } from "react";
import styles from "./tab.module.less"; import styles from "./tab.module.less";
interface TabProps extends PropsWithChildren { interface TabProps extends PropsWithChildren {
className?: string; className: string;
} }
interface HeaderProps { interface HeaderProps {

View File

@ -1,13 +0,0 @@
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})`);
}
});

View File

@ -6,11 +6,11 @@ const getTitle = () => {
const metaOgTitle = document.querySelector<HTMLMetaElement>(`meta[name="og:title"]`); const metaOgTitle = document.querySelector<HTMLMetaElement>(`meta[name="og:title"]`);
if (metaOgTitle) { if (metaOgTitle) {
return metaOgTitle.getAttribute("content"); return metaOgTitle.getAttribute("content");;
} }
if (metaTitle) { if (metaTitle) {
return metaTitle.getAttribute("content"); return metaTitle.getAttribute("content");;
} }
if (title.includes(" - ")) { if (title.includes(" - ")) {

View File

@ -27,7 +27,7 @@
}, },
"manifest": { "manifest": {
"permissions": [ "permissions": [
"tabs", "storage", "scripting", "contextMenus" "tabs", "storage", "scripting"
], ],
"host_permissions": [ "host_permissions": [
"https://*/*" "https://*/*"