>>107939140
Can you try this version?? I think it should work
// ==UserScript==
// @name 4chanX Theme Switcher (Yotsuba/Tomorrow)
// @namespace http://tampermonkey.net/
// @version 1.4
// @description Switch between Yotsuba B New, Yotsuba B, and Tomorrow themes based on system dark mode
// @match *://boards.4chan.org/*
// @match *://boards.4channel.org/*
// @grant none
// @run-at document-body
// ==/UserScript==
(function() {
'use strict';
//this needs to run before 4chanX can replace the favicon with their custom ones, hence the running at document-body
const is_worksafe_board = document.head.querySelector('link[rel="shortcut icon"]').href.includes('-ws');
function after_DOMContentLoaded() {
function switchTheme(isDark) {
const styleSelector = document.querySelector('#styleSelector');
if (styleSelector) {
styleSelector.value = isDark ? "Tomorrow" : is_worksafe_board ? "Yotsuba B New" : "Yotsuba New";
styleSelector.dispatchEvent(new Event('change'));
}
}
// Set initial theme and listen for changes
const darkModeMediaQuery = window.matchMedia('(prefers-color-scheme: dark)');
switchTheme(darkModeMediaQuery.matches);
darkModeMediaQuery.addListener(e => switchTheme(e.matches));
}
//if readyState isn't loading then DOMContentLoaded will have already fired so call immediately
if (document.readyState !== 'loading') { after_DOMContentLoaded(); }
else { document.addEventListener("DOMContentLoaded", after_DOMContentLoaded, { once: true }); }
})();