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 8225777
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T15:31:48+00:00 2026-06-07T15:31:48+00:00

Long story short I’m making a greasemonkey script. The pages I work on have

  • 0

Long story short I’m making a greasemonkey script. The pages I work on have this specific table with various values depending on the page.

<table class="billing dead">
    <tbody>
        <tr>
            <th>Index:</th>
            <td>Long alpha numeric value here</td>
        </tr>
        <tr>
            <th>Status:</th>
            <td class="status">This text is red to denote urgency.</td>
        </tr>
    </tbody>
</table><!-- end billing dead -->

What I need to do is change the text “Index:” to something else, whether it be a button or a link depending on the situation. I’m just having a hard time actually locating the item via Javascript.

Looking around I found this: How to Get Element By Class in JavaScript? which provided me with this code:

function replaceContentInContainer(matchClass,content)
{
    var elems = document.getElementsByTagName('*'), i;
    for (i in elems)
    {
        if((" " + elems[i].className + " ").indexOf(" " + matchClass + " ") > -1)
        {
            elems[i].innerHTML = content;
        }
    }
}

That replaces the whole table, however it’s the closest question/answer to my situation; it’s just not quite right. Once I’ve found the table with that method linked above, is there a way to access the elements of that specific table? I’ve tried arbitrarily changing

elems[i].innerHTML = content;

into

elems[i][0].innerHTML = content;

which quickly taught me that elems[i] isn’t a node of nodes. Is there an easy way to do what I’m looking for?

  • 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-07T15:31:50+00:00Added an answer on June 7, 2026 at 3:31 pm

    Is there more than one “billing” table? Is there only one “Index” per and is it always the first row?

    The following, complete script shows how to change the HTML about any/all “Index” rows, including activating the resulting buttons. It uses jQuery, which will save you much time and effort.

    See the base code in action at jsFiddle.

    // ==UserScript==
    // @name     _Buttonize the Index cells
    // @include  http://YOUR_SERVER.COM/YOUR_PATH/*
    // @require  http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js
    // ==/UserScript==
    
    //--- Find all the "Index" headers.
    var indexHdrs   = $("table.billing.dead th:contains(Index)");
    
    //--- Wrap them all in a button, for example.
    indexHdrs.each ( function () {
        $(this).wrapInner ('<button class="myButton" />');
    } );
    
    /*--- Activate the buttons.  In this case they just display matching
        cell contents.
    */
    $("table.billing.dead th button.myButton").click ( function () {
        var jThis           = $(this);  //-- The button that was clicked.
        var matchingCell    = jThis.parent ().next ();
        alert (matchingCell.text () );
    } );
    

    Note: To use this script on Chrome, install the Tampermonkey extension — which you will want to do anyway, both for the extra features, and to surmount Chrome’s pending restrictions on userscript installation.

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

Sidebar

Related Questions

Long story short: I have 2 collections of objects. One contains good values (Let's
Long story short Say I have the following code: // a class like this
Long story short, I have an ASP.NET application I'm trying to debug and at
Long story short, I'm making a custom Swing component that's basically a JTable with
Long story short, I have a long code that uses jQuery. Lots of files,
Long story short: var o="before"; x = function() //this needs to be an anonymous
Long story short, I have a struct (see below) that contains exactly one field:
Long story short, I have a SQL file that I want to import as
Long story short: # this works as expected: logging.error(my_object.__unicode__()) # this doesn't: logging.error(my_object) Same
Long story short, VSS decided I wasn't allowed to have some code changes. I

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.