Ability to NAME injected scripts??

Add-in Express™ Support Service
That's what is more important than anything else

Ability to NAME injected scripts??
Locating injected code for debugging purposes is very difficult 
Robert Apostolico


Guest


I'm not sure if i'm doing something wrong or not,
but when I inject js code into a page, it is very difficult to locate.

Additionally, the names that DO appear all say "unknown script code".

User added an image

Is there a better way to get the code injected so it somehow can be named??

Thank you!
Posted 03 Jun, 2014 07:17:15 Top
Sergey Grischenko


Add-in Express team


Posts: 7233
Joined: 2004-07-05
Hi Robert,

I would advise you to use the 'OnDataAvailable' event to inject your javascript code. In this case it will be available in the code of the main document and you will see it in 'View->Source' and 'F12 Dev Tools'. To activate this event you need to set HandleHTTPNegotiations property of the iemodule to true. Please have a look at the http://www.add-in-express.com/support/ie-vbnet-csharp.php example.
Posted 03 Jun, 2014 12:00:15 Top
Robert Apostolico


Guest


Sergey,

Please refer to this post:
http://www.add-in-express.com/forum/read.php?FID=10&TID=12378

If I use OnDataAvailable as you just suggested, I then run into the problem mentioned in the above post:
When a website/page has frames or iframes, OnDataAvailable is fired MANY times, and we currently do not have access to know if the OnDataAvailable is firing for the top-level document, which is what we need to know.

Do you have any other suggestions?

PLEASE ADVISE.
Posted 03 Jun, 2014 13:18:22 Top
Sergey Grischenko


Add-in Express team


Posts: 7233
Joined: 2004-07-05
Hi Robert,

You can use 'e.Url' to learn what exactly html source is downloaded.


        string rootDocUrl = String.Empty;

        private void IEModule_BeforeNavigate2(ADXIEBeforeNavigate2EventArgs e)
        {
            if (e.PDisp == IEObj)
            {
                rootDocUrl = (string)e.Url;
            }
        }

        private void IEModule_OnDataAvailable(object sender, ADXIEDataAvailableEventArgs e)
        {
            if (e.DataState == ADXIEDataAvailableEventArgs.ADXIEReportDataState.DataReadyForDownload)
            {
                if (e.Url == rootDocUrl)
                    e.PreviewData = true;
            }
            else
            {
                if (e.Data != null && e.Data.Length > 0)
                {
                    Encoding encoding = GetEncoding(e.Options, e.CodePage);
                    string htmlSource = encoding.GetString(e.Data.GetBuffer());
                    if (ModifyHTMLCode(ref htmlSource))
                    {
                        e.Data.SetLength(0);
                        byte[] bytes = encoding.GetBytes(htmlSource);
                        e.Data.Write(bytes, 0, bytes.Length);
                        e.UpdateCacheFile(false);
                    }
                }
            }

Posted 04 Jun, 2014 04:33:34 Top
Robert Apostolico


Guest


Sergey and Andrei,

I'm pretty sure I will be purchasing a licensed version of the ADXIE soon;
still have a few days left on trial (v9.0.6121).

I'd like to make sure that when I get that version, the problems mentioned here:
http://www.add-in-express.com/forum/read.php?FID=10&TID=12372

...has been resolved and will be in the download available with my purchase.

Because I believe, if they have not been officially released, that if I try to implement the above solution, I'll start getting random exception errors. When I first tried playing around with OnDataAvailable a few weeks ago, I was getting unexplained crashes, which I thought was just "IE". But after switching off HTTP negotiations and using the "DocumentComplete2" event, the crashes went away.

Please advise.
And thank you again for all your help.
Posted 04 Jun, 2014 09:06:33 Top
Andrei Smolin


Add-in Express team


Posts: 18829
Joined: 2006-05-11
Robert,

We are very close to publishing the new build; it includes the fix. I'll send you a note when the build is published.


Andrei Smolin
Add-in Express Team Leader
Posted 05 Jun, 2014 09:43:09 Top
Andrei Smolin


Add-in Express team


Posts: 18829
Joined: 2006-05-11
Hello Robert,

The new build is published at http://www.add-in-express.com/downloads/adxnet-ie.php.


Andrei Smolin
Add-in Express Team Leader
Posted 09 Jun, 2014 01:01:41 Top
Robert Apostolico


Guest


Thank you. Downloading it now.
Posted 09 Jun, 2014 13:15:22 Top