Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
16
rated 0 times [  21] [ 5]  / answers: 1 / hits: 20974  / 13 Years ago, wed, july 13, 2011, 12:00:00

I've been searching for a way to change HTML on a website my main problem being it does not have an id tag that I can use to pull it out and change it, using Greasemonkey JavaScript.



sorry I left that part out. I am logging the current winner on a server and trying to use JavaScript via Greasemonkey to show the last winning time on the game site.



Below is part of the source, in the example below I'd want to add the current time beside Raiton between the <b> tags.



<html>
<head>

Most Recent Winner: <b>Raiton</b><br>
Entry Cost: <font color=22AA22><b>11000</b></font> (resets at Dayroll)<br>

Entry costs go up in <font color=2222AA><b>11</b></font> entries to <font color=22AA22><b>22000</b></font> Ryo<br>
Number of plays today: <font color=AA2222><b>0</b></font><br>


</body>
</html>

More From » html

 Answers
122

So far, I haven't seen any answers that just answer the question. Try this:



var elts = document.getElementsByTagName('b'),
i = elts.length,
elt,
text;

while (i--)
{
elt = elts[i];
text = elt.textContent;
if (text === 'Raiton')
{
elt.textContent = text + ' ' + new Date();
break;
}
}


Demo: http://jsfiddle.net/mattball/Nvwmd/


[#91195] Tuesday, July 12, 2011, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
sienad

Total Points: 208
Total Questions: 100
Total Answers: 77

Location: Taiwan
Member since Mon, Sep 6, 2021
3 Years ago
;