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 6 of 6
  1. #1
    New Coder
    Join Date
    Jul 2011
    Posts
    44
    Thanks
    5
    Thanked 0 Times in 0 Posts

    getting regxp data from the GET method in jquery

    hey guys im using greasmonkey with jquery and i want to find the remaining time on a page then display it in my infomation bar in game but what im having trouble with is the regxp trying to get the text then get the 1,2 or 3 didgit number between the text here is my current function which gets the numbers on the page but returns a HUGE number because its returning every number

    Code:
    function getFallen()
    {
    	hellGate = "";
    	$.get('http://kong.playmage.com/dream/fallen?board', function(data) 
    	{
    		temp = data;
    		if(temp.search("Time until revival:") != -1 || temp.search("minutes") != -1)
    		{
    			numb = temp.match(/\d/g);//format of text needed "Time until Revial (number 1,2 or 3 didgits long) minutes" 
    			numb = numb.join("");//with the current match i have it returns huge number
    			//debugScript("Found the number :" + numb, "debug");
    			//el2 = $inc1("test"); function outside this function just for finding classes/ids
    			//if (el2) el2.textContent = numb; // for setting the content of the id class above not needed in this function but just for debug purposes
    		}
    	});
    }

    now oviously this get function WILL NOT work for you because you will need to log in so if you just store the following html into the temp var then it will function the same

    Code:
     
    
    <input type="hidden" id="cfix" value=""/>
    
    <center><span
    	style="padding-top: 4px; display: inline-block; font-size: 16px; color: #00ddbb; font-family: lucida grande, verdana, arial;">Fallen
    Defenders</span> <br />
    <table style="width: 100%;" border="0" cellpadding="0" cellspacing="0">
    <tbody>
    <tr>
    <td>
    <div style="text-align: center;">Last Fallen</div>
    <div class="trainlbox" style="height: 346px; overflow-x: hidden; margin: 5px 4px 5px 12px; display: inline-block;">
    <table style="width: 332px;" border="0" cellpadding="0" cellspacing="0">
    	<tbody>
    
    		<tr style="vertical-align: middle; background-color: rgb(0, 36, 36);">
    			<td class="healheadertd" style="width: 50px;">&nbsp; Rank</td>
    			<td class="healheadertd" style="width: 120px;">Player</td>
    			<td class="healheadertd" style="text-align: center;">Damage &nbsp; </td>
    		</tr>
    		
    			<tr style="vertical-align: middle;">
    
    				<td> &nbsp; &nbsp; 1</td>
    				<td>
    					
    					
    					<a href="#" onclick="showDiv('/dream/profile?id=nf110743'); return false;">Authority[aik]</a>
    					
    				</td>
    				
    				<td style="text-align: center;">1,479,141,013 &nbsp; </td>
    
    			</tr>
    		
    			<tr style="vertical-align: middle;">
    				<td> &nbsp; &nbsp; 2</td>
    				<td>
    					
    					
    					<a href="#" onclick="showDiv('/dream/profile?id=nf483977'); return false;">Ultima[HOT]</a>
    					
    				</td>
    
    				
    				<td style="text-align: center;">603,063,918 &nbsp; </td>
    			</tr>
    		
    			<tr style="vertical-align: middle;">
    				<td> &nbsp; &nbsp; 3</td>
    				<td>
    					
    					
    					<a href="#" onclick="showDiv('/dream/profile?id=nf402815'); return false;">wozza[AGA]</a>
    
    					
    				</td>
    				
    				<td style="text-align: center;">287,130,506 &nbsp; </td>
    			</tr>
    		
    			<tr style="vertical-align: middle;">
    				<td> &nbsp; &nbsp; 4</td>
    				<td>
    
    					
    					
    					<a href="#" onclick="showDiv('/dream/profile?id=nf404165'); return false;">larry1977[AGA]</a>
    					
    				</td>
    				
    				<td style="text-align: center;">277,033,578 &nbsp; </td>
    			</tr>
    		
    			<tr style="vertical-align: middle;">
    				<td> &nbsp; &nbsp; 5</td>
    
    				<td>
    					
    					
    					<a href="#" onclick="showDiv('/dream/profile?id=nf455510'); return false;">Ehanida[ToF]</a>
    					
    				</td>
    				
    				<td style="text-align: center;">276,799,331 &nbsp; </td>
    			</tr>
    		
    			<tr style="vertical-align: middle;">
    				<td> &nbsp; &nbsp; 6</td>
    
    				<td>
    					
    					
    					<a href="#" onclick="showDiv('/dream/profile?id=nf173542'); return false;">dudemanly[DNA]</a>
    					
    				</td>
    				
    				<td style="text-align: center;">191,656,885 &nbsp; </td>
    			</tr>
    		
    			<tr style="vertical-align: middle;">
    				<td> &nbsp; &nbsp; 7</td>
    
    				<td>
    					
    					
    					<a href="#" onclick="showDiv('/dream/profile?id=nf191162'); return false;">krashkill0069[G4B]</a>
    					
    				</td>
    				
    				<td style="text-align: center;">47,831,724 &nbsp; </td>
    			</tr>
    		
    			<tr style="vertical-align: middle;">
    				<td> &nbsp; &nbsp; 8</td>
    
    				<td>
    					
    					
    					<a href="#" onclick="showDiv('/dream/profile?id=nf486185'); return false;">ben_avatar[HOT]</a>
    					
    				</td>
    				
    				<td style="text-align: center;">33,264,175 &nbsp; </td>
    			</tr>
    		
    			<tr style="vertical-align: middle;">
    				<td> &nbsp; &nbsp; 9</td>
    
    				<td>
    					
    					
    					<a href="#" onclick="showDiv('/dream/profile?id=nf312560'); return false;">Niv[PWN]</a>
    					
    				</td>
    				
    				<td style="text-align: center;">31,520,972 &nbsp; </td>
    			</tr>
    		
    			<tr style="vertical-align: middle;">
    				<td> &nbsp; &nbsp; 10</td>
    
    				<td>
    					
    					
    					<a href="#" onclick="showDiv('/dream/profile?id=nf528295'); return false;">leandroaod[DJE]</a>
    					
    				</td>
    				
    				<td style="text-align: center;">26,510,757 &nbsp; </td>
    			</tr>
    		
    			<tr style="vertical-align: middle;">
    				<td> &nbsp; &nbsp; 11</td>
    
    				<td>
    					
    					
    					<a href="#" onclick="showDiv('/dream/profile?id=nf187015'); return false;">Graveyard[PWN]</a>
    					
    				</td>
    				
    				<td style="text-align: center;">10,379,144 &nbsp; </td>
    			</tr>
    		
    			<tr style="vertical-align: middle;">
    				<td> &nbsp; &nbsp; 12</td>
    
    				<td>
    					
    					
    					<a href="#" onclick="showDiv('/dream/profile?id=nf25358'); return false;">Maynard[PWN]</a>
    					
    				</td>
    				
    				<td style="text-align: center;">7,116,618 &nbsp; </td>
    			</tr>
    		
    			<tr style="vertical-align: middle;">
    				<td> &nbsp; &nbsp; 13</td>
    
    				<td>
    					
    					
    					<a href="#" onclick="showDiv('/dream/profile?id=nf229143'); return false;">Barry McCociner[XXX]</a>
    					
    				</td>
    				
    				<td style="text-align: center;">6,123,612 &nbsp; </td>
    			</tr>
    		
    			<tr style="vertical-align: middle;">
    				<td> &nbsp; &nbsp; 14</td>
    
    				<td>
    					
    					
    					<a href="#" onclick="showDiv('/dream/profile?id=nf79006'); return false;">DumMetlHed[PWN]</a>
    					
    				</td>
    				
    				<td style="text-align: center;">4,736,449 &nbsp; </td>
    			</tr>
    		
    	</tbody>
    </table>
    </div>
    
    </td>
    
    <td>
    <div style="text-align: center;">Current Fallen
    
    </div>
    <div class="trainlbox" style="height: 346px; overflow-x: hidden; margin: 5px 8px; display: inline-block;">
    <table style="width: 332px;" border="0" cellpadding="0" cellspacing="0">
    	<tbody>
    		<tr style="vertical-align: middle; background-color: rgb(0, 36, 36);">
    			<td class="healheadertd" style="width: 50px;">&nbsp; Rank</td>
    			<td class="healheadertd" style="width: 120px;">Player</td>
    
    			<td class="healheadertd" style="text-align: center;">Damage &nbsp; </td>
    		</tr>
    		
    		
    			<tr><td colspan="3" style="text-align: center;">
    			<br/>&nbsp;<br/>&nbsp;<br/>&nbsp;<br/>
    			Time until revival: 147 minutes
    			</td></tr>
    		
    	</tbody>
    </table>
    </div>
    
    </td>
    </tr></tbody>
    </table>
    
    <div style="padding-top: 10px;"><span class="btn100" onclick="closeFloat();">Close</span></div>
    </center>
    would it be possible to only strip the following text Time until Revial (number 1,2 or 3 didgits long) minutes and then once it has found that match remove anything that isnt a number

  • #2
    Senior Coder
    Join Date
    Dec 2010
    Posts
    2,396
    Thanks
    12
    Thanked 569 Times in 562 Posts
    Code:
    var TimeUntilRevival = data.match(/Time until revival:\s(\d+)\s/)[1];
    should do the trick

  • #3
    New Coder
    Join Date
    Jul 2011
    Posts
    44
    Thanks
    5
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by devnull69 View Post
    Code:
    var TimeUntilRevival = data.match(/Time until revival:\s(\d+)\s/)[1];
    should do the trick
    just so i understand this and dont have to ask again how does that match actualy work?

    also i tried a else statment for the oposite and for some reason is breaks the script and i cant understand how to fix it

    TimeUntilRevival = temp.match(/Current Fallen (HP:\s\(\s(\d+)\s/)[1];
    Last edited by jordandap; 08-24-2011 at 09:08 PM.

  • #4
    Senior Coder
    Join Date
    Dec 2010
    Posts
    2,396
    Thanks
    12
    Thanked 569 Times in 562 Posts
    It looks for the text "Time until revival:" followed by a white space character, followed by "at least one digit" followed by a white space character. If found, it will extract the "first group" from the matched string (which is the part of the string in brackets, so the digits part).

  • #5
    New Coder
    Join Date
    Jul 2011
    Posts
    44
    Thanks
    5
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by devnull69 View Post
    It looks for the text "Time until revival:" followed by a white space character, followed by "at least one digit" followed by a white space character. If found, it will extract the "first group" from the matched string (which is the part of the string in brackets, so the digits part).

    aah ok so thats why when im searching for the string im currently looking for that has a ( in it is messesing up the search so to escape it i would put this

    temp.match(/Current Fallen \(HP:\s(\d+)\s/)[1]; ?
    and would it matter if the numbers contained , every 3 numbers?
    Last edited by jordandap; 08-24-2011 at 09:32 PM.

  • #6
    Senior Coder
    Join Date
    Dec 2010
    Posts
    2,396
    Thanks
    12
    Thanked 569 Times in 562 Posts
    and would it matter if the numbers contained , every 3 numbers?
    Yes of course, because \d+ would only match numbers as a sequence of digits without any different character.

    What do you want to do with those commas? Do you want to include them or exclude them?


  •  

    Posting Permissions

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