[Hadzy] Youtube Comment Analytics

Hadzy - The best youtube comment picker and great tool to search for all comments, open it with 'Activate' menu button

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         [Hadzy] Youtube Comment Analytics
// @namespace    https://greasyfork.org/en/users/10118-drhouse
// @version      3.1
// @description  Hadzy - The best youtube comment picker and great tool to search for all comments, open it with 'Activate' menu button
// @include      https://www.youtube.com/watch?*
// @include      https://hadzy.com/analytics/youtube/
// @require      http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js
// @require      https://greasemonkey.github.io/gm4-polyfill/gm4-polyfill.js
// @grant        GM_getValue
// @grant        GM_setValue
// @grant        GM_registerMenuCommand
// @author       drhouse
// @icon         https://www.google.com/s2/favicons?domain=youtube.com
// ==/UserScript==
this.$ = this.jQuery = jQuery.noConflict(true);

(function($){

    GM_registerMenuCommand("Activate", function(){
        if (location !== "https://hadzy.com/analytics/youtube/"){
            var here = window.location.href;
            GM_setValue("ytube", here);
            // window.location.href = 'https://hadzy.com/analytics/youtube/';
            window.open('https://hadzy.com/analytics/youtube/');
        }
    }, "A");

    if (window.location.href === 'https://hadzy.com/analytics/youtube/'){
        var storedObject = GM_getValue("ytube");
        var target1 = $('.MuiInputBase-input');
        var target2 = $('.MuiButtonBase-root');
        $(target1).val(storedObject);
        $(target2).click();
        setTimeout(function(){
            var loadButton = $('.MuiButtonBase-root.MuiFab-root');
            $(loadButton).click();
        }, 1000);

        function waitForElementToDisplay(selector, time) {
            if($(selector)!=null) {
                $(selector).click();
                return;
            }
            else {
                setTimeout(function() {
                    waitForElementToDisplay(selector, time);
                }, time);
            }
        }

        var target3 = "div.MuiPaper-root > div.MuiCardContent-root > button"
        waitForElementToDisplay(target3, 1000)
        var target4 = "div.MuiCardContent-root > a:nth-child(2) > button";
        waitForElementToDisplay(target4, 1000)
        //#root > div > div.MuiPaper-root.MuiCard-root.sc-kAzzGY.jujnLM.MuiPaper-elevation1.MuiPaper-rounded > div.MuiCardContent-root.sc-kGXeez.dVnFSi > a:nth-child(2) > button
    }
})(jQuery);