Différences entre les versions de « Les scripts de Maxthon v2.0 »

De Wiki Francophone de Maxthon
Aller à la navigation Aller à la recherche
Ligne 1 : Ligne 1 :
Last Modified: 2006-07-17 4:24 PM
== '''Types de Plugin de Maxthon''' ==
Version: 2.0.1
 
 
Le type de Plugin de Maxthon est défini par ModuleType (Script, HTML, COM et EXE) et Type (Button, Sidebar, Toolbar, COM_Button, MHO, MHO_Button) simultanément :
 
 
              Button    SideBar  Toolbar  COM_Button    MHO    MHO_Button
Script        oui      oui
HTML          oui
EXE            oui
COM            oui      oui        oui        oui        oui        oui
COM_Global    oui      oui        oui        oui
 
 
'''1. ModuleType - Script, HTML, EXE, COM et COM_Global'''
 
 
'''Script''' - Le Plugin Script peut être de type button, qui exécute un script lorsqu'il est cliqué. le script peut être dans un langage supporté par IE, comme le javascript ou le vbscript. Maxthon 2.0 supporte le mscript qui exécute l'environment (plus de détails ci-après). Le Script peut également être de type sidebar, qui affiche un fichier HTML dans la barre latérale.
'''HTML''' - Un nouveau type de Plugin pour Maxthon 2.0 seulement. Le Plugin de type HTML est similaire au Plugin Script Sidebar dans sa nature. La différence majeure est que le Plugin Script Sidebar est affiché dans la barre latérale de Maxthon alors que le Plugin HTML est affiché comme un bouton dans la barre des Plugins ou n'importe quelle barre d'outils (barre d'état, barre des menus, barre des onglets, barre d'adresses...).
'''EXE''' - EXE plugin will be shown as a button in the plugin bar. EXE plugin can be any executable file. Maxthon can pass various parameters to the executable file like the url of the current webpage or the handle of Maxthon browser window.
 
'''COM''' - COM plugin can be written in any programming language supported by MSCOM, like C++, Delphi, Visual Basic, C# etc. COM plugins are created on per tab basis when a tab is created (SideBar/Toolbar/MHO/COM_Button types) or when the plugin button is clicked (Button type), and is destroyed when the tab is closed. A COM plugin can implement the IObjectWithSite interface to obtain the pointer to webbrowser of the tab, the browser events and the Document Object Model for manipulation.
 
'''COM_Global''' - COM_Global plugins are created only once when Maxthon is started, and is destroyed when Maxthon is closed. COM_Global plugins are mostly for browser functions not related to the Document Object Model. Yet COM_Global plugins can implement a PutMaxCommander function through the IDispatch interface to obtain a Maxthon plugin object, which can be used the same way as Maxthon's external object for script plugins (see script plugin commands below), for interaction with the Document Object Model of tabs and Maxthon.
 
Note that Maxthon 2.0 is multi-thread (a thread for each tab). Plugins designed for extensive interaction with the Document Object Model of tabs should be implemented as COM (per tab) instead of COM_Global so they can work more efficiently within the same thread of individual tab.
 
 
'''Type - Button, SideBar, Toolbar, COM_Button, MHO, and MHO_Button'''
 
 
'''Button''' - A button will be added to the plugin bar. The operation specified by script (Script plugin), executable (EXE plugin), dll (COM plugin) will be runned when the button is clicked. Optionally button plugins can implement a dropdown menu for the plugin. A COM button plugin must implement the IOleCommandTarget interface to receive the button click. If a plugin menu is implemented, the IOleCommandTarget_Exec function will receive a command id of 1 when the button is clicked, and a command id of 2 when the first menu command is clicked, and so on. A COM button plugin is created when the button is clicked and is destroyed when the tab is closed (the same as IE7).
 
'''SideBar''' - A button will be added to the sidebar, and an item will be added to the main menu > View > SideBars. When the button or menu item is clicked, Maxthon's sidebar will be opened and show the HTML file specified by the plugin (script plugin), or the window specified by the plugin through the IDeskBand interface (com or com_global plugin).
 
