편집 요약 없음 태그: 수동 되돌리기 |
편집 요약 없음 태그: 되돌려진 기여 |
||
| 1번째 줄: | 1번째 줄: | ||
/* 이 자바스크립트 설정은 리버티 스킨을 사용하는 사용자에게 적용됩니다 */ | /* 이 자바스크립트 설정은 리버티 스킨을 사용하는 사용자에게 적용됩니다 */ | ||
// 요소 선택 | |||
const header = document.querySelector('.liberty-content-header'); | |||
// 다크 모드 적용 함수 | |||
function applyColorScheme() { | |||
// 다크 모드 감지 | |||
if (window.matchMedia('(prefers-color-scheme: dark)').matches) { | |||
// 다크 모드일 경우 배경색을 검정색으로 설정 | |||
header.style.backgroundColor = 'black'; | |||
header.style.color = 'white'; // 텍스트 색상도 흰색으로 설정 | |||
} else { | |||
// 기본 모드일 경우 배경색을 흰색으로 설정 | |||
header.style.backgroundColor = 'white'; | |||
header.style.color = 'black'; // 텍스트 색상도 검정색으로 설정 | |||
} | |||
} | |||
// 페이지 로드 시 색상 적용 | |||
applyColorScheme(); | |||
// 다크 모드가 변경될 때마다 색상 변경 | |||
window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', applyColorScheme); | |||
2025년 1월 13일 (월) 13:26 판
/* 이 자바스크립트 설정은 리버티 스킨을 사용하는 사용자에게 적용됩니다 */
// 요소 선택
const header = document.querySelector('.liberty-content-header');
// 다크 모드 적용 함수
function applyColorScheme() {
// 다크 모드 감지
if (window.matchMedia('(prefers-color-scheme: dark)').matches) {
// 다크 모드일 경우 배경색을 검정색으로 설정
header.style.backgroundColor = 'black';
header.style.color = 'white'; // 텍스트 색상도 흰색으로 설정
} else {
// 기본 모드일 경우 배경색을 흰색으로 설정
header.style.backgroundColor = 'white';
header.style.color = 'black'; // 텍스트 색상도 검정색으로 설정
}
}
// 페이지 로드 시 색상 적용
applyColorScheme();
// 다크 모드가 변경될 때마다 색상 변경
window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', applyColorScheme);