Set Bing Search page to dark mode by default
Try this, first time writing one of these.
// ==UserScript==
// @name Set Bing Search page to dark mode by default
// @namespace https://www.bing.com/
// @version 2023-12-15
// @description try to take over the world!
// @author Sauce Code
// @match http*://*.bing.com/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=tampermonkey.net
// @grant none
// ==/UserScript==
(function() {
'use strict';
// Your code here...
window.addEventListener('load', function (event) {
setTimeout(function () {
// only run if has class
if (!document.body.classList.contains('b_dark')) {
// open menu
const siteHamburger = document.querySelector('#id_sc')
siteHamburger.click()
//
setTimeout(function () {
// click toggle
const darkModeToggle = document.querySelector('#rdiodark')
darkModeToggle.click()
}, 2000)
//
}
//
}, 2000)
})
// end code
})();
A better example after working with r4nk.
- we are now using the proper document-end instead of the on load event listener.
// ==UserScript==
// @name Set Bing Search page to dark mode by default
// @namespace https://www.bing.com/
// @version 2023-12-15
// @description try to take over the world!
// @author Sauce Code
// @match http*://*.bing.com/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=tampermonkey.net
// @run-at document-end
// @grant none
// ==/UserScript==
(function() {
'use strict';
// Your code here...
setTimeout(function () {
// only run if has class
if (!document.body.classList.contains('b_dark')) {
// open menu
const siteHamburger = document.querySelector('#id_sc')
siteHamburger.click()
//
setTimeout(function () {
// click toggle
const darkModeToggle = document.querySelector('#rdiodark')
darkModeToggle.click()
}, 2000)
//
}
//
}, 2000)
// end code
})();
Legend !!! I knew you could probably get this working, works a treat. Many thanks bro, hopefully some one else might find this useful too ;)
found a small bug where hamburger drop down pops up on shopping page and doesn't disappear, this is because shopping page has no dark theme, solution was to include:
// @exclude http*://*.bing.com/shop*
We have posted this script officially here..!
https://greasyfork.org/en/scripts/482342-set-bing-search-page-to-dark-mode-by-default
Recently I got sick of Google's reCaptcha's because I aggressively block their cookies and trackers, tried Bing and quite like it. It has a really nice built in dark mode however because my cookies don't stick neither does the theme. I'm wondering how tricky it would be to write a script that sets the dark mode by default. Tried searching for this everywhere but it seems no one had written anything for this. Just curious at this stage. I'm not a coder myself but love using Greasy Fork scripts for this kind of thing :)