User:Positron/common.js

From FFXI Wiki

Note: After publishing, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Press Ctrl-F5.
function setTheme(themeName) {
    document.documentElement.className = themeName;
    localStorage.setItem('theme', themeName);
}

theme = localStorage.getItem('theme');
if (theme) {
	if (theme === 'theme-dark') {
	  setTheme('theme-dark');
	} 
	
	if (theme === 'theme-light') {
	  setTheme('theme-light');
	}
	return;
	}
	
	prefersDarkTheme = window.matchMedia('(prefers-color-scheme: dark)');
	if (prefersDarkTheme.matches) {
		setTheme('theme-dark');
		return;
	} 
	
	prefersLightTheme = window.matchMedia('(prefers-color-scheme: light)');
		if (prefersLightTheme.matches) {
		setTheme('theme-light');
	return;
}

setTheme('theme-light');