更多相关内容...>>Maxthon Script Plugin Commands
Maxthon Script Plugin Commands
Maxthon provides various plugin commands to improve the capability of Script plugins. These plugin commands can be run through the window.external object. Some plugin commands requires a Security ID generated by Maxthon to be run.
JlLJG2 http://blog.numino.net/
How to obtain the Security ID
78s0J2 http://blog.numino.net/
1. Script button plugins can use "%max_security_id" for the Security ID
aa8jzA http://blog.numino.net/
2. Script sidebar plugins and HTML button plugins have to load "max.src", a script generated by Maxthon. Then "max_security_id" can be used。
xKcGb6 http://blog.numino.net/
<script src=max.src></script>
6TNtez http://blog.numino.net/
Reference for Maxthon Plugin Commands
3e9mNZ http://blog.numino.net/
Unless specified otherwise, the following plugin commands are applicable for both Maxthon 2.0 and Maxthon 1.X。
H1p3HQ http://blog.numino.net/
1. max_version - return Maxthon's version number
JOiqzO http://blog.numino.net/
Example:
OGBp5Z http://blog.numino.net/
alert(external.max_version);
YktYy6 http://blog.numino.net/
2. max_language_id - return Maxthon's language ID
26uKzW http://blog.numino.net/
Example:
00Hp77 http://blog.numino.net/
alert(external.max_language_id);
oXk24H http://blog.numino.net/
Note: Maxthon 2.0 and Maxthon 1.X have different language ID format
zTj3qZ http://blog.numino.net/
3. tab_count - return the number of tabs opened by Maxthon
Hxmn4p http://blog.numino.net/
Example:
ac74qE http://blog.numino.net/
alert(external.tab_count);
i5BYUi http://blog.numino.net/
4. cur_sel - return the index of Maxthon's current tab
0M1cM8 http://blog.numino.net/
Example:
72Y43p http://blog.numino.net/
alert(external.cur_sel);
sur3WQ http://blog.numino.net/
5. m2_plugin_folder( security_id , plugin_name ) - return the folder path of the specified plugin
Ve5WFg http://blog.numino.net/
Example:
Lf4288 http://blog.numino.net/
alert(external.m2_plugin_folder( %max_security_id , 'ViewSource!'));
R3Sjx9 http://blog.numino.net/
6. m2_run_cmd( security_id , command_id ) - run the specified command ID
Sr8LJO http://blog.numino.net/
Example:
QPLh23 http://blog.numino.net/
external. m2_run_cmd( %max_security_id , 32772 ));
OyXv2X http://blog.numino.net/
Note: Maxthon 2.0 and Maxthon 1.X have different command ID. Command ID can be found in Maxthon's language file.
5fp7wb http://blog.numino.net/
7. get_tab( security_id , tab_index ) - return the window object of the specifed tab
TLrAeB http://blog.numino.net/
Example:
AzTCBu http://blog.numino.net/
var oWin=external.get_tab(%max_security_id, 0);
z9BSzN http://blog.numino.net/
alert(oWin.document.URL);
d93w7r http://blog.numino.net/
8. activate_tab( security_id , tab_index ) - activate the specified tab
BaJvSH http://blog.numino.net/
Example:
is148h http://blog.numino.net/
external.activate_tab(%max_security_id, 0);
Yb7388 http://blog.numino.net/
9. close_tab( security_id , tab_index ) - close the specified tab
H1r2WJ http://blog.numino.net/
Example:
aC8I7R http://blog.numino.net/
external.close_tab(%max_security_id, 0);
uXPx4x http://blog.numino.net/
10. readFile( security_id, plugin_name, file_name) - read the content of specified text file
Xqos6h http://blog.numino.net/
Example:
nxvE7i http://blog.numino.net/
var sText=external.readFile(%max_security_id, 'ViewPage', 'readme.txt');
oP3aRr http://blog.numino.net/
alert(sText);
oG43TQ http://blog.numino.net/
11. writeFile( security_id, plugin_name, file_name, content ) - write content to the specific text file
gRuQV2 http://blog.numino.net/
Example:
tdD67V http://blog.numino.net/
external.writeFile(%max_security_id, 'ViewPage', 'test.txt', 'This is the file content');
AP4oNe http://blog.numino.net/
12. m2_readIni( security_id, plugin_name , file_name , section_name , key , default_value) - read data from specific INI file
VlMd2i http://blog.numino.net/
Example:
kXWtL0 http://blog.numino.net/
var sDownloadTool=external.m2_readIni(%max_security_id, 'ViewPage', 'plugin.ini', 'Settings', 'Tool', );
U5vaN0 http://blog.numino.net/
alert(sDownloadTool);
4kA20l http://blog.numino.net/
13. m2_writeIni( security_id , plugin_name , file_name , section_name , key , value ) - write data to specific INI file
vrAV50 http://blog.numino.net/
Example:
Y0aOxd http://blog.numino.net/
external.m2_writeIni(%max_security_id, 'ViewPage', 'test.ini', 'Config', 'height', '100px');
jUXUej http://blog.numino.net/
14. max_modelessDialog( security_id , url , option , attr , window ) - returns a modeless web page dialog
39VCfg http://blog.numino.net/
Example:
Du255h http://blog.numino.net/
var oDialog= external.max_modelessDialog( %max_security_id , 'blank.html', window , , window );
5PDqw1 http://blog.numino.net/
var oDoc=oDialog.document;
5UzEli http://blog.numino.net/
oDoc.write('Testing');
1pVLaJ http://blog.numino.net/
oDoc.close();
9eafhb http://blog.numino.net/
15. max_activex(security_id ,program_id) - return specified ActiveX object
21VgOI http://blog.numino.net/
Example:
FyrCWq http://blog.numino.net/
var oWSH=external.max_activex(%max_security_id, 'WScript.Shell');
7yIB7p http://blog.numino.net/
oWSH.run('notepad.exe');
9NMd5x http://blog.numino.net/
16. m2_search_text(security_id) - return the text in search bar
k9e9n1 http://blog.numino.net/
Example:
EpbiN9 http://blog.numino.net/
alert(m2_search_text(%max_security_id));
c7H2Wd http://blog.numino.net/
17. max_callback(event_name) - a function which is run when certain Maxthon events happen (for HTML button plugins and Script sidebar plugins)
wjwzON http://blog.numino.net/
HTML button plugins and Script sidebar plugins can implement the max_callback function for reacting to certain Maxthon browser events like switching to a different tab.
g2XBG7 http://blog.numino.net/
Example:
l14d0w http://blog.numino.net/
function max_callback(x){
aKVuB6 http://blog.numino.net/
if(x=='tab_change') alert('Current tab is changed.');
z4rf7w http://blog.numino.net/
}
0idu8f http://blog.numino.net/
By checking the parameter of the max_callback function, plugin can get the following browser events:
cYdfpT http://blog.numino.net/
HTML button plugins
wgHR63 http://blog.numino.net/
tab_change – after the current tab is switched
1SXPnN http://blog.numino.net/
document_Complete - after the current tab is fully loaded
6c2F40 http://blog.numino.net/
self_destroy - when the html is unloaded, usually when Maxthon exits
VGBt2Z http://blog.numino.net/
Script sidebar plugins
Y3Yj66 http://blog.numino.net/
sidebar_tab_change - after the current tab is switched
4Ddf5K http://blog.numino.net/
sidebar_activate - when the sidebar plugin is activated
8N4T4a http://blog.numino.net/
sidebar_deactivate - when the sidebar plugin is deactivated
l3lZne http://blog.numino.net/
sidebar_unload - when the sidebar plugin is unloaded (Maxthon is closed)
s4xj62 http://blog.numino.net/
18. max_getObj (for Maxthon 2.0 only) - return various Maxthon objects, including:
j0xcmD http://blog.numino.net/
Info - general information about Maxthon
arm186 http://blog.numino.net/
Adhunter – about Ad Hunter
I1V27c http://blog.numino.net/
FavManager – about Favorites
rOHdM6 http://blog.numino.net/
RssManager – about RSS
BjFJrq http://blog.numino.net/
PluginManager - about Plugins, for Maxthon 2.0.5 or later
INODZh http://blog.numino.net/
Example:
zi1l2C http://blog.numino.net/
var oInfo=external.max_getObj(%max_security_id, 'info');
ZIRafO http://blog.numino.net/
Info Object supports the following property and method:
C6MywM http://blog.numino.net/
Property:
Q1xNY0 http://blog.numino.net/
fileProxy - read-only, returns the path of the current user's proxy configuration document.
kA8Him http://blog.numino.net/
Example:
S584Ix http://blog.numino.net/
var oInfo=external.max_getObj(%max_security_id, 'info');
iuc50f http://blog.numino.net/
alert(oInfo.fileProxy);
q43NuS http://blog.numino.net/
folderUser - read-only, returns the path of the profile folder of the current user
jv2n0o http://blog.numino.net/
Example:
rs0arG http://blog.numino.net/
var oInfo=external.max_getObj(%max_security_id, 'info');
a95EgW http://blog.numino.net/
alert(oInfo. folderUser);
4sCS5f http://blog.numino.net/
Method:
4By4df http://blog.numino.net/
getFolderPluginData(plugin_name) - obtain the path of plugin data storage folder for the current user and the plugin
3PdXhp http://blog.numino.net/
Example:
zbC3yS http://blog.numino.net/
var oInfo=external.max_getObj(%max_security_id, 'info');
lft4Ww http://blog.numino.net/
alert(oInfo.getFolderPluginData('ViewSource!'));
Kk2cSD http://blog.numino.net/
AdHunter object support the following method:
TQzKDS http://blog.numino.net/
Method:
DR9Up7 http://blog.numino.net/
reloadFilter(filter_name) – reload the specified Maxthon filter (currently content filter only) after modifying the relevant filter
s8O5Kn http://blog.numino.net/
Example:
d8lb0o http://blog.numino.net/
var oAdHunter=external.max_getObj(%max_security_id, 'AdHunter');
xclrCV http://blog.numino.net/
oAdHunter.reloadFilter('content');
DB9ai3 http://blog.numino.net/
enableFilter(filter_name, bEnable) – enable or disable Maxthon's 'content' or 'popup' filter
RoAh9g http://blog.numino.net/
Example:
591ugU http://blog.numino.net/
var oAdHunter=external.max_getObj(%max_security_id, 'AdHunter');
9Z3da4 http://blog.numino.net/
oAdHunter.enableFilter ('content', false);
Y5yTl5 http://blog.numino.net/
PluginManager object support the following method:
DO6HZq http://blog.numino.net/
getPluginFolder - return Maxthon main plugin folder path
8CMq5d http://blog.numino.net/
Example:
07BAwu http://blog.numino.net/
var oPluginManager=external.max_getObj(%max_security_id, 'PluginManager');
TGg636 http://blog.numino.net/
alert(oPluginManager.getPluginFolder)
dDk31y http://blog.numino.net/
getCount - return the number of all installed plugins, both enabled and disabled
rijFWg http://blog.numino.net/
Example:
E6xE22 http://blog.numino.net/
var oPluginManager=external.max_getObj(%max_security_id, 'PluginManager');
x1u8J4 http://blog.numino.net/
alert(oPluginManager.getCount)
cRzhAw http://blog.numino.net/
getList - return a list which contains information like name, author etc of all plugins
dDFzfb http://blog.numino.net/
Example:
9cemHx http://blog.numino.net/
var oPluginManager=external.max_getObj(%max_security_id, 'PluginManager');
DMWkNt http://blog.numino.net/
alert(oPluginManager.getList)
6ISyhv http://blog.numino.net/
getPlugin(Index) - Index is a number, return the corresponding plugin object
18tpCo http://blog.numino.net/
Example:
dl5FHM http://blog.numino.net/
var oPluginManager=external.max_getObj(%max_security_id, 'PluginManager');
vduS9k http://blog.numino.net/
var oPlugin=oPluginManager.getPlugin(0);
HHg7QK http://blog.numino.net/
The plugin object returned from getPlugin(Index) supports the following property and method:
hvIpkR http://blog.numino.net/
Property:
8c5eRR http://blog.numino.net/
title - read only, return plugin name
aBWl0o http://blog.numino.net/
Example:
HcLddA http://blog.numino.net/
alert(oPlugin.title);
GZMEXZ http://blog.numino.net/
folderName - read only, return plugin's folder name
hPTvIc http://blog.numino.net/
Example:
742PZH http://blog.numino.net/
alert(oPlugin.folderName);
Kz68yR http://blog.numino.net/
fullPath - read only, return plugin folder's full path
K5n2um http://blog.numino.net/
Example:
XOMpNZ http://blog.numino.net/
alert(oPlugin.fullPath);
ZSXLVW http://blog.numino.net/
enable - read/write, return or set if the plugin is enabled
bUv7RM http://blog.numino.net/
Example:
B01G5J http://blog.numino.net/
oPlugin.enable=false;
o7903b http://blog.numino.net/
alert(oPlugin.enable);
ENf6K7 http://blog.numino.net/
oPlugin.enable=true;
3jYUyr http://blog.numino.net/
alert(oPlugin.enable);
0WgdF3 http://blog.numino.net/
startAfterPageDone - read/write, return or set if the plugin is auto started
L9TOy5 http://blog.numino.net/
Example:
XX2Boa http://blog.numino.net/
oPlugin.startAfterPageDone = true;
BqexXG http://blog.numino.net/
alert(oPlugin.startAfterPageDone);
4rw35C http://blog.numino.net/
oPlugin.startAfterPageDone = false;
9zWz6k http://blog.numino.net/
alert(oPlugin.startAfterPageDone);
IosbI7 http://blog.numino.net/
startAfterPageDoneUrl - read/write, return or set the address where the plugin will be auto started
67Gg1v http://blog.numino.net/
Example:
vxgudm http://blog.numino.net/
oPlugin.startAfterPageDoneUrl='*maxthon.com*|*maxthon.cn*';
VjgUwR http://blog.numino.net/
alert(oPlugin.startAfterPageDoneUrl);
4B7aOF http://blog.numino.net/
Methods:
Gc4q1E http://blog.numino.net/
config() - open plugin configuration dialog (config.html)
JK2GTa http://blog.numino.net/
Example:
7nfnyF http://blog.numino.net/
oPlugin.config();
PvhA4C http://blog.numino.net/
remove() - delete the plugin
X0BQDV http://blog.numino.net/
Example:
3ulteD http://blog.numino.net/
oPlugin.remove();
tuM7hu http://blog.numino.net/
[edit] Mscript
T5St25 http://blog.numino.net/
Maxthon 2.0 supports custom mscript in addition to normal script for script button plugins. Unlike normal script,mscript is not run on webpages and so mscript does not subject to security restrictions imposed on normal script, and does not need to worry about being exploit by webpages. mscript can greatly enhance the functionality of script plugins since mscript can operate with scripting disabled and mscript can access contents in cross domain frames. To use mscript in a Script button plugin, replace the <script...> tag with <mscript...>
27D4Eb http://blog.numino.net/
Example - the following script button plugin can disable scripting in the current page by changing Maxthon's content control:
11PkHM http://blog.numino.net/
<script language="javascript">
2NDB7L http://blog.numino.net/
external.m2_run_cmd(%max_security_id, 33175);
wYM8Ik http://blog.numino.net/
</script>
2E24g1 http://blog.numino.net/
But after scripting is disabled, the plugin cannot operate. So it cannot re-enable scripting in the current page. On the other hand the following mscript plugin can operate with scripting disabled, so it can renable scripting in the current page.
Vz3LjB http://blog.numino.net/
<mscript language="javascript">
QE6qug http://blog.numino.net/
external.m2_run_cmd(0, 33175);
IQflRi http://blog.numino.net/
</script>
078GcJ http://blog.numino.net/
Note an arbitrary number can be used as %max_security_id when mscript is used
更多相关内容...>>Maxthon Script Plugin Commands

Bug报告 |  免责声明 |  联系我们 |  加入收藏

Copyright © 2006 NuminoStudio(www.numino.net) All Rights Reserved