Jump to content

Change text or innerHTML attribute of a link


Recommended Posts

Hi i need to change the text of the link

<a href="index.php?page=messages&dsp=1&session=6343865f4df2">Tem 1 nova(s) mensagem()</a>

to "Você tem 1 nova mensagem."

here is part of the code:

i search the innerText of all links untill i find the one with the message text and then try to modify it. so if there are no new messages it will find nothing and continue.

Func MessageCheck()
;DETECT with REGEXP the message.
    $oLinks = _IELinkGetCollection($OGameSiteID)
    For $oLink In $oLinks
        ConsoleWrite("Searching Tables..." & @CR)
; IF DETECTS AND CHANGES MESSAGE, IF NOT DETECTED DO NOTHING.
        If StringRegExp($oLink.innerText, "Tem [0-9]{1,4} nova\(s\) mensagem\([s]{0,1}\)") = 1 Then
            $NewMessageTable = $oLink;Is this the table we want?
            $array = StringRegExp($oLink.innerText, "Tem [0-9]{1,4} nova\(s\) mensagem\([s]{0,1}\)", 1)
            $array2 = StringRegExp($array[0], "[0-9]{1,4}", 1)
;MESSAGE DETECTED.
            If $array2[0] = 1 Then; YOU HAVE 1 MESSAGE
;~              _IEDocInsertText($oLink, "Você tem " & $array2[0] & " nova mensagem.", "afterbegin")
                MsgBox(1, "", "Você tem " & $array2[0] & " nova mensagem.")
            Else; YOU HAVE MORE THAN 1 MESSAGE ("Você tem # novas mensagens."
;~              _IEDocInsertText($oLink,  "Você tem " & $array2[0] & " novas mensagens.", "afterbegin")
                MsgBox(1, "", "Você tem " & $array2[0] & " novas mensagens.")
            EndIf
        EndIf
    Next

i can insert text but its somewhat useless because the link text will stay like this: "Você tem 1 nova mensagem.Tem 1 nova(s) mensagem()"

is there any way to overwrite the text?

btw the site is http://ogame.com.br its verry bad translated and im trying to make a script to translate... i dont know java so i cant use something like that.

Thanks, Caio.

Link to comment
Share on other sites

What you want is _IEPropertySet($oLink, "innertext", $new-string)

Dale

Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y

Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Link to comment
Share on other sites

won't it work by navigating to java script:yourcode; ??

Some Projects:[list][*]ZIP UDF using no external files[*]iPod Music Transfer [*]iTunes UDF - fully integrate iTunes with au3[*]iTunes info (taskbar player hover)[*]Instant Run - run scripts without saving them before :)[*]Get Tube - YouTube Downloader[*]Lyric Finder 2 - Find Lyrics to any of your song[*]DeskBox - A Desktop Extension Tool[/list]indifference will ruin the world, but in the end... WHO CARES :P---------------http://torels.altervista.org

Link to comment
Share on other sites

What you want is _IEPropertySet($oLink, "innertext", $new-string)

Dale

thx Dale i had a completely diferent idea of what _IEPropertySed did... that did the trick =D

won't it work by navigating to java script:yourcode; ??

im not sure i dont realy use java script but thx anyway
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...