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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T04:13:12+00:00 2026-05-15T04:13:12+00:00

I am writing a greasemonkey script that is parsing a page with the following

  • 0

I am writing a greasemonkey script that is parsing a page with the following general structure:

<table>
<tr><td><center>
<b><a href="show.php?who=IDNumber">(Account Name)</a></b>
 (#IDNumber)
<br> (Rank)
<br> (Title)
<p>
<b>Statistics:</b>
<br>
<table>
<tr><td>blah blah etc.
</td></tr></table></center></table>

I’m specifically trying to grab the (Title) part out of that. As you can see, however, it’s set off only by a <BR> tag, has no ID of its own, is just part of the text of a <CENTER> tag, and that tag has a whole raft of other text associated with it.

Right now what I’m doing to get that is taking the innerHTML of the Center tag and using a regex on it to match for /<br>([A-Za-z ]*)<p><b>Statistics/. That is working okay for me, but it feels like there’s gotta be a better way to pick that particular text out of there.

… So, is there a better way? Or should I complain to the site programmer that he needs to make that text more accessible? 🙂

  • 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-05-15T04:13:13+00:00Added an answer on May 15, 2026 at 4:13 am

    EDIT: updated to remove whitespace

    var title = $('table center').contents().filter(function() {
             if( this.nodeType == 3 && $.trim(this.data) != "") { //get only text nodes and filter out whitespace elements
               return true;
            }
          }).get(2); // get the 3rd text node 
    
    
        alert( title.data ); // alerts "(Title)
        title.data = "How to use jQuery"; // (Title) changes
    

    How it works:

    The function is run through all of the nodes in the provided node, in this case that’s the center tag. Text is nodeType 3, so you’ll get an array of those. Your example has the closing center tag misplaced, so that might give you errors but I think you get the idea. (i think you’re missing a at the end of that before )

    You could always:

      $('table center').contents().filter(function() {
           if( this.nodeType == 3 && $.trim(this.data) != "") { //get only text nodes and filter out whitespace elements
               return true;
            }
          }).wrap('<p></p>') // make those text nodes paragraphs
          .end().filter('br')
            .remove(); // remove the brs
    

    see the jquery docs on .contents()

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

Sidebar

Related Questions

Background : I'm currently writing a greasemonkey script that embeds/modifies a specific page's html.
I am writing a simple GreaseMonkey script that has a jQuery plugin called hoverIntent
I am writing a fairly basic GreaseMonkey script that locates text in a specific
I'm currently writing a Greasemonkey script for a page, so I can't modify the
I'm writing a greasemonkey script that creates an auto-complete search type box which makes
I'm writing a Greasemonkey script that has a fair few user settings (just using
I'm writing a greasemonkey script to make it so that when a user clicks
I am writing a greasemonkey script. The site is using jquery, i need a
I'm writing a simple Greasemonkey script to strip out all the images, headings and
Writing a JSP page, what exactly does the <c:out> do? I've noticed that the

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.