YT auto comment

Auto-fills comment automatically on YT

이 스크립트를 설치하려면 Tampermonkey, Greasemonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey와 같은 확장 프로그램을 설치해야 합니다.

이 스크립트를 설치하려면 Tampermonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey 또는 Userscripts와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 유저 스크립트 관리자 확장 프로그램이 필요합니다.

(이미 유저 스크립트 관리자가 설치되어 있습니다. 설치를 진행합니다!)

Advertisement:

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

(이미 유저 스타일 관리자가 설치되어 있습니다. 설치를 진행합니다!)

Advertisement:

// ==UserScript==
// @name         YT auto comment
// @namespace    DK 
// @version      1.0.0
// @description  Auto-fills comment automatically on YT
// @author       DK
// @match        https://*.youtube.com/watch*
// @grant        GM_registerMenuCommand
// @run-at       document-idle
// ==/UserScript==

(() => {
  'use strict';

  const ALLOWED_CHANNELS = [
    "MRBREAST"
  ];

  const comments = [
    "Hello Human"
  ];

  const SELECTORS = {
    CHANNEL_NAME: '#text-container.ytd-channel-name',
    COMMENT_BOX: 'ytd-comment-simplebox-renderer div#placeholder-area',
    COMMENT_INPUT: '#contenteditable-root',
  };

  function getChannelName() {
    const el = document.querySelector(SELECTORS.CHANNEL_NAME);
    return el?.innerText?.trim() || null;
  }

  function scrollToComments() {
    document.querySelector('ytd-comments')?.scrollIntoView({ behavior: 'smooth' });
    return new Promise(resolve => setTimeout(resolve, 1500));
  }

  async function fillComment() {
    const commentBox = document.querySelector(SELECTORS.COMMENT_BOX);
    if (!commentBox) {
      alert(" Comment box not found.");
      return false;
    }

    commentBox.click();
    await new Promise(resolve => setTimeout(resolve, 1000));

    const commentInput = document.querySelector(SELECTORS.COMMENT_INPUT);
    if (commentInput) {
      const comment = comments[Math.floor(Math.random() * comments.length)];
      commentInput.focus();
      commentInput.innerText = comment;
      commentInput.dispatchEvent(new InputEvent("input", { bubbles: true }));
      console.log(` Auto-filled comment: "${comment}"`);
      return true;
    } else {
      alert(" Comment input area not found.");
      return false;
    }
  }

  async function autoFillIfAllowed() {
    const channelName = getChannelName();
    if (!channelName) return;

    if (ALLOWED_CHANNELS.includes(channelName)) {
      console.log(` Auto-filling comment on allowed channel: ${channelName}`);
      await scrollToComments();
      await fillComment();
    } else {
      console.log(` Channel not allowed for auto-fill: ${channelName}`);
    }
  }

  // Tampermonkey menu command for manual fill on any channel
  GM_registerMenuCommand(" Manually Auto-Fill Comment", async () => {
    const channelName = getChannelName() || 'Unknown Channel';
    console.log(` Manual fill requested on channel: ${channelName}`);
    await scrollToComments();
    await fillComment();
  });

  // Run auto-fill on page load
  setTimeout(autoFillIfAllowed, 3000);
})();