English | 简体中文
The Dark Mode conversion algorithm for WeChat Official Accounts Platform.
Download the latest release.
Or, install via npm:
npm i mp-darkmode(1) Under non-AMD/CMD rule, insert mp-darkmode into <head>.
<script src="path/to/darkmode.min.js"></script>
<script>
// run dark mode conversion algorithm
Darkmode.run(document.body.querySelectorAll('*')); // process all DOM nodes under body
</script>(2) Under AMD/CMD rule, use require() to import mp-darkmode.
var Darkmode = require('path/to/darkmode.min.js');
// run dark mode conversion algorithm
Darkmode.run(document.body.querySelectorAll('*')); // process all DOM nodes under bodynodes<DOM Object Array> The DOM to be converted.options<Object> Configuration.options.error<Function> Callback triggered when an error occurs.err<Error> Error object.
options.mode<string> The specified color mode (dark | light), if specified, the system color will not be monitored.- ...
- ...
- ...
Run Dark Mode conversion algorithm.
Darkmode.run(document.body.querySelectorAll('*'), {
mode: 'dark', // force dark mode
... // other configuration items
});More detailed usage can refer to API.
Plugins are supported since v1.1.0. Custom actions can be performed during transformation, such as filtering DOM attributes. How to use the plugin is as follows:
Darkmode.extend([pluginA, pluginB, pluginC]);If you want to write your own Dark Mode plugin, you can refer to here。
The algorithm is constantly updated and optimized. If you have a good idea, you can fork and submit your code. For specific development, please refer to Development Guide.

Formed in 2009, the Archive Team (not to be confused with the archive.org Archive-It Team) is a rogue archivist collective dedicated to saving copies of rapidly dying or deleted websites for the sake of history and digital heritage. The group is 100% composed of volunteers and interested parties, and has expanded into a large amount of related projects for saving online and digital history.
