// ==UserScript== // @name Automatic Theme Switcher // @namespace https://downloads.khinsider.com/ // @version 0.1 // @description Automatically toggles between light and dark themes for KHInsider based on local time. // @author Inari // @match https://downloads.khinsider.com/* // @grant none // @icon https://upload.wikimedia.org/wikipedia/commons/thumb/5/5d/Oxygen480-actions-document-save.svg/256px-Oxygen480-actions-document-save.svg.png?20220904192514 // @downloadURL none // ==/UserScript== (function () { 'use strict'; const sunriseHour = 6; // 6:00 AM, change as needed const sunsetHour = 18; // 6:00 PM, change as needed const currentHour = new Date().getHours(); const isDarkMode = currentHour >= sunsetHour || currentHour < sunriseHour; const url = new URL(window.location.href); const currentTheme = url.searchParams.get('theme'); const desiredTheme = isDarkMode ? 'dark' : 'light'; if (currentTheme !== desiredTheme) { url.searchParams.set('theme', desiredTheme); window.location.replace(url.toString()); } })();