'''Toolbar''' - Toolbar plugins must be written in COM. A new toolbar will be added, which can be shown or hidden from Main Menu > View > Toolbars. A Toolbar plugin must implement the IDeskBand interface to specify the toolbar window. Toolbar plugins can be COM or COM_Global. COM Toolbar plugins are created on per tab basis when a tab is created, and are destroyed when the tab is closed. This enables the adoption of most IE Toolbars in Maxthon with minimal or no change. COM_Global Toolbars are created only once when Maxthon is started, and are destroyed when Maxthon is closed. If a COM_Global Toolbar implements the IObjectWithSite interface, it can obtain the webbrowser pointer of the active tab throught SetSite. When the active tab is changed, SetSite will call again to pass the webbrowser pointer of the new active tab.
 
'''COM_Button''' - COM_Button plugins are similar to Toolbar plugins, except that COM_Button plugins are shown in Maxthon similar to a button, instead of a toolbar. A COM_Button plugin has the flexibility of placement in Maxthon interface like other buttons, but also supports the richer interface of a toolbar than a button.
 
'''MHO''' - MHO plugin is similar to IE's Browser Helper Object and must be written in COM. MHO plugins are created on per tab basis when a tab is created, and are destroyed when a tab is closed. MHO plugins should implement the IObjectWithSite interface to obtain the webbrowser pointer of the tab for interaction with the DOM. MHO plugins do not have interface.
 
'''MHO_Button''' - MHO plugin is a combination of MHO plugin and COM Button plugin. MHO_Button plugins are created on per tab basis when a tab is created, and are destroyed when a tab is closed. In addition, an instance of MHO_Button plugin will be created when its button is clicked, and the instance will be destroyed when the operation is finished. MHO_Button plugin essentially adds a button interface to the MHO plugin.
 
== Create Maxthon Plugin ==
 
 
'''Major Components of Maxthon Plugin'''
 
A Maxthon normally contains the following files:
 
'''INI file''' – The plugin.ini file necessary for all Maxthon plugins. It defines various attributes of the plugin.
 
'''HTML/DLL/EXE file''' – The most main component necessary for all Maxthon plugins specifying the operation to be done or the content to be displayed.
'''Icon file''' – The button ico (*.ICO) necessary for button and sidebar plugins. COM and EXE plugin may use icons in their own resources.
'''Config.html''' – An optional HTML file for use with Script and HTML type plugins as the configuration dialog.
 
 
 
'''plugin.ini file'''
 
 
[General] necessary for definition of various plugin attributes
'''Name'''= plugin name
'''Author'''= author name
'''Version'''= plugin version
'''ModuleType'''= can be Script, HTML, EXE, COM, or COM_Global
'''FileName'''= can be HTML file (Script and HTML plugins),DLL file (COM plugins),or EXE file (EXE plugins)
'''Comments'''= the description shown in plugin options dialog and/or button type plugin tooltips
'''Type'''= can be M2Plugin_Button, M2Plugin_Sidebar, M2Plugin_Toolbar, M2Plugin_COM_Button, M2Plugin_MHO, or M2Plugin_MHO_Button
'''IdealSize'''= the width and height of plugin interface (eg 120 20, for HTML plugin only)
'''IdealSizeVertical'''= the width and height of plugin interface when docked vertically (eg 120 20, optional for HTML plugin)
'''Icon'''= the button icon for button and sidebar plugins
'''HotIcon'''= the button icon when the button plugin is hovered
'''CLSID'''= the CSLID for COM and COM_Global plugins
'''DefaultLocation'''= optional, set the default location of plugin icon, can be '''None''' (in plugin bar but not shown after installation, user can show the button from the add/remove button menu), '''MenuBar''', '''ToolBar''', or '''StatusBar'''. If this is not set, the plugin will be shown in the plugin bar. For '''Button''' type plugin and Maxthon 2.0.5 or later.
 
'''StartAfterPageDoneURL'''= optional, set the addresses where the plugin should auto start, supports wildcards, and can use "|" to separate addresses, eg '''*maxthon.com*|forum.maxthon.cn*'''. If not set, will auto start in all addresses, equivalent to a setting of '''*'''. For '''Script''' '''Button''' type plugin and Maxthon 2.0.5 or later.
 
