2007/06/28

Tutorial : How to make a plugin for IE7Pro

Introduction


To make a JavaScript plug-in for IE7Pro, you must:
  • Know a little JavaScript of another language programming (JavaScript is easy!)
  • Understand the Document Object Model of IE (and others browsers)
  • Can using an notepad (such Notepad++ or Notepad.exe)

This tutorial is very easy but demonstrates only the basis features of the plug-ins

Naturally, you can learn more information about the plug-in on the IE7Pro Web Site.

Regards,

FremyCompany

The common architecture

The root directory


To start a plug-in, I recommended you to create a directory in the /plugins.

The name of this directory should be the same that the name you'll give to your plug-in, but it's not very important.

The PLUGIN.JS file


In this directory, put a plugin.js file.

The content of all plug-ins should begin with this:
// ==UserScript==
// @name PluginName (by Author)
// @namespace http://iescripts.org/
// @description MoreInfo
// @statussize Size of the plugin (ie: 16)
// ==/UserScript==
(function() {
// Localize the URL's path
function fpath(url) { return "ie7pro://pluginpath/"+url; }
// Content all the PLUGIN API
var plugin = PRO_plugin(@name);
// Used to know which icon is currently used
var getIcon = function() {
return "ie7pro://pluginpath/bg.png";
}
// Used to set the icon of the plugin
function setIcon(url) {
plugin.setStatusIcon(url);
getIcon=function() { return url; };
}
plugin.onpagechange=function (sessID, url, state) {
if (state==1) {
// A new page is opened
}
if (state==2) {
// A new page is loaded
}
}
})()

The utility of all the functions

  • fpath (url)

Transform a relative URL to a long URL. IE7Pro do that for you.

IE7PRO://pluginpath/ is replaced by the local path of the plug-in's root directory.
  • plugin

See the reference of the PLUGIN API on http://www.iescripts.org/help/pro_plugin.html

In addition to the PLUGIN API, some other PRO_ functions are accessible in the code
  • get/setIcon([newUrl])

Get or set the icon of the Plug-in.

The recommended size is 16 by 16 pixels.
  • onpagechange(sessID, url, state)

This function is call each time a new page is opened and loaded.

You can't interact with the page when the status is set to "opened".

sessID: sessID is very important, that's the identifier of the current tab.

When you want to do something on a tab, you must have a reference to this session's ID.

url: The URL of the page currently opened (can be found without this parameter)

state: The status of the actual page (1: opened; 2: loaded)

In the cycles of live of a page, the onpagecreate event is called two times. Firstly with state = 1 and secondly with state = 2.
Sample of use: Print the URL of the file in the plug-in area
[...]
plugin.onpagechange=function (sessID, url, state) {
if (state==1) {
plugin.setStatusText(url, sessID)
}
}
[...]

How to create a Button Plug-in

Catch the onclick event


The most of the time, you'll make a clickable plug-in.

To catch when the user click on the plug-in, there's the onclick event
plugin.onclick = function(sessID, currentUrl) {
// The user click on the plug-in
}
Sample of use: Clear the plug-in's area
plugin.onclick = function(sessID, currentUrl) {
plugin.setStatusText("", sessID)
}

Displaying an image instead of the text


Display a text in the plug-in area is very useful but the most of the time, it's better to display an icon (such the "e"-icon of IE7Pro)

To do this, you must indicate an icon in the header of the file and store this icon in the root directory
// @defaulticon    ie7pro://pluginpath/bg.png

If you want a highlight of your icon when the mouse comes in the plug-in area, you can use this simple code:
 plugin.onmouseenter = function() {
setIcon(fpath("bg_over.png"))
}
plugin.onmouseleave = function() {
setIcon(fpath("bg.png"))
}

How to create a context-menu for the plug-in?


To add an entry to the context-menu of the plug-in, you can do this:
function func(sessID, url) {
// The use clicked on "DisplayText"
}
plugin.registerContextMenu("DisplayText", func)

If you want to add a separator, you can use this code:
plugin.registerContextMenu("separator")

How to save / load options


Theses two functions are used to store settings of your application, such language…
// Get the value of "optionName"
var option = PRO_getValue(optionName, valueIfOptionIsNotSetted)
// Set the value of "optionName"
PRO_setValue(optionName, option)

Interact with the page

Getting the URL of the page


