Results 1 to 3 of 3

Thread: GM help?

  1. #1

    Join Date
    Jun 2012
    Gender
    Posts
    1,131
    Thanks
    182
    Thanked 210 Times in 161 Posts


    Downloads
    0
    Uploads
    0
    Mentioned
    121 Post(s)
    Time Online
    19 d 9 h 4 m
    Avg. Time Online
    14 m
    Rep Power
    7

    GM help?



    Could someone explain to me what is happening here, step by step please?
    I'm trying to learn by adapting available code


    The only thing I partially understand is

    Where the character string "Red Apple" is searched for in the page. And an if event is triggered if it is > -1? I don't under stand the > -1 part.
    Last edited by Shawn; 06-09-2012 at 10:00 AM.

  2. #2
    Little Brother


    Zachafer's Avatar
    Join Date
    Dec 2011
    Gender
    Posts
    1,206
    Thanks
    723
    Thanked 1,392 Times in 651 Posts


    Downloads
    81
    Uploads
    17
    Mentioned
    497 Post(s)
    Time Online
    21 d 17 h 32 m
    Avg. Time Online
    16 m
    Rep Power
    14
    Quote Originally Posted by Shawn View Post


    Could someone explain to me what is happening here, step by step please?
    I'm trying to learn by adapting available code


    The only thing I partially understand is

    Where the character string "Red Apple" is searched for in the page. And an if event is triggered if it is > -1? I don't under stand the > -1 part.
    indexOf returns the index of the parameter in the instance string. If the parameter does not exist in the instance string, indexOf returns -1. The parameter in this case is 'Red Apple' and the instance string is document.body.innerHTML. So that if statement is checking if 'Red Apple' is found in document.body.innerHTML

    This is fairly advanced code. This uses XPath (XML Path language) to find a certain element in the document. I believe '//b[. = "What What What Stick"]' finds a bold element (<b> that contains the text "What What What Stick".



    This code looks to see if the previous XPath expression found the element (snapshotlength > 0). If so, it sets the first resultant element to item (for convenience purposes). It then sets a variable (selectedlink) to the item's previousSibling's previousSibling (I can't really explain this without seeing the HTML). It then points the browser to that URL.

    This looks like code for a GM ABer or something like that. Hope I helped.

  3. The Following User Says Thank You to Zachafer For This Useful Post:

    Shawn (06-10-2012)

  4. #3

    Join Date
    Jun 2012
    Gender
    Posts
    1,131
    Thanks
    182
    Thanked 210 Times in 161 Posts


    Downloads
    0
    Uploads
    0
    Mentioned
    121 Post(s)
    Time Online
    19 d 9 h 4 m
    Avg. Time Online
    14 m
    Rep Power
    7
    Yes I understand this now. Yes, it is from a GM ABer that I'm trying to adapt.

Posting Permissions

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