Sign in to follow this  
Followers 0
BinaryBrother

IE Redirection hack

7 posts in this topic

#1 ·  Posted (edited)

I have this script which utilizes an Ajax chat engine, all reliant on the IE UDF... I would prefer for links clicked inside the chat client to open in FireFox, which is, sort of, a complex operation... The code below is very nasty, but I was just testing around with the idea...

For the life of me, I can't pull the Chat-HTML from the page as it is polled, and updated via Java some-how...

The below script will hide any instance of IE, nab the URL it's trying to visit, close IE, and ShellExecute the URL ...

Is there a better way to intercept these calls? Dale made a suggestion which started with re-writing some of the code, which I can't manage to do because of my inability to access the current chat-text. (Because it is not located in the base HTML)

Here is a Demo of this Ajax chat ---> http://chat.ecobytes.net/

Username: ANY* (Literally... Any username)

Password: none

#include <IE.au3>


Dim $aIE[1]
$aIE[0] = 0
$i = 1
Opt("WinTitleMatchMode", 2)
While 1
    ProcessWait("iexplore.exe")
    While Not WinSetState("Internet Explorer","",@SW_HIDE) And ProcessExists("iexplore.exe")
        ;Sleep very little... :D
    WEnd


    While 1
        $oIE = _IEAttach("", "instance", $i)
        If @error = $_IEStatus_NoMatch Then ExitLoop
        ReDim $aIE[$i + 1]
        $aIE[$i] = $oIE
        $aIE[0] = $i
        $i += 1
    WEnd
    If $i > 0 Then
        For $N = 1 To $aIE[0]
            $URL = _IEPropertyGet($aIE[$N], "locationURL")
            ShellExecute($URL)
            _IEQuit($aIE[$N])
            ProcessWaitClose("iexplore.exe")
        Next
        ReDim $aIE[1]
        $aIE[0] = 0
        $i = 1
    EndIf

WEnd
Edited by BinaryBrother

Share this post


Link to post
Share on other sites



Please be more specific... what do you mean by "the CHAT-HTML"? the text being typed into the text area below or the transcript stored in the area at the top?

If it is either of those, I don't understand your trouble... I can access both.

What do you mean by "inability to access the current chat-text. (Because it is not located in the base HTML)"?

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

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Your a lot better than me Dale! :P (I was referring to the chat transcript... :))

I couldn't get it using the normal HTML nabbing method, I'm sure there is something special involved isn't there?:)

Posted Image

Edited by BinaryBrother

Share this post


Link to post
Share on other sites

#include <IE.au3>

$oIE = _IEAttach("AJAX Chat")
$oChatList = _IEGetObjById($oIE, "chatlist") ; <DIV id=chatList>
$oChats = _IETagNameGetCollection($oChatList, "div")
For $oChat in $oChats
    ConsoleWrite(_IEPropertyGet($oChat, "innerText") & @CRLF)
Next

Note that in DebugBar, when viewing dynamic content like AJAX, you may have to right-click in the DOM tree and choose "Rebuild the DOM tree" to be able to see the most recent content there.

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

Share this post


Link to post
Share on other sites

Hah! That little trick with the DebugBar done the trick as far as giving me more data. All heaps of juicy stuff now... :)

Thanks so much Dale! :) A true genius you are.

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Hey Dale, since the chat conversation is going to be dynamic, what do you think would be the most valid way of 're-writing' the links on the fly?

I've found a good way to modify form values on the fly using Javascript. :) And I know how to set events using the IE Udf I believe, now all I have left is a good RegExp method... If you think that's the best?

<input type="text" id="txt" value=""/>
<br/>
<br/>
<a href="#" onclick="{document.getElementById('txt').value = 'http://www.google.com';}">Change form field to http://www.google.com</a>

When the chat messages are submitted, they are going to be in form like this...

<div id="ajaxChat_m_97419" class="rowEven" xmlns="http://www.w3.org/1999/xhtml"><a class="delete" title="Delete this chat message" href="javascript:ajaxChat.deleteMessage(97419);"> </a><span class="dateTime">(23:29:48)</span><span class="user" dir="ltr" onclick="ajaxChat.insertText(this.firstChild.nodeValue);">BinaryBrother</span>: <a href="http://www.google.com" onclick="window.open(this.href); return false;">http://www.google.com</a></div>

So I would assume the only thing that would need to be re-written is this...

<a href="http://www.google.com" onclick="window.open(this.href); return false;">http://www.google.com</a>

Which should simply be rewritten to this...

<a href="#" onclick="{document.getElementById('txt').value = 'http://www.google.com';}">Change form field to http://www.google.com</a>

Right?

Edited by BinaryBrother

Share this post


Link to post
Share on other sites

I'm sorry. I don't understand what you are trying to accomplish.

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

Share this post


Link to post
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
Sign in to follow this  
Followers 0