|
|
Linha 1: |
Linha 1: |
| document.addEventListener('DOMContentLoaded', function () {
| |
| // Cria o botão de alternância
| |
| const toggle = document.createElement('button');
| |
| toggle.innerText = 'Dark Mode';
| |
| toggle.style.position = 'absolute';
| |
| toggle.style.top = '10px';
| |
| toggle.style.right = '10px';
| |
| toggle.style.background = '#333';
| |
| toggle.style.color = '#fff';
| |
| toggle.style.border = '1px solid #444';
| |
| toggle.style.padding = '5px 10px';
| |
| toggle.style.cursor = 'pointer';
| |
| toggle.style.zIndex = '1000'; // Garante que o botão fique visível sobre tudo
| |
|
| |
|
| // Adiciona a funcionalidade de alternância
| |
| toggle.addEventListener('click', function () {
| |
| document.body.classList.toggle('dark-mode');
| |
| if (document.body.classList.contains('dark-mode')) {
| |
| toggle.innerText = 'Light Mode';
| |
| } else {
| |
| toggle.innerText = 'Dark Mode';
| |
| }
| |
| });
| |
|
| |
| // Adiciona o botão no elemento da skin Timeless
| |
| const timelessToolbar = document.querySelector('.mw-header');
| |
| if (timelessToolbar) {
| |
| timelessToolbar.appendChild(toggle);
| |
| } else {
| |
| // Caso a skin não seja Timeless, adiciona ao body
| |
| document.body.appendChild(toggle);
| |
| }
| |
| });
| |