'''StartAfterPageDoneURLExclude'''= optional, set where the plugin should not auto start, has higher priority than startAfterPageDoneUrl. Use the same format as startAfterPageDoneUrl eg. '''forum.maxthon.cn/index.php?|*.maxthon.cn/index.php?showtopic*'''. For '''Script''' '''Button''' type plugin and Maxthon 2.0.5 or later.
 
[MyIE2Buttons] optional for definition of drop down menu for Button and MHO_Button plugins
'''Count'''= the number of drop down menu items
'''Name1'''= the name of the first menu item
'''FileName1'''= the file name, or the file name plus the parameter for EXE plugins, of the first menu item. For COM Button and COM MHO_Button plugins, put an arbitrary and distinct name, eg. 1 for FileName1 and 2 for FileName2 etc
 
 
'''Install Maxthon Plugin'''
 
Maxthon plugins are installed in the "Plugin" folder inside Maxthon's installation folder. Every plugin has own dedicated plugin folder which contains the plugin.ini file and other necesary files and/or subfolders.
 
A finished plugin, comprising the plugin folder and all files and/or subfolders inside can be compressed into a ZIP file (*.zip) for released.
 
 
'''Maxthon 2.0'''
Maxthon 2.0 supports custom M2P plugin installation pack (essentially a *.zip renamed to *.m2p. Plugin will be installed when the M2P file is doubleclicked or dragged into Maxthon's browser window.
 
'''Maxthon 1.X'''
Plugins are installed in Maxthon 1.x according to the following procedures:
1. close Maxthon
2. extract the plugin zip file to the "Plugin" folder inside Maxthon's installation folder. Typically the relevant plugin.ini file will be located C:\Program Files\Maxthon\Plugin\NewPlugin\plugin.ini
3. open Maxthon, the Plugin Installation window will be shown
4. confirm the installation of new plugin
 
 
 
 
 
 
 





Version du 4 septembre 2008 à 08:42

Types de Plugin de Maxthon

Le type de Plugin de Maxthon est défini par ModuleType (Script, HTML, COM et EXE) et Type (Button, Sidebar, Toolbar, COM_Button, MHO, MHO_Button) simultanément :


              Button    SideBar   Toolbar   COM_Button    MHO     MHO_Button
Script         oui       oui
HTML           oui
EXE            oui
COM            oui       oui        oui        oui        oui        oui
COM_Global     oui       oui        oui        oui


1. ModuleType - Script, HTML, EXE, COM et COM_Global


Script - Le Plugin Script peut être de type button, qui exécute un script lorsqu'il est cliqué. le script peut être dans un langage supporté par IE, comme le javascript ou le vbscript. Maxthon 2.0 supporte le mscript qui exécute l'environment (plus de détails ci-après). Le Script peut également être de type sidebar, qui affiche un fichier HTML dans la barre latérale.

HTML - Un nouveau type de Plugin pour Maxthon 2.0 seulement. Le Plugin de type HTML est similaire au Plugin Script Sidebar dans sa nature. La différence majeure est que le Plugin Script Sidebar est affiché dans la barre latérale de Maxthon alors que le Plugin HTML est affiché comme un bouton dans la barre des Plugins ou n'importe quelle barre d'outils (barre d'état, barre des menus, barre des onglets, barre d'adresses...).

EXE - EXE plugin will be shown as a button in the plugin bar. EXE plugin can be any executable file. Maxthon can pass various parameters to the executable file like the url of the current webpage or the handle of Maxthon browser window.

COM - COM plugin can be written in any programming language supported by MSCOM, like C++, Delphi, Visual Basic, C# etc. COM plugins are created on per tab basis when a tab is created (SideBar/Toolbar/MHO/COM_Button types) or when the plugin button is clicked (Button type), and is destroyed when the tab is closed. A COM plugin can implement the IObjectWithSite interface to obtain the pointer to webbrowser of the tab, the browser events and the Document Object Model for manipulation.

COM_Global - COM_Global plugins are created only once when Maxthon is started, and is destroyed when Maxthon is closed. COM_Global plugins are mostly for browser functions not related to the Document Object Model. Yet COM_Global plugins can implement a PutMaxCommander function through the IDispatch interface to obtain a Maxthon plugin object, which can be used the same way as Maxthon's external object for script plugins (see script plugin commands below), for interaction with the Document Object Model of tabs and Maxthon.

Note that Maxthon 2.0 is multi-thread (a thread for each tab). Plugins designed for extensive interaction with the Document Object Model of tabs should be implemented as COM (per tab) instead of COM_Global so they can work more efficiently within the same thread of individual tab.


Type - Button, SideBar, Toolbar, COM_Button, MHO, and MHO_Button


Button - A button will be added to the plugin bar. The operation specified by script (Script plugin), executable (EXE plugin), dll (COM plugin) will be runned when the button is clicked. Optionally button plugins can implement a dropdown menu for the plugin. A COM button plugin must implement the IOleCommandTarget interface to receive the button click. If a plugin menu is implemented, the IOleCommandTarget_Exec function will receive a command id of 1 when the button is clicked, and a command id of 2 when the first menu command is clicked, and so on. A COM button plugin is created when the button is clicked and is destroyed when the tab is closed (the same as IE7).

SideBar - A button will be added to the sidebar, and an item will be added to the main menu > View > SideBars. When the button or menu item is clicked, Maxthon's sidebar will be opened and show the HTML file specified by the plugin (script plugin), or the window specified by the plugin through the IDeskBand interface (com or com_global plugin).

Toolbar - Toolbar plugins must be written in COM. A new toolbar will be added, which can be shown or hidden from Main Menu > View > Toolbars. A Toolbar plugin must implement the IDeskBand interface to specify the toolbar window. Toolbar plugins can be COM or COM_Global. COM Toolbar plugins are created on per tab basis when a tab is created, and are destroyed when the tab is closed. This enables the adoption of most IE Toolbars in Maxthon with minimal or no change. COM_Global Toolbars are created only once when Maxthon is started, and are destroyed when Maxthon is closed. If a COM_Global Toolbar implements the IObjectWithSite interface, it can obtain the webbrowser pointer of the active tab throught SetSite. When the active tab is changed, SetSite will call again to pass the webbrowser pointer of the new active tab.

COM_Button - COM_Button plugins are similar to Toolbar plugins, except that COM_Button plugins are shown in Maxthon similar to a button, instead of a toolbar. A COM_Button plugin has the flexibility of placement in Maxthon interface like other buttons, but also supports the richer interface of a toolbar than a button.

MHO - MHO plugin is similar to IE's Browser Helper Object and must be written in COM. MHO plugins are created on per tab basis when a tab is created, and are destroyed when a tab is closed. MHO plugins should implement the IObjectWithSite interface to obtain the webbrowser pointer of the tab for interaction with the DOM. MHO plugins do not have interface.

MHO_Button - MHO plugin is a combination of MHO plugin and COM Button plugin. MHO_Button plugins are created on per tab basis when a tab is created, and are destroyed when a tab is closed. In addition, an instance of MHO_Button plugin will be created when its button is clicked, and the instance will be destroyed when the operation is finished. MHO_Button plugin essentially adds a button interface to the MHO plugin.

Create Maxthon Plugin

Major Components of Maxthon Plugin

A Maxthon normally contains the following files:

INI file – The plugin.ini file necessary for all Maxthon plugins. It defines various attributes of the plugin.

HTML/DLL/EXE file – The most main component necessary for all Maxthon plugins specifying the operation to be done or the content to be displayed.

Icon file – The button ico (*.ICO) necessary for button and sidebar plugins. COM and EXE plugin may use icons in their own resources.

Config.html – An optional HTML file for use with Script and HTML type plugins as the configuration dialog.


plugin.ini file


[General] necessary for definition of various plugin attributes


Name= plugin name

Author= author name

Version= plugin version

ModuleType= can be Script, HTML, EXE, COM, or COM_Global

FileName= can be HTML file (Script and HTML plugins),DLL file (COM plugins),or EXE file (EXE plugins)

Comments= the description shown in plugin options dialog and/or button type plugin tooltips

Type= can be M2Plugin_Button, M2Plugin_Sidebar, M2Plugin_Toolbar, M2Plugin_COM_Button, M2Plugin_MHO, or M2Plugin_MHO_Button

IdealSize= the width and height of plugin interface (eg 120 20, for HTML plugin only)

IdealSizeVertical= the width and height of plugin interface when docked vertically (eg 120 20, optional for HTML plugin)

Icon= the button icon for button and sidebar plugins

HotIcon= the button icon when the button plugin is hovered

CLSID= the CSLID for COM and COM_Global plugins

DefaultLocation= optional, set the default location of plugin icon, can be None (in plugin bar but not shown after installation, user can show the button from the add/remove button menu), MenuBar, ToolBar, or StatusBar. If this is not set, the plugin will be shown in the plugin bar. For Button type plugin and Maxthon 2.0.5 or later.

StartAfterPageDoneURL= optional, set the addresses where the plugin should auto start, supports wildcards, and can use "|" to separate addresses, eg *maxthon.com*|forum.maxthon.cn*. If not set, will auto start in all addresses, equivalent to a setting of *. For Script Button type plugin and Maxthon 2.0.5 or later.

StartAfterPageDoneURLExclude= optional, set where the plugin should not auto start, has higher priority than startAfterPageDoneUrl. Use the same format as startAfterPageDoneUrl eg. forum.maxthon.cn/index.php?|*.maxthon.cn/index.php?showtopic*. For Script Button type plugin and Maxthon 2.0.5 or later.


[MyIE2Buttons] optional for definition of drop down menu for Button and MHO_Button plugins


Count= the number of drop down menu items

Name1= the name of the first menu item

FileName1= the file name, or the file name plus the parameter for EXE plugins, of the first menu item. For COM Button and COM MHO_Button plugins, put an arbitrary and distinct name, eg. 1 for FileName1 and 2 for FileName2 etc


Install Maxthon Plugin

Maxthon plugins are installed in the "Plugin" folder inside Maxthon's installation folder. Every plugin has own dedicated plugin folder which contains the plugin.ini file and other necesary files and/or subfolders.

A finished plugin, comprising the plugin folder and all files and/or subfolders inside can be compressed into a ZIP file (*.zip) for released.


Maxthon 2.0

Maxthon 2.0 supports custom M2P plugin installation pack (essentially a *.zip renamed to *.m2p. Plugin will be installed when the M2P file is doubleclicked or dragged into Maxthon's browser window.

Maxthon 1.X

Plugins are installed in Maxthon 1.x according to the following procedures:

1. close Maxthon

2. extract the plugin zip file to the "Plugin" folder inside Maxthon's installation folder. Typically the relevant plugin.ini file will be located C:\Program Files\Maxthon\Plugin\NewPlugin\plugin.ini

3. open Maxthon, the Plugin Installation window will be shown

4. confirm the installation of new plugin





Vue d'ensemble

Le navigateur Maxthon a amélioré le support du DHTML de IE en ajoutant plusieurs nouvelles extensions qui peuvent être appelées par un langage de script comme Javascript et VBScript.

Ces APIs peuvent être appelées via l'objet window.external dans une page HTML ou par un Plugin de type script réalisé pour Maxthon.

Quelques fonctions nécessiteront security_id comme premier paramètre. Ces fonctions peuvent seulement être utilisées par des Plugins.
Afin d'avoir un security_id pour votre plugin, vous devez procéder ainsi :

Plugins de type Bouton

Insérez un %max_security_id dans votre script, comme ceci :

var security_id=%max_security_id;

Ainsi vous pourrez utiliser la variable security_id dans votre script.

Plugins de type Barre latérale

Un fichier nommé max.src sera créé dans le dossier de votre Plugin, inclure ce fichier dans votre fichier HTML :

<script type="text/javascript" src="max.src"></script>

Ainsi vous pourrez utiliser la variable max_security_id comme paramètre identificateur de sécurité dans votre script.

Index

Propriétés étendues

Méthodes générales

Méthodes associées aux onglets

Méthodes associées aux fichiers


Propriétées étendues

max_version

Remarques :

Cette propriété retournera une chaîne de caractères indiquant le numéro de version de Maxthon.
La chaîne sera formatée de la façon suivante : "2.1.0.600".
Il est suggéré d'utiliser cette propriété pour déterminer si Maxthon est en cours d'exécution.

Exigences :

Maxthon version 2.0+

Exemple :

alert('Maxthon Version: '+external.max_version);


max_language_id

Remarques :

Cette propriété retournera l'ID de la langue en cours d'utilisation dans Maxthon.
L'ID de la langue a été modifié afin d'utiliser l'identificateur de langage défini dans Microsoft Windows depuis Maxthon v2.0. 
la liste des ID utilisés par Maxthon se trouve ici :
http://msdn.microsoft.com/library/?url=/library/en-us/intl/nls_238z.asp

Exigences :

Maxthon version 1.0+

Exemple :

alert('Language ID='+external.max_language_id);


====current_tab==== (formerly cur_sel ) Non encore implémenté

Remarques :
Cette propriété retournera un nombre entier qui représente l'index de l'onglet qui est actif.
null sera retourné s'il n'y a auncun onglet d'ouvert.
current_tab a été introduit dans Maxthon v2.0 en remplacement de cur_sel
parce que le nom de l'ancienne propriété était trop obscur à comprendre.


Exigences :
Maxthon version 2.0+ (utiliser cur_sel pour les versions 1.x)

Exemple :
alert('Current Tab Index: '+external.current_tab);


tab_count

Remarques :
Cette propriété retournera le nombre d'onglet en cours sous la forme d'un entier.

Exigences :
Maxthon version 1.0+

Exemple :

alert('Tabs Count: '+external.tab_count);


Méthodes générales

addFavorite(url [, title])

Paramètres :

url : chaîne
L'url à ajouter.

title : chaîne
Optionnel. Le titre de l'url.

Remarques :
Affiche la boîte de dialogue Ajouter un Favori pour demander à l'utilisateur d'ajouter un nouveau Favori.
Cette fonction retournera faux si l'utilisateur a annulé cette opération.

Exigences :
Maxthon version 1.0+

Exemple :

external.addFavorite("http://www.maxthon.com");

external.addFavorite("http://www.maxthon.com", "Site officiel de Maxthon");


addProxy(name, address, type)

Paramètres :

name : chaîne
Le nom du Proxy.

address : chaîne
L'adresse IP ou le nom de domaine du Proxy.

type : entier
Un nombre indiquant la vitesse du Proxy.
= Proxy HTTP, 1 = Proxy SOCKS4A, 2 = Proxy SOCKS5

Remarques :
Ajoute un nouveau Proxy dans liste des Proxy de Maxthon. Une boîte de dialogue sera présentée à l'utilisateur.
Cette fonction retournera faux si l'utilisateur a annulé cette opération.

Exigences :
Maxthon version 2.0+

Exemple :

external.addProxy("My proxy","192.168.1.0:8080", 1);


addFilter(url_mask, type)

Paramètres :

url_mask : chaîne
Masque d'adresse qui correspond aux adresses à bloquer. Supporte les expressions régulières.

type : entier
Un nombre indiquant la liste de filtres à ajouter.
= Filtre de Popup, 1 = Filtre de contenu

Remarques :
Ajoute une nouvelle politique de filtrage dans Maxthon. Une boîte de dialogue sera présentée à l'utilisateur.
Cette fonction retournera faux si l'utilisateur a annulé cette opération.

Exigences :
Maxthon version 2.0+

Exemple :

external.addFilter("http://www.advertisement.com/img/*", );


max_addProxyProvider(URL)

Paramètres :

URL : chaîne
L'URL du fichier de la liste des Proxy. Pour le format du fichier, se reporter à [proxyprovider.htm ce document].

Remarques :
Ajoute un nouveau fournisseur de Proxy dans Maxthon. Une boîte de dialogue sera présentée à l'utilisateur.
Cette fonction retournera faux si l'utilisateur a annulé cette opération.

Exigences :
Maxthon version 2.0+

Exemple :

external.max_addProxyProvider("http://www.freeproxy.cn/m2proxy/proxylist.xml");


m2_run_cmd(security_id, command_id)

Paramètres :

security_id : chaîne
ID de sécurité de Maxthon.

command_id : entier
L'ID de la commande interne de Maxthon.

Remarques :
Cette fonction appellera une commande de Maxthon avec le command_id spécifié.
De nombreux ID de commande peuvent être trouvés dans le fichier langage dans le répertoire langage de Maxthon.
L'ID de la commande peut être différent suivant la version.
N'utilisez pas cette fonction si ce n'est pas nécessaire.


Exigences :
Maxthon version 1.0+

Exemple :

external.m2_run_cmd(security_id, 32772); // Ouvre une page vierge


m2_search_text(security_id)

Paramètres :

security_id : chaîne
ID de sécurité de Maxthon.

Remarques :
Cette fonction retournera le texte de la barre de recherche de Maxthon sous la forme d'une chaîne.

Exigences :
Maxthon version 1.2+

Exemple :

var searchText=external.m2_search_text(security_id);


m2_plugin_folder(security_id, plugin_name)

Paramètres :

security_id : chaîne
ID de sécurité de Maxthon.

plugin_name : chaîne
Le nom du Plugin comme défini dans le fichier plugin.ini.

Remarques :
Cette fonction retournera le dossier local du Plugin spécifié sous la forme d'une chaîne.

Exigences :
Maxthon version 1.2+

Exemple :

var pluginPath=external.m2_plugin_folder(security_id, "ViewSource!");


m2_callerName(security_id, plugin_name)

Paramètres :

security_id : chaîne
ID de sécurité de Maxthon.

plugin_name : chaîne
Le nom du Plugin comme défini dans le fichier plugin.ini.

Remarques :
Cette fonction indiquera à Maxthon la fonction suivante appelée à partir du Plugin.
Cette fonction est habituellement utilisée avant l'ouverture de la méthode window.open()
pour bypasser le bloqueur de Popup de Maxthon pour le Plugin.

Exigences :
Maxthon version 1.2+

Exemple :

external.m2_callerName(security_id, "ViewSource!");
window.open("about:blank");


max_actSideBarItem(plugin_name)

Paramètres :

plugin_name : chaîne
Le nom du Plugin comme défini dans le fichier plugin.ini.

Remarques :
Cette fonction activera le Plugin de la barre latérale avec le nom indiqué. 

Exigences :
Maxthon version 1.2+

Exemple :

external.max_actSideBarItem("Calculator++");


max_modelessDialog(security_id, url, arguments, features, parent_window)

Paramètres :

security_id : chaîne
ID de sécurité de Maxthon.

url : chaîne
L'url du contenu de la boîte de dialogue.

arguments : variante
Les arguments passés à l'objet window.dialogArguments de la boîte de dialogue .

features : chaîne
Une chaîne qui spécifie les caractéristiques de la fenêtre de la boîte de dialogue.

parent_window : objet
La racine de l'objet window de la boîte de dialogue.

Remarques :
Cette fonction est à peu près la même que window.showModelessDialog() mais avec 2 paramètres de plus.
Avec le security_id votre Plugin peut bypasser le bloqueur de Popup de Maxthon.
Avec le parent_window vous pouvez créer la boîte de dialogue qui est une fille d'une autre window de l'onglet.

Exigences :
Maxthon version 1.2+

Exemple :

external.max_modelessDialog(security_id, "about:blank", {"userid": 7, "key": "d3fe3asd"}, "status:no; help:no; resizable:yes; scroll:yes;", window);


get_tab(security_id, index)

Paramètres :

security_id : chaîne
ID de sécurité de Maxthon.

index : entier
L'index de l'onglet à obtenir.

Remarques :
Cette fonction obtiendra l'objet window de l'onglet spécifié dans Maxthon.
null sera retourné si l'onglet n'existe pas.

Exigences :
Maxthon version 1.0+

Exemple :

var objTab=external.get_tab(security_id, 5);


activate_tab(security_id, index)

Paramètres :

security_id : chaîne
ID de sécurité de Maxthon.

index : entier
L'index de l'onglet à activer.

Remarques :
Cette fonction activera l'onglet spécifié dans Maxthon.
Il ne se passera rien si l'onglet n'existe pas.

Exigences :
Maxthon version 1.0+

Exemple :

external.activate_tab(security_id, 1);


close_tab(security_id, index)

Paramètres :

security_id : chaîne
ID de sécurité de Maxthon.

index : entier
Entier. L'index de l'onglet à fermer.

Remarques :
Cette fonction fermera l'onglet représentant l'index.
Il ne se passera rien si l'onglet n'existe pas.

Exigences :
Maxthon version 1.0+

Exemple :

external.close_tab(security_id, );


readFile(security_id, plugin_name, file_name)

Paramètres :

security_id : chaîne
ID de sécurité de Maxthon.

plugin_name : chaîne
Le nom du Plugin appelé indiqué dans le fichier plugin.ini

file_name : chaîne
Le ficher à lire.

Remarques :
Cette fonction peut seulement être utilisée dans un Plugin.
La fonction retournera le contenu du fichier dans une chaîne en cas de succès.
Si le Plugin n'est pas actif ou que le plugin_name n'est pas trouvé, la fonction échouera et retournera null.

Exigences :
Maxthon version 1.0+

Exemple :

var strFile=external.readFile(security_id, "Test plugin", "plugin.ini");


writeFile(security_id, plugin_name, file_name, content)

Paramètres :

security_id : chaîne
ID de sécurité de Maxthon.

plugin_name : chaîne
Le nom du Plugin appelant comme indiqué dans le fichier plugin.ini

file_name : chaîne
Le fichier à écrire.

content : chaîne
Chaîne du contenu du fichier à écrire.

Remarques :
Cette fonction ne peut être utilisée que dans un Plugin.
Cette fonction retournera vrai en cas de succès.
Si le fichier n'est pas trouvé, le plugin n'est pas actif ou le plugin_name n'est pas trouvé,
la fonction échouera et retournera faux.
Si un fichier avec le même nom existe, il sera écrasé.

Exigences :
Maxthon version 1.0+

Exemple :

external.writeFile(security_id, "Test plugin", "setting.ini", "username=abc\npass=qwrxcv");


m2_readIni(security_id, plugin_name, file_name, section_name, key, default_value)

Paramètres :

security_id : chaîne
ID de sécurité de Maxthon.

plugin_name : chaîne
Le nom du Plugin appelant comme indiqué dans le fichier plugin.ini.

file_name : chaîne
Le nom du fichier INI à lire.

section_name : chaîne
La section INI à lire, sans crochet [ ].

key : chaîne
La clé de l'entrée à lire.

default_value : chaîne
La valeur par défaut à retourner si la clé n'existe pas.

Remarques :
Cette fonction lira la valeur de la key sous la section section_name dans le fichier INI file_name.
Le fichier INI doit se trouver dans le dossier du Plugin plugin_name.
La valeur sera retournée sous la forme d'une string en cas de succès.
Si le fichier n'existe pas, la section n'existe pas ou la clé n'existe pas, la default_value sera retournée.

Exigences :
Maxthon version 1.0+

Exemple :

var saveCount = external.m2_readIni(security_id, "TestPlugin", "settings.ini", "general", "saveCount", "0");


m2_writeIni(security_id, plugin_name, file_name, section_name, key, value)

Paramètres :

security_id : chaîne
ID de sécurité de Maxthon.

plugin_name : chaîne
Le nom du Plugin appelant comme indiqué dans le fichier plugin.ini.

file_name : chaîne
Le nom du fichier INI à écrire.

section_name : chaîne
La section INI à écrire, sans crochet [ ].

key : chaîne
La clé de l'entrée à écrire.

value : chaîne/entier
La valeur à écrire.

Remarques :
Cette fonction écrira une key et une paire de value sous la section section_name dans le fichier INI file_name.
Le fichier INI ne peut être écrit que dans le dossier du Plugin plugin_name.
Si le fichier n'existe pas, la section n'existe pas ou la clé n'existe pas, ils seront créés automatiquement.
Cette fonction retournera vrai en cas de succès et faux en cas d'échec.

Exigences :
Maxthon version 1.0+

Exemple :

external.m2_writeIni(security_id, "TestPlugin", "settings.ini", "general", "saveCount", 25);


Base de connaissances de Maxthon 2.0