[Hadzy] Youtube Comment Analytics

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

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

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

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

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

你需要先安裝一款使用者腳本管理器擴展,比如 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);