YouTube Night Mode & Ad Remover

Adds night mode button to YouTube and removes ads.

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         YouTube Night Mode & Ad Remover
// @namespace    https://greasyfork.org/users/123456
// @version      1.0
// @description  Adds night mode button to YouTube and removes ads.
// @author       Saimen Nemias
// @match        https://www.youtube.com/*
// @icon         https://www.youtube.com/s/desktop/8bb15d8c/img/favicon_32x32.png
// @grant        none
// @license      none
// ==/UserScript==

(function() {
    'use strict';

    // Add night mode button
    const nightModeButton = document.createElement('button');
    nightModeButton.innerText = 'Night Mode';
    nightModeButton.style.position = 'fixed';
    nightModeButton.style.bottom = '10px';
    nightModeButton.style.right = '10px';
    nightModeButton.style.padding = '10px';
    nightModeButton.style.backgroundColor = '#000';
    nightModeButton.style.color = '#fff';
    nightModeButton.style.border = 'none';
    nightModeButton.style.borderRadius = '5px';
    document.body.appendChild(nightModeButton);

    nightModeButton.addEventListener('click', () => {
        document.body.classList.toggle('night-mode');
        document.body.classList.contains('night-mode') ? 
            document.body.style.backgroundColor = '#181818' :
            document.body.style.backgroundColor = '#fff';
    });

    // Remove ads
    const observer = new MutationObserver(() => {
        const ads = document.querySelectorAll('.ad-container');
        ads.forEach(ad => ad.remove());
    });

    observer.observe(document.body, { childList: true, subtree: true });

    // Donation message
    console.log('Se você gostou deste script e deseja apoiar o desenvolvimento, considere fazer uma doação em [Buy Me a Coffee](https://buymeacoffee.com/saimen). Agradeço pelo apoio!');
})();