1 | declare namespace DarkReader {
|
2 | /**
|
3 | * Enables dark mode for current web page.
|
4 | * @param theme Theme options.
|
5 | * @param fixes Fixes for the generated theme.
|
6 | */
|
7 | function enable(theme: Partial<Theme>, fixes?: DynamicThemeFix): void;
|
8 |
|
9 | /**
|
10 | * Disables dark mode for current web page.
|
11 | */
|
12 | function disable(): void;
|
13 |
|
14 | /**
|
15 | * Enables dark mode when system color scheme is dark.
|
16 | * @param theme Theme options.
|
17 | * @param fixes Fixes for the generated theme.
|
18 | */
|
19 | function auto(theme: Partial<Theme> | false, fixes?: DynamicThemeFix): void;
|
20 |
|
21 | /**
|
22 | * Stops watching for system color scheme.
|
23 | * @param isEnabled Boolean `false` value.
|
24 | */
|
25 | function auto(isEnabled: false): void;
|
26 | /**
|
27 | * Returns if darkreader is enabled.
|
28 | */
|
29 | function isEnabled(): boolean;
|
30 |
|
31 | /**
|
32 | * Sets a function for making CORS requests.
|
33 | * @param fetch A fetch function.
|
34 | */
|
35 | function setFetchMethod(fetch: (url: string) => Promise<Response>): void;
|
36 |
|
37 | /**
|
38 | * Returns the generated CSS by Dark Reader as a string.
|
39 | */
|
40 | function exportGeneratedCSS(): Promise<string>;
|
41 |
|
42 | /**
|
43 | * Theme options.
|
44 | */
|
45 | interface Theme {
|
46 | /**
|
47 | * 1 - dark mode, 0 - dimmed mode.
|
48 | * Default 1.
|
49 | */
|
50 | mode: 0 | 1;
|
51 | /**
|
52 | * Brightness (0 - 100+).
|
53 | * Default 100.
|
54 | */
|
55 | brightness: number;
|
56 | /**
|
57 | * Contrast (0 - 100+).
|
58 | * Default 100.
|
59 | */
|
60 | contrast: number;
|
61 | /**
|
62 | * Grayscale (0 - 100).
|
63 | * Default 0.
|
64 | */
|
65 | grayscale: number;
|
66 | /**
|
67 | * Sepia (0 - 100).
|
68 | * Default 0.
|
69 | */
|
70 | sepia: number;
|
71 | /**
|
72 | * Specifies if custom font should be used.
|
73 | * Default false.
|
74 | */
|
75 | useFont: boolean;
|
76 | /**
|
77 | * Font family to use.
|
78 | */
|
79 | fontFamily: string;
|
80 | /**
|
81 | * Makes text look bolder (0 - 1px).
|
82 | * Default 0.
|
83 | */
|
84 | textStroke: number;
|
85 | /**
|
86 | * Background color to use for dark mode.
|
87 | * Default #181a1b
|
88 | */
|
89 | darkSchemeBackgroundColor: string;
|
90 | /**
|
91 | * Text color to use for dark mode.
|
92 | * Default #e8e6e3
|
93 | */
|
94 | darkSchemeTextColor: string;
|
95 | /**
|
96 | * Background color to use for light mode.
|
97 | * Default #dcdad7
|
98 | */
|
99 | lightSchemeBackgroundColor: string;
|
100 | /**
|
101 | * Text color to use for light mode.
|
102 | * Default #181a1b
|
103 | */
|
104 | lightSchemeTextColor: string;
|
105 | /**
|
106 | * Scrollbar color
|
107 | * Default auto
|
108 | */
|
109 | scrollbarColor: string;
|
110 | /**
|
111 | * Selection color
|
112 | * Default auto
|
113 | */
|
114 | selectionColor: string;
|
115 | /**
|
116 | * Specifies if it has to style system controls
|
117 | * Default true
|
118 | */
|
119 | styleSystemControls: boolean;
|
120 | }
|
121 |
|
122 | /**
|
123 | * Contains fixes for the generated theme.
|
124 | */
|
125 | interface DynamicThemeFix {
|
126 | /**
|
127 | * List of CSS selectors that should be inverted.
|
128 | * Usually icons that are contained in sprites.
|
129 | */
|
130 | invert: string[];
|
131 | /**
|
132 | * Additional CSS.
|
133 | * ${color} template should be used to apply theme options to a color.
|
134 | * Example:
|
135 | * ```
|
136 | * body {
|
137 | * background-color: ${white} !important;
|
138 | * background-image: none !important;
|
139 | * }
|
140 | * ```
|
141 | */
|
142 | css: string;
|
143 | /**
|
144 | * List of CSS selectors where it's inline style should not be analyzed
|
145 | * Mostly used for color pickers
|
146 | */
|
147 | ignoreInlineStyle: string[];
|
148 | /**
|
149 | * List of CSS selectors where it's image should not be analyzed
|
150 | * Mostly used for wrongly inverted background-images
|
151 | */
|
152 | ignoreImageAnalysis: string[];
|
153 |
|
154 | /**
|
155 | * A toggle to disable the proxying of `document.styleSheets`.
|
156 | * This is a API-Exclusive option, as it can break legitmate websites,
|
157 | * who are using the Dark Reader API.
|
158 | */
|
159 | disableStyleSheetsProxy: boolean;
|
160 | }
|
161 | }
|
162 |
|
163 | declare module 'darkreader' {
|
164 | export = DarkReader;
|
165 | }
|