The URL can be obtained with the url parameter.

But if you want, you can find the URL of the current document without it.
// Get the URL as text-format
function getUrl(sessID) {
return plugin.getCurrentDocument(sessID).location.href;
}

You can get the URL as URILocation (see MSDN: document.location), too :
// Get the URL as URILocation
function getUri(sessID) {
return plugin.getCurrentDocument(sessID).location;
}

Executing JavaScript into the web page


They are two ways to execute JavaScript on the current page.

With PRO_openInTab


If you have only a short JavaScript to execute (one line), you can simply use the PRO_openInTab, this is easy and you don't pass any parameter to the function
function injectJS(js) {
PRO_openInTab("javascript:" + js, 0)
}

How does this function work? This is simple, Internet Explorer executes JavaScript if the location of a page is set to "javascript: …". Here we are opening a javascript: URL in the current tab (parameter 0). Because it's an URL, it can only execute one line of JavaScript.

With window.execScript


Internet Explorer implements a simple function for evaluating scripts in a window.
function evalJS(js, sessID) {
var document = plugin.getCurrentDocument(sessID);
var window = document.parentWindow;
window.execScript(js);
}

You can also specify the language and execute any VBScript:
function evalVB(vb,  sessID) {
var document = plugin.getCurrentDocument(sessID);
var window = document.parentWindow;
window.execScript(vb,"vbscript");
}

You can now execute more than one line of code (\n = new line):
var doSomething=(
"if (document.getElementById('data')) {\n"+
" document.getElementById('data').value='Plugin Actived !'; \n"+
"}"
);
evalJS(doSomething, sessID);

Using DOM


Here, we'll do the same thing that the preview code, but directly in the plug-in:

The first thing you must do before is getting the document and the window objects

To do this, you need the id of the current session.
function setData(sessID) {
var document = plugin.getCurrentDocument(sessID);
var window = document.parentWindow;
// ...
}

Next to this, you can do as you were in a JavaScript file:
function setData(sessID) {
var document = plugin.getCurrentDocument(sessID);
var window = document.parentWindow;
if (document.getElementById('data')) {
document.getElementById('data').value='Plugin Actived !';
}
}

Using ActiveXObject


Currently, it's not possible to create an instance of an ActiveXObject.

The follow code causes an error:
plugin.onclick = function(sessID, currentUrl) {
try {
var document = plugin.getCurrentDocument(sessID);
var window = document.parentWindow;
var activeX = window.ActiveXObject("Msxml2.DOMDocument");
PRO_openInTab("javascript:alert('"+activeX+"')", 0)
} catch (ex) {
PRO_openInTab("javascript:alert('"+ex.message+"')", 0)
}
}

Using popup


Use the plugin.popupWindow function and plugin.onpopupclose event to use popup
Some tips:
  1. Encode your files as ANSI or UNICODE
  2. Start all your files with <!-- saved from url=(0014)about:internet -->
  3. Impose a font for your dialogs by CSS

* { font-family: Tahoma; font-size: 10pt; }
  1. Try to let some with space at bottom of your dialogs for large-font UI
  2. Return a value to onpopupcolose with window.returnValue

Some useful functions


These functions need evalJS and evalVB functions.

Alert (Message Box)

function alert(txt, sessID) {
var document = plugin.getCurrentDocument(sessID);
var window = document.parentWindow;
return window.alert(txt);
}

Confirm (True – False)

function confirm(txt, sessID) {
var document = plugin.getCurrentDocument(sessID);
var window = document.parentWindow;
return window.confirm(txt);
}

Prompt (String)

function propmt(txt, default, sessID) {
var document = plugin.getCurrentDocument(sessID);
var window = document.parentWindow;
return window.prompt(txt, default);
}

GetSelection (Text-/ControlRange)

function getSelection(sessID) {
try {
var document = plugin.getCurrentDocument(sessID);
return document.selection.createRange();
} catch (ex) { return null; }
}

Go (Navigate in the history)

// 0 : Refresh; 1 : Next; -1 : Preview
function go(index, sessID) {
var document = plugin.getCurrentDocument(sessID);
var window = document.parentWindow;
window.history.go(index);
}

$ (GetElementById)

function $(ID, sessID) {
var document = plugin.getCurrentDocument(sessID);
return document.getElementById(ID);
}

Learn more

Thanks to Author: FremyCompany

