Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8353833
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T09:22:42+00:00 2026-06-09T09:22:42+00:00

So, I have some code that should do four things: remove the .mp4 extension

  • 0

So, I have some code that should do four things:

  • remove the “.mp4” extension from every title
  • change my video category
  • put the same description in all of the videos
  • put the same keywords in all of the videos

Note: All of this would be done on the YouTube upload page. I’m using Greasemonkey in Mozilla Firefox.

I wrote this, but my question is: how do I change the HTML title in the actual HTML page to the new title (which is a Javascript variable)?

This is my code:

function remove_mp4()
{
   var title = document.getElementsByName("title").value;
   var new_title = title.replace(title.match(".mp4"), "");
}
function add_description()
{
   var description = document.getElementsByName("description").value;
   var new_description = "Subscribe."
}
function add_keywords()
{
   var keywords = document.getElementsByName("keywords").value;
   var new_keywords = prompt("Enter keywords.", "");
}
function change_category()
{
   var category = document.getElementsByName("category").value;
   var new_category = "<option value="27">Education</option>"
}
remove_mp4();
add_description();
add_keywords();
change_category();

Note: If you see any mistakes in the JavaScript code, please let me know.

Note 2: If you wonder why I stored the current HTML values in variables, that’s because I think I will have to use them in order to replace HTML values (I may be wrong).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T09:22:45+00:00Added an answer on June 9, 2026 at 9:22 am

    I assume that your question is only about the title changing, and not about the rest; also, I assume you mean changing all elements in the document that have “title” as name attribute, and not the document title.

    In that case, you could indeed use document.getElementsByName("title").

    To handle the name="title" elements, you could do:

    titleElems=document.getElementsByName("title");
    for(i=0;i<titleElems.length;i++){
        titleInner=titleElems[i].innerHTML;
        titleElems[i].innerHTML=titleInner.replace(titleInner.match(".mp4"), "");
    }
    

    For the name="description" element, use this: (assuming there’s only one name="description" element on the page, or you want the first one)

    document.getElementsByName("description")[0].value="Subscribe.";
    

    I wasn’t really sure about the keywords (I haven’t got a YouTube page in front of me right now), so this assumes it’s a text field/area just like the description:

    document.getElementsByName("keywords")[0].value=prompt("Please enter keywords:","");
    

    Again, based on your question which just sets the .value of the category thingy:

    document.getElementsByName("description")[0].value="<option value='27'>Education</option>";
    

    At the last one, though, note that I changed the "27" into '27': you can’t put double quotes inside a double-quoted string assuming they’re handled just like any other character 🙂

    Did this help a little more? 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a factory class that decides which of four available subclasses it should
I'm having a small issue, I have some code that calculates a mean value
i have some code that tries to list images based on their height. the
I have some code that generates image of a pie chart. It's a general
I have some code that prints out databse values into a repeater control on
I am porting some code from C to C++ and I found this code:
I'm planning to code a library that should be usable by a large number
I have the following methods, that all return different types. I have four of
I have some unstructured data that describe setting for each devices. For e.g. for
I understand that whenever I have a function that has more than four arguments

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.