Set Bing Search page to dark mode by default

Automatically opens hamburger menu (2 secs after page load), once open will then automatically click on the dark mode toggle (1 sec after menu opens), then page will refresh in dark mode. This script excludes the shop page since Bing has no dark mode styles for that page/area. IMPORTANT: The version of Chrome which came out Mid Dec 2023 (Version 120.0.6099.71) for MacOS and PC doesn't support Bings Dark mode. So only use this script if Bing supports dark mode in your browser.

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         Set Bing Search page to dark mode by default
// @namespace    http://tampermonkey.net/
// @description  Automatically opens hamburger menu (2 secs after page load), once open will then automatically click on the dark mode toggle (1 sec after menu opens), then page will refresh in dark mode. This script excludes the shop page since Bing has no dark mode styles for that page/area. IMPORTANT: The version of Chrome which came out Mid Dec 2023 (Version 120.0.6099.71) for MacOS and PC doesn't support Bings Dark mode. So only use this script if Bing supports dark mode in your browser.
// @author       SauceCode
// @version      1.1
// @license MIT
// @match        http*://*.bing.com/*
// @exclude      http*://*.bing.com/?*
// @exclude      http*://*.bing.com/shop*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=tampermonkey.net
// @run-at       document-end
// @grant        none
// ==/UserScript==

(function() {
    'use strict';
    // delay is needed otherwise page isn't ready for this !!
    setTimeout(function () {
        // only run if '.b_dark' class doesn't exist on body (shop page doesn't have dark mode, hence the exclude above)
        if (!document.body.classList.contains('b_dark')) {
            // open menu
            const siteHamburger = document.querySelector('#id_sc')
            siteHamburger.click()
            // second function needs to be on a delay too !!
            setTimeout(function () {
                // click dark radio button
                const darkModeToggle = document.querySelector('#rdiodark')
                darkModeToggle.click()
                // 
            }, 1000)
            //
        }
        //
    }, 2000)
    // end code
})();