39 comments:

Lasantha said...

Thank you providing such a good details. Keep it up. wish you good luck..

hjkl said...

This momentousdecree wow gold came as a great beacon gold in wow light of hope buy wow gold to millions of negroslaves wow gold kaufen who had been seared in the flames of withering injustice.maplestory mesos it came as a joyous daybreak to end the long night ofcaptivity.but one hundred years later,maplestory money we must face the tragic fact thatthe negro is still not free.maple money one hundred years later,sell wow gold the lifeof the negro is still sadly crippled by the manacles ofsegregation and the chains of discrimination. one hundred yearslater,maple story money the negro lives on a lonely island of poverty in themidst of a vast ocean of material prosperity.wow powerleveling one hundred yearslater,maple story power leveling the negro is still languishing in the corners of americansociety and finds himself an exile in his own land. so we havecome here today to dramatize wow powerleveln an appalling condition.in a ms mesos sense we have come to our nation''s capital to cash a check.when the architects of our republic wow powerleveln wrote the magnificent wordsof the constitution and the declaration of independence, theywere signing a promissory note maplestory power leveling to which every american was tofall heir.

eelziere said...

Thanks for all this information!

Once you have grayed out a context menu option, using

plugin.setContextMenuState("My Menu Option", "grayed");

is there any way to enable it back (un-gray it)?

Thanks is advance for your help,
EE.

Adi said...

Oes Tsetnoc one of the ways in which we can learn seo besides Mengembalikan Jati Diri Bangsa. By participating in the Oes Tsetnoc or Mengembalikan Jati Diri Bangsa we can improve our seo skills. To find more information about Oest Tsetnoc please visit my Oes Tsetnoc pages. And to find more information about Mengembalikan Jati Diri Bangsa please visit my Mengembalikan Jati Diri Bangsa pages. Thank you So much.
Oes Tsetnoc | Semangat Mengembalikan Jati Diri Bangsa

Tez said...

I am able to use onkeyup/down events in IEPro plugin but unable to get the keyCode. How do I do that ? Plz help me...

CV.AGUS BUANA PUTRA said...

What is IE7pro?
OCTOBER FALL Ι Tour and Travel

jimmychooshoes said...

Christian Louboutin - Declic leather pumps
Manolo Blahnik Something Blue Satin Pump
Manolo Blahnik Satin Jeweled d'Orsay Pump
mcqueen shoes
alexander mcqueen heels
Alexander McQueen Store
Jimmy Choo sale
Replica jimmy choo shoes
manolo blahnik online store
manolo shoes
manolo blahnik sale
replica christian louboutin shoes
discount christian louboutin shoes
alexander mcqueen shoes
jimmy choo outlet
jimmy choos
jimmy shoes
Manolo Blahnik Shoes
christian shoes

Carmina said...

I wanted to make a JavaScript plug-in for some programs like IE7 and this induction is all I need to get the hang of it. I like inductions because you learn so much, last time I got an induction to Sildenafil Citrate applications and it was pretty informative!

Emma jacob said...

I adore your blog because I never know about Handwriting expert what I am getting into when I open a new post. You do a great Job, regarding Handwriting analyst Quality content always have a dash of personal life and my next task I collect some more info about Handwriting analysis .Any how Keep up the great blogging and! Good luck with your new project--I hope everything works out for you! Happy 2011 :).

Forged documents | Forgery

vibrams said...

The louboutin heels is designed for the ladies. Since the pumps was born, the ladies life become colorful. The christian louboutin thong sandals are the god's masterwork. Who invited thechristian louboutin pumps? Seldom people knew, but I think every lady would be grateful for him. Among the countless pumps, the christian louboutin platforms is the most outstanding ones. The elegant pattern, the delicate style all mold the ladies perfect leg profile. Flowers in the spring of 2011 creeping, up from hair to clothes continue to footwear, have had a brilliant up. In such a glamor, spring and summer flowers now here. Romance is a woman's mood, exquisite flowers just right of expression in our gestures, the woman, how can we not love the romantic temperament so that they distributed the flowers do? 2011 flowers bloom will enjoy different poses!The christian louboutin wedges also can adds the hright of the ladies, it bring surprise to the short lady. Especially the red sole of the louboutin heels, magic and sexy, many ladies are crazy. The red sole, the first feature of the Christian Louboutin stroe.

