belassal

Hi everyone,

This is my first post. I will be thankful for any ideas. I was wondering if there is a tutorial somewhere, that teaches you how to write IE extension that changes the content of a page.

I have written Firefox extension before that manipulates specific texts within a page, but i don't know what is the procedure for IE in general.

I was wondering, if i could use the same javascript as part of the extension for IE.

Thanks to everyone in advance.

Bilal

ba_lebanon@hotmail.com



Re: Internet Explorer Extension Development Help writing an extension for IE

IECUSTOMIZER

Hi Belassal,

You can try the same javascriptlet with IE6 (not IE7 though as it does not support the javascript: protocol in the Addressbar).

Just copy your FF javascript to the address bar of IE6 and prefix it with javascript:

eg. javascript:alert('hello world');

Method 2. - Place the scriptlet in an Internet Shortcut(IE6 and 7)

Open up Notepad

type in

url=javascript:{your javascript goes here}

IconFile={the url to your favorite icon}

IconIndex=1

Save the file with a .url extension (make sure you have FileType=All selected in the filetype dropdown) in your Favorites or Links folder

Method 3 - Place the scriptlet in a button script (IE6 and 7)

Open notepad and enter something similar to

<script language=javascript defer>

{your javascript goes here}

</script>

Save the file as a .htm or .html extension.

with all methods you have to be aware of the differences between scripting engines used by FF and IE. Ie uses the external object to access the browser and the document objects. (search msdn for external.menuArguments) and of coarse document.all is a no-no for FireFox.

As far as making an installer for your scriptlete I have a utility to build a msi for Button Add-ons, but my site iecustomizer.com is currently off the air due to a hardware failure. So if you would like to publish your script for the general public or want it packaged to an installer, send us a note and I would be happy to do it for you. Regards.






Re: Internet Explorer Extension Development Help writing an extension for IE

belassal

Rob,

Thank you for your generousity. One more thing if you don't mind.

My script is suppose to be manipulating the content of any web page visited. Lets say, i am using the 3rd method (since i didn't understand the second one) you mentioned:

1- How can i test if my script actually work

2-After having the .html file, how this file will interact with web pages and change the contents

Sorry, if the questions are silly, but i am very very new to Javascript.

My entire script is in one function that looks like:

(function() {

javascript...

}) ();

This is the version that works of GreaseMonkey. But the extension version comes with an addEventListener to load the function.

So should it look like this:

<script language=javascript defer>

(function() {

})();

</script>

or i should be making some changes to it.

Again, Thank you very very much, because you're getting me started and this is very important to me.

Cheers.





Re: Internet Explorer Extension Development Help writing an extension for IE

tuma

Hi,

I want to do similar thing from my IE extension. I have created BHO object and subscribed for DocumentComplete event. But I dont know how to inject my java scripts to the current html page for page event handlings.

Please help.

-tuma






Re: Internet Explorer Extension Development Help writing an extension for IE

IECUSTOMIZER

Hi,

I don't think there is an equivalent addEventListener for IE browsers. To hook into an IE Browser and monitor the events you need with a BHO or Toolbar.

I think an existing example that may give you some ideas(good and bad) is the Site Advisor toolbar from McAffee.

Once you have established a hook into the browsers methods and events (implements isetsite) you can insert code into pages using the innerHTML property of the loaded document (do this on the OnNavigateComplete event, but make sure you have a valid html document (test typename of the loaded document) before you try to insert into it)). Be aware also that BHO's and toolbars also are implemented/instanciated when other MSIE browsers (Windows Explorer, Outlook, Avant and Maxthon browsers) are loaded, so filter the application object and only hook into the IExplore.exe application.

Here is a link to an example to insert script. http://g.msn.com/9SE/1 http://msdn.microsoft.com/workshop/author/dhtml/reference/properties/innerhtml.asp&&DI=6066&IG=673ef1aeb7e94a67b9d1150af36db745&POS=1&CM=WPU&CE=1&CS=AWP&SR=1

Lastly .... Do no evil!

Changing the content of web pages without user consent could be seen as a browser hijack






Re: Internet Explorer Extension Development Help writing an extension for IE

tuma

Hi Rob,

Thanks for your reply. I will go through this link.

-tuma






Re: Internet Explorer Extension Development Help writing an extension for IE

tuma

Hi Rob,

The innerHTML property only shows the body of the HTML page. I want to put some javascripts in the HTML head, through which I want to handle events as well as manipulate the body.

I am able to call the javascript through IHTMLWindow2

IHTMLWindow2 *spWindow;
if ( SUCCEEDED( spDoc->get_parentWindow( &spWindow))) {
if (spWindow != NULL) {
VARIANT pvarRet;
spWindow->execScript(L"alert(\"Tuma\");", L"javascript", &pvarRet);
spWindow->Release();
}
}

But I don't know how to add the script into HTML head. Please help me if you know anything.

- tuma