show content tree

にこにこ動画でコンテンツツリーボタンを追加

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey, το Greasemonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

You will need to install an extension such as Tampermonkey to install this script.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Userscripts για να εγκαταστήσετε αυτόν τον κώδικα.

You will need to install an extension such as Tampermonkey to install this script.

Θα χρειαστεί να εγκαταστήσετε μια επέκταση διαχείρισης κώδικα χρήστη για να εγκαταστήσετε αυτόν τον κώδικα.

(Έχω ήδη έναν διαχειριστή κώδικα χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Έχω ήδη έναν διαχειριστή στυλ χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

// ==UserScript==
// @name         show content tree
// @namespace    com.blowham.show_content_tree
// @version      0.1.1
// @description  にこにこ動画でコンテンツツリーボタンを追加
// @author       hukihamu
// @match        https://www.nicovideo.jp/watch/*
// @require      https://code.jquery.com/jquery-3.3.1.min.js
// @grant        none
// ==/UserScript==

(function() {
    function setIcon(){
        let findCount = 0
        const findInterval = setInterval(function(){
            if(180 < findCount){
                clearInterval(findInterval)
                findCount = 10000
            }
            findCount++
            const menu = document.getElementsByClassName("VideoMenuContainer-areaLeft")[0]
            if ( menu !== undefined ){
                const treeDiv = document.createElement("div")
                treeDiv.className = "ClickInterceptor is-inline LoginRequirer"
                const dStyle = treeDiv.style
                dStyle.width = "28px"
                dStyle.height = "28px"
                dStyle.margin = "0px"

                const treeButton = document.createElement("button")
                treeButton.className = "ActionButton VideoMenuContainer-button"
                treeButton.onclick = onClickTree
                $(treeButton).attr("data-title","コンテンツツリー")
                const bStyle = treeButton.style
                bStyle.backgroundImage = "url(http://commons.nicovideo.jp/cpp/img/common/sprite/sprite_gmenu.png)"
                bStyle.backgroundColor = "transparent"
                bStyle.backgroundRepeat = "no-repeat"
                bStyle.border = "none"
                bStyle.padding = "2px"
                bStyle.backgroundPosition = "2px -104px"
                bStyle.transitionDuration = "0ms"
                bStyle.width = "24px"
                bStyle.height = "24px"
                $(treeButton).hover(function(){
                    $(this).css("background-position", "2px -140px");
                },function(){
                    $(this).css("background-position", "2px -104px");
                })

                treeDiv.appendChild(treeButton)
                menu.insertBefore(treeDiv,menu.childNodes[2])


                clearInterval(findInterval)
                findCount = 10000

            }
        }, 1000)
    }
    function onClickTree(){
        window.open("http://commons.nicovideo.jp/tree/" + location.href.substring(location.href.lastIndexOf('/') + 1))

    }
    window.onLoad = setIcon()
})();