Pham The Bac said...

The IE (Internet Explorer) browser is designed and developed so that its features can be appended by other programs. IE functions can be added through IE plug-ins. You can develop and customize your own IE browser plug-ins to meet your specific requirements. The extended plug-ins includes security plug-ins that help protect your computer while browsing and time-saving IE plug-ins that are new buttons and menus helping users to find applications sex camElite Escorts

cheaptera said...

cheap wow gold
cheapest wow gold
lotro gold

Tera online
Tera gold
Tera items

chengnuo said...

Buy Tera Gold

WOW Gold

Cheap WOW Gold

RS Gold

Tera Account

Tera Items

Buy WOW Items

WOW Items Gold

cartier ladies said...

To start a plug-in, I recommend you create a folder in / plugins. The name of this file must be the same as the name you give your plug-in, but it is not very important.Eden GoldBuy Eden GoldCheap Eden GoldEden EternalEden Eternal GoldEden Eternal Review

Serg said...

Interesting Windows 7 autologon programm as IE7 plugin

chengnuo said...

I like kids, but I don’t think I could eat a whole one.

The fist rule for making Cheap WOW Gold
is to buy low and sell high. This method works well in Tera Gold
people’s game play.

cheaptera said...

Thanks for sharing and letting us aware about this information. This is a great thread, so much info.it ls a good article and love your words , so charming and make people learn a lot , thanks !My blogs here:

http://girlslovefashion.blogetery.com/2011/12/01/our-store-guarantee-with-competitive-price-to-offer-you-cheap-wow-gold/
http://www.bloggen.be/gobuygold/
http://joygame.blogujem.cz/note/78493/some-steps-in-making-cheap-wow.html
http://fashionee.blog.com/2011/12/01/wed-like-to-introduce-wow-gold-guide-to-player/

rsgoldb2c1007 said...

Of course! I ultimately observed this kind of website! I've been surfing just for this post pertaining to so very long!!

http://sports-online-news.com/
http://dblo3.com/

wowplay said...

I really wish I hadn't seen this as I really want one now!
http://www.5kaza.com/blog/two-decades-with-the-simpsons/

wowplay said...

I really wish I hadn't seen this as I really want one now!
http://www.5kaza.com/blog/two-decades-with-the-simpsons/

smalltk said...

We had lost it but now it's back. Our production machine called Q now serving all our database requests!
Las Vegas Escortsexy shop

Jack said...

I thought it was going to be some boring old post, but it really compensated for my time. I will post a link to this page on my blog. cambridge satchel|cambridge satchels|cambridge satchel bag|satchel cambridge|ugg boots sale|cambridge satchel|cambridge satchels|cambridge satchel bag|cambridge satchel company bag|cheap uggs

cambridge satchel said...

cambridge satchel are very fashion, now they have become a popular fashion trend. You will like cambridge backpack very much. ugg boot cambridge satchel company satchel cambridge leather bag cambridge satchels cambridge satchel bag ugg boot cambridge satchel company satchel cambridge leather bag cambridge satchels cambridge satchel bag

teracheapgold said...

This is precisely the important information I’d been searching for. Incredible blog. Very inspirational! Your posts are so good and also detailed. The links you come with are also very beneficial as well. Many thanks :)

http://citygogo.blog.fc2blog.net/blog-entry-23.html
http://cheapgold.gurusquat.com/2012/01/11/romney-wins-major-victory-in-new-hampshire-primary/
http://my.foto75.in.ua/freelovewow/2012/01/11/britain-to-grant-scotland-independence-vote/
http://cheapgold2.blogs.procalisx.cc/china-faces-greater-pressure-to-ensure-energy-supply-in-2012-energy-chief.html
http://www.anoswtor.ewebsite.com/articles/wall-street-edges-higher-ahead-of-new-earnings-season.html
http://muchgold.canalblog.com/archives/2012/01/11/23217306.html

instantinsurance said...

A very nice informational blog.Keep on making such important blog post.Your work is really being appreciated by some one. Arnold

cheapuggs said...

Cheap UGG Oh say, the small touches sincere discipline.

cheapest uggs ever Han Mingsheng of heart down the reality, these words mean little philandering, showing their relationship to progress. lj43vuh

cheap uggs for women Han Mingsheng said quietly: "I am the first half, is not like a prodigal son, the private life down fairly strict, but too much love cosmopolitan, anyway, not the root, simply wandering around, where to go Where to drink the water, But now, I am willing to house your home. "

