YouTube Night Mode & Ad Remover

Adds night mode button to YouTube and removes ads.

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 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!');
})();