This hosting is not for free. You might want to consider disabling AdBlock or other extensions hiding ads. I'd appreciate that! Even if you don't do that, this web is fully functional so don't worry.

Privacy Terms

Automatic Prefilled Comment Replies at YouTube Studio

I get a lot of comments on my videos, and my most frequent reply is Thank you!. Even when I write a more complex one, I often include thanks somewhere in the comment. When the views of a video go wild, I sometimes even copy and paste the same thanking comment many times. YouTube offers the automatic reply suggestions, but they are often imprecise and not even visible under most of the comments since their language model probably did not find a proper response. YouTube Studio does not offer a default comment reply. I wanted to have an automatic, predefined, templated answer to the video comments that I can easily post just like forms autofill on many pages. Well, I implemented it by myself.

YouTube Creator Studio with the Comments section, automatic suggestions and reply box.
YouTube Creator Studio with the Comments section, automatic suggestions and reply box.

My initial idea was to create a custom JavaScript, use the Custom JavaScript for Websites 2 extension, and simply run a script that would fill the reply boxes for me. I did that as a proof of concept and then transformed the code into a standalone extension that is available here.

So the main idea was to add a callback function to the Reply button. After some experiments, I found it difficult to fill the text area HTML element since it was not ready when I clicked the button. I changed the strategy to the text area itself. Below is the code with comments. This code is to be run only in the Comments section of YouTube Creator Studio. The code detects if the textarea HTML element was entered, which happens automatically after clicking the button to reply. If the element is empty, the default comment string is inserted. And, that's all!

// Run the script when the window is loaded with all the elements
window.addEventListener('load', function () {
  // Intercept every focus-in event (for example, when the textarea is entered)
  window.addEventListener("focusin", (event) => {
    // If the event happened in textarea element
    if(event.target.nodeName="TEXTAREA")
    // If the area is empty to avoid replacement of a comment in progress
    if(event.target.value == '')
    {
        // Load the stored default reply string
	  chrome.storage.sync.get("studioReply", function(value){
            // Inserting the string in the text area would be the straightforward solution but...
	    // event.target.value = value["studioReply"];
            // Simulate a typing in the text area, otherwise YT thinks that the comment is empty and won't allow to submit
	    document.execCommand('insertText', false, value["studioReply"]);
      }); 
    }
  }); 
}); 

Published:

Keywords: JS, browser
#javascript #javascriptTutorial

You might also be interested in these articles:

Yoga Meditation Through Life - Kvetoslav Minarik

Spirituality in Martial Arts - Can Fighting Lead to Enlightenment?

Compositing Particles/Smoke Around 2D Video Object - Blender

How to Start Learning Japanese by Yourself at Home Tutorial

How to Learn Lucid Dreaming Guide & Tutorial

Comments

Write a new comment:

All the comments are reviewed before publishing! Meaningless posts are automatically refused.

Be the first legendary hero and write a message that will last for ages!