YT auto comment

Auto-fills comment automatically on YT

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey, Greasemonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला 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);
})();