[Greasemonkey] Getting value between tags 
September 6th, 2008, 07:53 AM
| | Newbie | | Join Date: Sep 2008
Posts: 3
| | [Greasemonkey] Getting value between tags
What I got:
[HTML]<font color="#ffffcc" face="Tahoma, Arial, Helvetica" size="+1">testA</font>
<font color="#ffffcc" face="Tahoma, Arial, Helvetica" size="+1">test1</font>
[/HTML]
What I want:
[HTML]<font color="#ffffcc" face="Tahoma, Arial, Helvetica" size="+1">testA <a href="http://loginpage.php?login=testA">login</a></font>
<font color="#ffffcc" face="Tahoma, Arial, Helvetica" size="+1">test1<a href="http://loginpage.php?login=test1">login</a></font>
[/HTML]
Now I know how to insert the <a> tag but I can't get the "testA", "test1" values. Any help would be greatly appreciated .
Last edited by acoder; September 6th, 2008 at 11:13 AM.
Reason: Added [code] tags
| 
September 6th, 2008, 09:51 AM
|  | Moderator | | Join Date: Aug 2008 Location: Leipzig, Germany Age: 32
Posts: 2,209
| |
first, drop the <font> tags, they're deprecated since you can do styling with css.
if you have say
[HTML]<span>test1</span>[/HTML]
you can use - {span}.firstChild.nodeValue
-
{span}.value
-
{span}.innerHTML
there are several ways to get the desired span object...
regards
| 
September 6th, 2008, 10:54 AM
| | Newbie | | Join Date: Sep 2008
Posts: 3
| | Quote: |
Originally Posted by Dormilich first, drop the <font> tags, they're deprecated since you can do styling with css.
if you have say
[HTML]<span>test1</span>[/HTML]
you can use - {span}.firstChild.nodeValue
-
{span}.value
-
{span}.innerHTML
there are several ways to get the desired span object...
regards | I have no acces to the page, that is why I need grease monkey
| 
September 6th, 2008, 12:47 PM
|  | Moderator | | Join Date: Aug 2008 Location: Leipzig, Germany Age: 32
Posts: 2,209
| | Quote: |
Originally Posted by morbo I have no acces to the page, that is why I need grease monkey | this will result in quite a bit of work. the main problem you have (without access to the page) is to address the right font tags. you probably have to get all font tags, check if they contain a link and then you can read the text.
maybe you can provide a link, so I can have a look at the html (this could make things easier).
regards
| 
September 6th, 2008, 04:28 PM
| | Newbie | | Join Date: Sep 2008
Posts: 3
| |
http://www.hswn.dk/hobbit/servers/servers.html
What I am trying to accomplish is to have an icon next to the server names that connects to a login page and gives the server name as get variable.
ps: the span element is not in my version (runs on secure local network)
| 
September 6th, 2008, 04:56 PM
|  | Moderator | | Join Date: Aug 2008 Location: Leipzig, Germany Age: 32
Posts: 2,209
| |
nasty bit of tree walking there....
ok, first you need the right table - var tbl = document.getElementsByTagName("table")[2]; // 3rd table
then select the table rows - var rows = tbl.childNodes; // tbl.firstChild.childNodes for IE
now get the font tags (loop through the rows) and the text - var text = rows[i].firstChild.getElementsByTagName("font")[0].firstChild.nodeValue;
I didn't test it, but I think it should work this way.
regards
|  | | Thread Tools | Search this Thread | | | | | | | What is Bytes?
We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights.
Get the best answers to your questions from over 220,840 network members.
|