[Niko] Hide Custom Ranking Ads

2025年版ニコニコ カスタムランキングの広告行を非表示化

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         [Niko] Hide Custom Ranking Ads
// @namespace    http://tampermonkey.net/
// @version      2025.06.06
// @description  2025年版ニコニコ カスタムランキングの広告行を非表示化
// @author       anonymous
// @match        https://www.nicovideo.jp/ranking/custom
// @icon         https://www.google.com/s2/favicons?sz=64&domain=nicovideo.jp
// @grant        none
// @license      MIT
// ==/UserScript==

(async function() {
    'use strict';

    function hideAdRow()
    {
        let rows = document.querySelectorAll('.d_flex.gap_x1_5');

        // i=2からランキング行
        for(let i=2; i<rows.length; i++){
            let row = rows[i];
            let rank = row.querySelector('.w_x5')

            if (rank.children.length > 0) {
                //console.log('要素が含まれています');
            } else {

                row.style.display='none'
            }
        }
    }

    //--------------------------------
    hideAdRow();

    // 変化があったらとにかく消す
    const observer = new MutationObserver((mutations) => {
        Array.from(mutations).some((mutation) => {
                Array.from(mutation.addedNodes).some((node) => {
                    hideAdRow();
                });
            });
    });
    observer.observe(document.body, { childList: true, subtree: true });
})();