feat: 1.0.3 引入 Dark Reader 通用暗色引擎

This commit is contained in:
2026-08-08 17:21:22 +08:00
parent b36ad30d7a
commit 202ab537d1
29 changed files with 19555 additions and 207 deletions
+23
View File
@@ -0,0 +1,23 @@
MIT License
Copyright (c) 2026 Dark Reader Ltd.
All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
+9366
View File
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+173
View File
@@ -0,0 +1,173 @@
declare namespace DarkReader {
/**
* Enables dark mode for current web page.
* @param theme Theme options.
* @param fixes Fixes for the generated theme.
*/
function enable(theme: Partial<Theme>, fixes?: DynamicThemeFix): void;
/**
* Disables dark mode for current web page.
*/
function disable(): void;
/**
* Enables dark mode when system color scheme is dark.
* @param theme Theme options.
* @param fixes Fixes for the generated theme.
*/
function auto(theme: Partial<Theme> | false, fixes?: DynamicThemeFix): void;
/**
* Stops watching for system color scheme.
* @param isEnabled Boolean `false` value.
*/
function auto(isEnabled: false): void;
/**
* Returns if darkreader is enabled.
*/
function isEnabled(): boolean;
/**
* Sets a function for making CORS requests.
* @param fetch A fetch function.
*/
function setFetchMethod(fetch: (url: string) => Promise<Response>): void;
/**
* Returns the generated CSS by Dark Reader as a string.
*/
function exportGeneratedCSS(): Promise<string>;
/**
* Theme options.
*/
interface Theme {
/**
* 1 - dark mode, 0 - dimmed mode.
* Default 1.
*/
mode: 0 | 1;
/**
* Brightness (0 - 100+).
* Default 100.
*/
brightness: number;
/**
* Contrast (0 - 100+).
* Default 100.
*/
contrast: number;
/**
* Grayscale (0 - 100).
* Default 0.
*/
grayscale: number;
/**
* Sepia (0 - 100).
* Default 0.
*/
sepia: number;
/**
* Specifies if custom font should be used.
* Default false.
*/
useFont: boolean;
/**
* Font family to use.
*/
fontFamily: string;
/**
* Makes text look bolder (0 - 1px).
* Default 0.
*/
textStroke: number;
/**
* Background color to use for dark mode.
* Default #181a1b
*/
darkSchemeBackgroundColor: string;
/**
* Text color to use for dark mode.
* Default #e8e6e3
*/
darkSchemeTextColor: string;
/**
* Background color to use for light mode.
* Default #dcdad7
*/
lightSchemeBackgroundColor: string;
/**
* Text color to use for light mode.
* Default #181a1b
*/
lightSchemeTextColor: string;
/**
* Scrollbar color
* Default auto
*/
scrollbarColor: string;
/**
* Selection color
* Default auto
*/
selectionColor: string;
/**
* Specifies if it has to style system controls
* Default true
*/
styleSystemControls: boolean;
}
/**
* Contains fixes for the generated theme.
*/
interface DynamicThemeFix {
/**
* List of CSS selectors that should be inverted.
* Usually icons that are contained in sprites.
*/
invert: string[];
/**
* Additional CSS.
* ${color} template should be used to apply theme options to a color.
* Example:
* ```
* body {
* background-color: ${white} !important;
* background-image: none !important;
* }
* ```
*/
css: string;
/**
* List of CSS selectors where it's inline style should not be analyzed
* Mostly used for color pickers
*/
ignoreInlineStyle: string[];
/**
* List of CSS selectors where it's image should not be analyzed
* Mostly used for wrongly inverted background-images
*/
ignoreImageAnalysis: string[];
/**
* A toggle to disable the proxying of `document.styleSheets`.
* This is a API-Exclusive option, as it can break legitimate websites,
* who are using the Dark Reader API.
*/
disableStyleSheetsProxy: boolean;
/**
* List of stylesheet URL patterns to ignore.
* Stylesheets matching these patterns will not be processed by Dark Reader.
* - Simple string: matches if URL contains the string (e.g., "crisp")
* - Prefix with ^: matches if URL starts with pattern (e.g., "^https://client.crisp")
* - Suffix with $: matches if URL ends with pattern (e.g., ".css$")
*/
ignoreCSSUrl: string[];
}
}
declare module 'darkreader' {
export = DarkReader;
}
+9
View File
@@ -0,0 +1,9 @@
{
"name": "darkreader",
"version": "4.9.129",
"description": "Dark mode for every website",
"main": "darkreader.js",
"module": "darkreader.mjs",
"types": "index.d.ts",
"license": "MIT"
}