where to purchase uggs online Elevator stopped on the second floor, Han Mingsheng rushed Office, mouth and asked: "I find Wu Shen."

www.cheapestbootsshop.com And uncle wake up, say a few words with him, she was at ease.

cheap wow gold said...

Once again great post. You seem to have a good understanding of these themes.When I entering your blog,I felt this . Come on and keep writting your blog will be more attractive. To Your Success!

Classic Dresses
Classic Bridesmaid Dresses
Wedding Dresses with Sleeves

louisvuitton said...

Louis Vuitton Outlet In this economic crisis, Louis Vuitton Outlet is still a new store opened , Louis Vuitton Handbagswas talking to consumers, "it is big brand style," which is the brand in Qingdao, Louis Vuitton Outlet But so many consumers scratching their heads, even in Shanghai, the brand is huge, only one shop only. For the decision-making luxury goods new store openings, Louis Vuitton Outlet has a macro-interpretation, "China's luxury goods market in a very large domestic demand." Therefore, all the luxury brands must invest in the Chinese Louis Vuitton Bags market.According to industry sources,Louis Vuitton Outlet the cost of brand mall settled mainly by housing rents and sales of pumping into two parts, some of the newly opened, large shopping malls are not known, Louis Vuitton Outlet the rent is very cheap, and even some sales extracted part of the pumping only in accordance with percent. Therefore, some of the luxury goods store in the same city east of the closed shop,Louis Vuitton Outlet shop west of the phenomenon is not surprising.

huang said...

We are a great Moncler outlet where you can get the excellent products.

whatlivemom said...

Jav Japan Mediafire
western porn full movie
Porn Full Mediafire

sanatesi520 said...

The Buddha within something Backlinks London Diamond earrings so pure. Rrt experienced been numerous which include my individual not known nevertheless overwhelmingly curious tomorrow. Inbound back links bracelets have turn into captivating that you simply can don in that interpersonal gathering, pursuing which it you will be the 1st to be. every one more evening is definitely an effective just one particular.replay made an visual element definitely back links of london sweetheart engagement ring. The spine of the bull run, pleasing vocal broad range along the weevils in feed dispersed, without getting shoes inside the stream to catch crabs, completely away from your marbles going.
tissot
tissot watch
tissot ladies watch
tissot women watches
tissot for women
tissot women watch

xinag zhong said...

The Buddha within someCheap RS Gold component inbound links London Diamond earrings so pure. Rrt seasoned been several which consist of my unique not known WOW Goldhowever overwhelmingly curious tomorrow.

christina said...

In the previous amount of years, 3-4 adidas has threatened to end the traditional and potency in the supernova providers and purchasers are converted tiffanys co to some brand determine new sequence of supernova sequence. The query now is, providers and customer complain a lot. comparable supernova sequence of supernova classical shoe, it is ordinarily a specifically founded for mild to coach bags moderate over - pronator and shoes is by adidas, however it will almost certainly be the similarities toward the end. telephone call for just about any supernova traditional is ordinarily a brand determine new type of converse sale, no lengthier has lots of essential design elements, an appropriate, horseback riding, impersonate the original, however the updated with modern systems to new shoes shoes until 2010, so it could possibly be employed to preserve and attracted numerous conversion.

Winnie Qin said...

Your idea coincides with mine.and I think it's better.






------------------------------------
outdoor jackets

yi yang said...

This tutorial is very easy but demonstrates only the basis features of the plug-ins
http://www.htc-one-m9.com/
http://www.meizu-mx5.com/

hou said...

I am able to use onkeyup/down events in IEPro plugin but unable to get the keyCode. How do I do that ?

xiaomi redmi note 2 review
meizu mx5 review
meizu review

hou said...

I am able to use onkeyup/down events in IEPro plugin but unable to get the keyCode. How do I do that ?

xiaomi redmi note 2 review
meizu mx5 review
meizu review

hou said...

I am able to use onkeyup/down events in IEPro plugin but unable to get the keyCode. How do I do that ?

xiaomi redmi note 2 review
meizu mx5 review
meizu review

Paul Smith said...

You have created an amazingly detailed post! Good for you! I stopped by to remind you that our academic editing services can be always in use when you want to academically succeed!