Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Nov 2010
    Posts
    21
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Parse HTML to create array from specific td tags

    Well after much trial and error I come asking for help. I am trying to write a greasemonkey script that scans a page for all the values between certain <td> tags. When I used firebug it shows what I am looking for as
    <td class="username">THEUSERNAME</td>
    but when I view the source it just shows up as
    <td>THEUSERNAME</td>
    I want to create an array of the 100 <td>'s on the page that pertain to usernames but none of the other <td>'s

    I created a test page that mimicked the code, what I thought origionally, to be so I could test my script with ease. And it worked when there was an actually <td class="username">

    This is what I have so far:

    Code:
    // ==UserScript==
    //
    //Displayable Name of your script 
    // @name           EXAMPLE 
    //
    // brief description
    // @description    EXAMPLE 
    //
    //URI (preferably your own site, so browser can avert naming collisions
    // @namespace      http://something.com
    //
    // Your name, userscript userid link (optional)   
    // @author         ME
    //
    //Version Number
    // @version        1.0
    //
    // Urls process this user script on
    // @include        http://example.com
    // ==/UserScript==
    
    
    var test = document.getElementsByClassName('username');
    
    alert(test.length);
    test[5].style.color="yellow"; //Just to see if it actually worked

  • #2
    New Coder
    Join Date
    Nov 2010
    Posts
    21
    Thanks
    4
    Thanked 0 Times in 0 Posts
    I just tested my userscript under Google Chrome and it worked fine. How can I make a cross browser userscript?


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •