cppreference balck mode

cppreference黑夜模式

目前為 2026-02-28 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

Advertisement:

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

Advertisement:

// ==UserScript==
// @name         cppreference balck mode
// @license      The Unlicense
// @namespace    https://github.com/girl-dream/
// @version      1.0.4
// @description  cppreference黑夜模式
// @author       girl-dream
// @match        https://cppreference.cn/*
// @match        https://www.cppreference.com/*
// @icon         https://cppreference.cn/favicon.ico
// @require      https://code.jquery.com/jquery-3.7.1.min.js
// @grant        none
// @run-at       document-end
// ==/UserScript==

(() => {
    'use strict'
    $('#content *:not(a, table, th, tr, tbody,.t-mark-rev,td,tt,.kw1,.co1 span)').not(this).css('color', 'white')
    $('#cpp-content-base, #cpp-footer-base, #bodyContent,body, #cpp-head-first-base,#cpp-head-second-base,.mw-geshi,#cpp-head-second-base span,.t-member').css('background', '#17181A')
    $('table,td').css('color', 'white')
    $('a,tt,a:visited,[class^="sy"],#footer-info-lastmod').css('color', '#9198a1')
    $('th,td,table').css('background', 'rgb(40, 43, 48)')
    $('[class^="kw"],[class^="nu"]').css('color', '#f5ab35')
    $('.mw-geshi').css('background', 'none')
    $('.t-navbar-menu').each(function () {
        $(this).children().first().css('background', 'rgb(40, 43, 48)')
    })
    $('[class^="st"],[class^="br"],[class^="co"]').css('color', '#339900')
    $('.coliru-btn').css({
        'color': 'white',
        'background': 'rgb(40, 43, 48)',
        'box-shadow': 'none',
        'margin-bottom': '6px'
    })
    $('.t-inherited').css('background-color', 'rgb(40, 43, 48)')


    //搜索框
    $('form').attr({
        'target': '_blank',
        'action': 'https://www.bing.com/search'
    })
    $('form').children().first().attr({
        'name': 'q1',
        'value': `site:${location.host}`
    })
    $('input').css({
        'background-color': '#333',
        'color': '#fff',
        'border': '1px solid #555',
        'outline': 'none'
    })
    $("input[type='text'], input[type='password']").css({
        'background-color': '#2d2d2d',
        'color': '#e0e0e0'
    })

    // 去除广告
    window.onload = () => {
        $('[id^="div-gpt-ad"]').remove()
        $('.google-auto-placed').remove()
        $('ins').remove()
    }
})();