Help | Site Map
Connecting Tech Pros Worldwide
Reply
 
LinkBack Thread Tools
  #1  
Old September 6th, 2008, 08:53 AM
Newbie
 
Join Date: Sep 2008
Posts: 3
Default [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 12:13 PM. Reason: Added [code] tags
Reply
  #2  
Old September 6th, 2008, 10:51 AM
Dormilich's Avatar
Expert
 
Join Date: Aug 2008
Location: Leipzig, Germany
Age: 31
Posts: 636
Default

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
Expand|Select|Wrap|Line Numbers
  1. {span}.firstChild.nodeValue
  2. {span}.value
  3. {span}.innerHTML
there are several ways to get the desired span object...

regards
Reply
  #3  
Old September 6th, 2008, 11:54 AM
Newbie
 
Join Date: Sep 2008
Posts: 3
Default

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
Expand|Select|Wrap|Line Numbers
  1. {span}.firstChild.nodeValue
  2. {span}.value
  3. {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
Reply
  #4  
Old September 6th, 2008, 01:47 PM
Dormilich's Avatar
Expert
 
Join Date: Aug 2008
Location: Leipzig, Germany
Age: 31
Posts: 636
Default

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
Reply
  #5  
Old September 6th, 2008, 05:28 PM
Newbie
 
Join Date: Sep 2008
Posts: 3
Default

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)
Reply
  #6  
Old September 6th, 2008, 05:56 PM
Dormilich's Avatar
Expert
 
Join Date: Aug 2008
Location: Leipzig, Germany
Age: 31
Posts: 636
Default

nasty bit of tree walking there....

ok, first you need the right table
Expand|Select|Wrap|Line Numbers
  1. var tbl = document.getElementsByTagName("table")[2]; // 3rd table
then select the table rows
Expand|Select|Wrap|Line Numbers
  1. var rows = tbl.childNodes; // tbl.firstChild.childNodes for IE
now get the font tags (loop through the rows) and the text
Expand|Select|Wrap|Line Numbers
  1. var text = rows[i].firstChild.getElementsByTagName("font")[0].firstChild.nodeValue;
I didn't test it, but I think it should work this way.

regards
Reply
Reply

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

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 network members.
Post your question now . . .
It's fast and it's free

Popular Articles