- 实现网页内容提取并导出为Markdown文件 - 支持自动识别和手动选择区域两种提取模式 - 使用Mozilla Readability算法提取页面主要内容 - 使用Turndown将HTML转换为Markdown - React + Vite + TypeScript 技术栈 - 支持图片URL保留、复制到剪贴板、直接下载 Co-Authored-By: Claude <noreply@anthropic.com>
62 lines
1.7 KiB
TypeScript
62 lines
1.7 KiB
TypeScript
// Chrome扩展API类型声明
|
|
declare const chrome: {
|
|
tabs: {
|
|
query: (options: { active?: boolean; currentWindow?: boolean }) => Promise<Array<{ id?: number; title?: string; url?: string }>>;
|
|
sendMessage: (tabId: number, message: any) => Promise<any>;
|
|
};
|
|
runtime: {
|
|
onMessage: {
|
|
addListener: (callback: (message: any, sender: any, sendResponse: (response?: any) => void) => boolean | void) => void;
|
|
};
|
|
openOptionsPage: () => Promise<void>;
|
|
};
|
|
downloads: {
|
|
download: (options: { url: string; filename?: string; saveAs?: boolean }) => Promise<number>;
|
|
onChanged: {
|
|
addListener: (callback: (downloadDelta: any) => void) => void;
|
|
};
|
|
};
|
|
storage: {
|
|
sync: {
|
|
get: (keys?: string | string[] | object) => Promise<any>;
|
|
set: (items: object) => Promise<void>;
|
|
};
|
|
local: {
|
|
get: (keys?: string | string[] | object) => Promise<any>;
|
|
set: (items: object) => Promise<void>;
|
|
};
|
|
};
|
|
};
|
|
|
|
// 声明 TurndownService
|
|
declare class TurndownService {
|
|
constructor(options?: {
|
|
headingStyle?: 'atx' | 'setext';
|
|
codeBlockStyle?: 'fenced' | 'indented';
|
|
bulletListMarker?: '-' | '*' | '+';
|
|
emDelimiter?: '*' | '_';
|
|
strongDelimiter?: '**' | '__';
|
|
linkStyle?: 'inlined' | 'referenced';
|
|
preformattedCode?: boolean;
|
|
});
|
|
turndown(html: string): string;
|
|
addRule(key: string, rule: {
|
|
filter: string | string[] | ((node: any) => boolean);
|
|
replacement: (content: string, node: any) => string;
|
|
}): void;
|
|
}
|
|
|
|
// 声明 Readability
|
|
declare class Readability {
|
|
constructor(doc: Document);
|
|
parse(): {
|
|
title: string;
|
|
content: string;
|
|
textContent: string;
|
|
length: number;
|
|
excerpt: string;
|
|
byline: string;
|
|
dir: string;
|
|
} | null;
|
|
}
|