General questions about Plugins: (+)
-
COM Object
COM object must implement IMyIEClient interface. Please refer to IMyIE.h
-
Exe File:
Any win32 exe file can be used as a plugin. Maxthon will send different parameters
under different circumstance.
General parameter:
a. "-h=handle" : handle is the Wnd handle of the Maxthon main window,
decimalist.
-
Script File:
Script File must be written in the following format:
Example:
<script language="Javascript">
alert(document.lastModified);
</script>
The 'language' can be any valid language that Internet Explorer supports.
How to implement the Config function of a Plugin? (+)
There is a 'Config' button in the 'Maxthon Plugin' option page. Maxthon will call
the corresponding 'Config' function of a plugin, when user clicks the 'Config'
button.
-
COM Object:
The COM's IMyIEClient::Config will be call with the parameter of the config
dialog's hWnd handle.
-
Exe File:
The file will be called with a parameter of "-setup". For example,
if the filename is "abc.exe", then Maxthon will call "abc.exe -setup
..." .
-
Script File: (Available for Maxthon version 1.1.067 and higher)
When the user clicks on the 'config' button in the plugin config dialog, Maxthon will
try to open the 'config.html' inside your plugin's folder. And a 'max.src' file
will be created to let your plugin gets the security_id, in order to call some maxthon
functions. You can use following meta settings to specify the dialog's size.
<meta name="Dialog-Width" content="110">
<meta name="Dialog-Height" content="120">
How to add new or override existing protocols? (+)
With Maxthon, the plugin could establish a new protocol, such as book://, or
override an existing protocol, such as ftp:// .When the user inputs the protocol
in the address bar or clicks the protocol on webpage, Maxthon will call the
plugin.
-
COM Object:
Currently not supported...
-
Exe File:
The file will be called with the parameter "-u=url", in which the
url is the address that the user wants to visit, such as book://www.mysite.com/abc.pdf,
or ftp://www.google.com .
-
Script File:
Currently not supported...
How to make a "Button" type plugin? (+)
Maxthon supports "Button" type plugins, which will be placed on "Ext
Button" toolbar. The plugin is called when the user clicks on the corresponding
button. The 'Button' plugin could be implemented using the following methods.
-
COM Object:
When the user clicks on the button, Maxthon will query the Com's IOleCommandTarget
interface and IObjectWithSite interface, passing the IWebBrowser2 pointer of
the current page to its IObjectWithSite::SetSite function, then call its IOleCommandTarget::Exec
function. It's similar to IE's implementation of button. Please refer to the MSDN
for more information.
Sample Plugin.ini:
[General]
Name=ComButton
Author=bloodchen
Version=1.0
ModuleType=COM
FileName=ComButton.dll
CLSID={96E78121-9FF2-466D-B6CD-4038CAC1BB79}
Comments=Com type 'Button'
Type=M2Plugin_BUTTON
HotIcon=hot.ico
Icon=cold.ico
-
Exe File:
When the user clicks on the button, Maxthon will call the file with the parameters
of the current address and the handle of the main Maxthon window. For example, if the file
is abc.exe, then Maxthon will call abc.exe -h=23424 -u=http://www.yahoo.com, in
which 23424 is the handle of the main Maxthon window and http://www.yahoo.com
is the URL of the current page.
Sample Plugin.ini:
[General]
Name=ExeButton
Author=BloodChen
Version=1.0
ModuleType=EXE
FileName=abc.exe
Comments=Exe type Button
Type=M2Plugin_BUTTON
Icon=p.ico
-
Script:
When the user clicks on the button, Maxthon will run the script on the current web page.
Sample Plugin.ini:
[General]
Name=LastModified
Author=bloodchen
Version=1.0
ModuleType=SCRIPT
FileName=LastModified.htm
Comments=See last modified date of current page
Type=M2Plugin_BUTTON
HotIcon=hot.ico
Icon=cold.ico
How to make a "SideBar" type plugin (+)
Maxthon supports 'SideBar' plugins, this kind of plugin will appear on Maxthon's
sidebar, implemented using a html file.
-
HTML:
When the user clicks on the button, Maxthon will load the html file into the side bar
, which is assigned in plugin.ini.
Example Plugin.ini:
[General]
Name=Calculator++ 1.2
Author=SiC
Version=1.2
ModuleType=SCRIPT
FileName=calculator.htm
Comments=Scientific programmable calculator.
Type=M2Plugin_Sidebar
HotIcon=cpp.ico
Icon=cpp.ico
-
COM
When the user clicks on the button, Maxthon will load the COM control into the sidebar,
which is assigned in the plugin.ini.
Example Plugin.ini:
[General]
Name=AXSidebar sample
Author=bloodchen
Version=1.0
ModuleType=COM
Comments=Simple activex side bar control
Type=M2Plugin_SideBar
FileName=AXSidebar.dll
CLSID={108C8E56-90AF-408B-873F-8AE3480BE090}
HotIcon=ax.ico
Icon=ax.ico
The COM plugin can be implemented in two ways:
-
A COM object similar to IE's browser band implementation. It must implement
the IObjectWithSite interface,
IDeskBand interface and optionally the IInputObject interface. An example is the
Net Snippet sidebar plugin.
-
An activex control. Any valid activex control can be used, providing the
correct CLSID. The activex control can optionally implement the IObjectWithSite
interface, from which Maxthon will pass the active tab's IWebBrowser2 interface.
If the activex control is not registered in user's system and the FileName is
not empty, Maxthon will try to register the file and load the control again.
An example is the AXSidebar plugin (with source code).
Extended DHTML support (+)
Maxthon has extended the DHTML support by adding several new commands which
could be called from the script language. The HTML or script writer can call the
functions through the 'window.external' object. The functions can be called
from the script in a HTML page or from a script plugin.
Please notice: Some function will require a security_id as
first parameter which was not needed in old versions of MyIE2/Maxthon. Plugins that use these
command must be changed to use security_id .
How to get the security_id
1. For script plugins, you need a %max_security_id in your script file,
such as 'var security_id=%max_security_id', then you can use 'security_id'
in your script.
2. For sidebar plugins, a file named "max.src" will be created in
your plugin's folder with content "max_security_id=id". You can include
this file into your html page to get the id.
- addFavorite( url , title ) , addFavorite( url )
This function will ask the user to add the 'url' into favorites, using 'title'
for the name of the url.
Example 1: external.addFavorite( "http://www.google.com" ); Demo
Example 2: external.addFavorite( "http://www.google.com","This
is google"); Demo
- addProxy (name, address, speed, is_web_proxy)
This function will call Maxthon's add proxy dialog to add the proxy named
as 'name' at address 'address', giving the initial speed 'speed'. The is_web_proxy
indicates whether the proxy is a web proxy or a normal proxy.
Example: external.addProxy("My proxy","192.168.1.0:8080",1,0);
Demo
- addFilter( address ) , addFilter( address, is_pop_filter )
This function will call Maxthon's add filter dialog, setting the address to
be filtered as 'address'. 'is_pop_filter' indicates whether the default filter
type is 'pop filter'.
Example 1: external.addFilter("http://www.yahoo.com/ad*"); Demo
Example 2: external.addFilter("http://www.yahoo.com/img/*", 0); Demo
- readFile( security_id, plugin_name, file_name)
This function can only be used in a script plugin, for security reasons.
The 'plugin_name' refers to the plugin name defined in plugin.ini and the
'file_name' indicates which file it wants to read. The function will return
the file contents. If the plugin is not enabled or the 'plugin_name' is wrong
or not found, the function will fail and return null.
Example: var text = external.readFile(%max_security_id,"Test plugin","plugin.ini");
- writeFile( security_id, plugin_name, file_name, content )
This function can only be used in a script plugin, for the security reasons.
The 'plugin_name' refers to the plugin name defined in plugin.ini and the
'file_name' indicates the file name which will be written. The 'content' is
the content that will be written to the file. If the plugin is not enabled or
the 'plugin_name' is wrong or not found, the function will fail and return
null.
Please note: The file will be overwritten from
the beginning.
Example: external.writeFile(%max_security_id,"Test plugin","setting.ini","username=abc\npass=qwrxcv");
- tab_count
This command will return the total number of tabs as an integer.
Example: var total_tab = external.tab_count ; Demo
- activate_tab( security_id , index )
This function will activate tab number 'index' in Maxthon.
Example: external.activate_tab(%max_security_id,2)
- get_tab( security_id , index )
This function will return a web page object of tab number 'index'.
Example: external.get_tab(%max_security_id,2)
- cur_sel
This function will return the number of current active tabs as an integer.
Example: var cur_tab = external.cur_sel; Demo
- close_tab( security_id , index )
This function will close tab number 'index' in Maxthon.
Example: external.close_tab(%max_security_id,2)
- m2_readIni( security_id, plugin_name , file_name , section_name , key , default_value)
This function will read the key using the default_value in the ini file specified
by file_name in the plugin folder.
Example: path = external.m2_readIni(%max_security_id,"testplugin","settings.ini","general","save","0");
- m2_writeIni( security_id , plugin_name , file_name , section_name , key , value )
This function will write the key with 'value' to the ini file specified
by file_name.
Example: external.m2_writeIni(%max_security_id,"testplugin","settings.ini","general","save","true");
- m2_search_text( security_id )
This property will return the text in Maxthon's search bar.
Example: var text = external.m2_search_text(%max_security_id)
- m2_run_cmd( security_id , id )
This function will call a Maxthon command with the specified ID. The id of every command
can be found in the language file.
Example: external.m2_run_cmd(%max_security_id,32772); //This will open a blank page.
- m2_plugin_folder( security_id , plugin_name )
This function will return the local path of the plugin.
Example: var folder = external.m2_plugin_folder(%max_security_id,"ViewSource!");
This will return for example: "C:\Program Files\Maxthon\Plugin\ViewSource!\"
- max_actSideBarItem( plugin_name )
This function will activate the sidebar plugin named as 'plugin_name'.
Example: external.max_actSideBarItem("Calculator++");
- max_modelessDialog( security_id , url , option , attr , window )
This function will open a modelessDialog. It's same as window.ShowModelessDialog
function. The last parameter 'window' is the window object of the web page.
Example: external.max_modelessDialog(%max_security_id,'example.htm',window,'status:no;help:no;resizable:yes;scroll:yes;',window)
- m2_callerName( security_id, plugin_name)
This function tells Maxthon the call is made from a Plugin. It's usually used
before a 'window.open' call to let maxthon bypass the popup window that the plugin
opened.
Example: external.m2_callerName(%max_security_id,"ViewSource!")
- max_showConfig( security_id, plugin_name)
This function will show the plugin's config dialog.
Example: external.max_showConfig(%max_security_id,"ViewSource!")
- max_activex(security_id, prog_id)
This function will create the ActiveX control with the prog_id.
Example: var XML=external.max_activex(%max_security_id,"Microsoft.XMLDOM")
- max_language_id
This property is the user's current selected language.
You can view all the languages here
Example: var language=external.max_language_id
SideBar plugin callback functions: (+)
In a sidebar plugin you can implement a script function called max_callback(status).
-
When the plugin is created the URL will be filename?maxcmd=init
-
When the plugin is activated, max_callback('sidebar_activate') will be called
-
When the plugin is deactivated, max_callback('sidebar_deactivate') will be
called
-
When the active tab is changed, max_callback('sidebar_tab_change') will be
called
-
When the plugin is unload, max_callback('sidebar_unload') will be called.