vPlus

让 v2ex 跟随系统的深色/浅色模式

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

You will need to install an extension such as Tampermonkey to install this script.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

You will need to install an extension such as Tampermonkey to install this script.

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==UserScript==
// @name         vPlus
// @namespace    https://greasyfork.org/en/users/190451-leo-aee
// @version      0.1.4
// @description  让 v2ex 跟随系统的深色/浅色模式
// @author       Leoaee
// @icon         https://cdn.jsdelivr.net/gh/mopig/oss@master/uPic/202005/v_logo.png
// @include      https://*.v2ex.com/*
// @include      https://v2ex.com/*
// @match        <$URL$>
// @grant        none
// @license      LGPLv3
// ==/UserScript==

(function() {
    'use strict';

    // Your code here...
    function detectColorScheme(){
        var ret = window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light'
        return ret;
    }
    var curScheme = detectColorScheme()
    var curColor = document.querySelector('.light-toggle > img').alt.toLowerCase()
    if(curScheme !== curColor) {
        document.querySelector('.light-toggle').click()
    }
})();