更多相关内容...>>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.
G56j3Y http://blog.numino.net/
How to obtain the Security ID
nLX0q8 http://blog.numino.net/
1. Script button plugins can use "%max_security_id" for the Security ID
fLCl0h 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。
hR0NdJ http://blog.numino.net/
<script src=max.src></script>
BL7M3M http://blog.numino.net/
Reference for Maxthon Plugin Commands
817V78 http://blog.numino.net/
Unless specified otherwise, the following plugin commands are applicable for both Maxthon 2.0 and Maxthon 1.X。
4Dof9s http://blog.numino.net/
1. max_version - return Maxthon's version number
wiSa8b http://blog.numino.net/
Example:
q0d44E http://blog.numino.net/
alert(external.max_version);
k0L919 http://blog.numino.net/
2. max_language_id - return Maxthon's language ID
dKEp10 http://blog.numino.net/
Example:
r8X2xT http://blog.numino.net/
alert(external.max_language_id);
hiqGP7 http://blog.numino.net/
Note: Maxthon 2.0 and Maxthon 1.X have different language ID format
q1a2aC http://blog.numino.net/
3. tab_count - return the number of tabs opened by Maxthon
527gWR http://blog.numino.net/
Example:
WsD6Tx http://blog.numino.net/
alert(external.tab_count);
5SYnK6 http://blog.numino.net/
4. cur_sel - return the index of Maxthon's current tab
4Se3Jr http://blog.numino.net/
Example:
ZTTseG http://blog.numino.net/
alert(external.cur_sel);
3sWm1T http://blog.numino.net/
5. m2_plugin_folder( security_id , plugin_name ) - return the folder path of the specified plugin
9Ysm78 http://blog.numino.net/
Example:
XzEwFn http://blog.numino.net/
alert(external.m2_plugin_folder( %max_security_id , 'ViewSource!'));
14Ef4Q http://blog.numino.net/
6. m2_run_cmd( security_id , command_id ) - run the specified command ID
Ko5xSp http://blog.numino.net/
Example:
pwuNc6 http://blog.numino.net/
external. m2_run_cmd( %max_security_id , 32772 ));
T2TccF 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.
6PIyTp http://blog.numino.net/
7. get_tab( security_id , tab_index ) - return the window object of the specifed tab
2aPJ0s http://blog.numino.net/
Example:
2O854P http://blog.numino.net/
var oWin=external.get_tab(%max_security_id, 0);
doY47N http://blog.numino.net/
alert(oWin.document.URL);
8V957q http://blog.numino.net/
8. activate_tab( security_id , tab_index ) - activate the specified tab
K2uE5h http://blog.numino.net/
Example:
QAuX0r http://blog.numino.net/
external.activate_tab(%max_security_id, 0);
xv5KSe http://blog.numino.net/
9. close_tab( security_id , tab_index ) - close the specified tab
WOQQFs http://blog.numino.net/
Example:
8M9pCD http://blog.numino.net/
external.close_tab(%max_security_id, 0);
xOk5J2 http://blog.numino.net/
10. readFile( security_id, plugin_name, file_name) - read the content of specified text file
oC6JvZ http://blog.numino.net/
Example:
r8jmoA http://blog.numino.net/
var sText=external.readFile(%max_security_id, 'ViewPage', 'readme.txt');
gBjasu http://blog.numino.net/
alert(sText);
87QEv0 http://blog.numino.net/
11. writeFile( security_id, plugin_name, file_name, content ) - write content to the specific text file
oysa8m http://blog.numino.net/
Example:
0x6sU4 http://blog.numino.net/
external.writeFile(%max_security_id, 'ViewPage', 'test.txt', 'This is the file content');
Dz0Txn http://blog.numino.net/
12. m2_readIni( security_id, plugin_name , file_name , section_name , key , default_value) - read data from specific INI file
6566Y6 http://blog.numino.net/
Example:
7PgLS6 http://blog.numino.net/
var sDownloadTool=external.m2_readIni(%max_security_id, 'ViewPage', 'plugin.ini', 'Settings', 'Tool', );
zxRrv0 http://blog.numino.net/
alert(sDownloadTool);
2p4NRe http://blog.numino.net/
13. m2_writeIni( security_id , plugin_name , file_name , section_name , key , value ) - write data to specific INI file
ZH7d8c http://blog.numino.net/
Example:
7QJam0 http://blog.numino.net/
external.m2_writeIni(%max_security_id, 'ViewPage', 'test.ini', 'Config', 'height', '100px');
127i17 http://blog.numino.net/
14. max_modelessDialog( security_id , url , option , attr , window ) - returns a modeless web page dialog
a88pzi http://blog.numino.net/
Example:
04keA4 http://blog.numino.net/
var oDialog= external.max_modelessDialog( %max_security_id , 'blank.html', window , , window );
lCbe7y http://blog.numino.net/
var oDoc=oDialog.document;
4HWVeB http://blog.numino.net/
oDoc.write('Testing');
QXm92a http://blog.numino.net/
oDoc.close();
CSn96g http://blog.numino.net/
15. max_activex(security_id ,program_id) - return specified ActiveX object
G63zsR http://blog.numino.net/
Example:
pgm7Bu http://blog.numino.net/
var oWSH=external.max_activex(%max_security_id, 'WScript.Shell');
2S76GH http://blog.numino.net/
oWSH.run('notepad.exe');
NnvJS5 http://blog.numino.net/
16. m2_search_text(security_id) - return the text in search bar
NJcLL8 http://blog.numino.net/
Example:
AVzxY3 http://blog.numino.net/
alert(m2_search_text(%max_security_id));
4Zpu12 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)
1WNdLT 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.
mnFVxH http://blog.numino.net/
Example:
06m1X5 http://blog.numino.net/
function max_callback(x){
0neUE6 http://blog.numino.net/
if(x=='tab_change') alert('Current tab is changed.');
Van9LE http://blog.numino.net/
}
qX2HR1 http://blog.numino.net/
By checking the parameter of the max_callback function, plugin can get the following browser events:
w8R5YG http://blog.numino.net/
HTML button plugins
KZwof8 http://blog.numino.net/
tab_change – after the current tab is switched
fe198s http://blog.numino.net/
document_Complete - after the current tab is fully loaded
vGb0Sj http://blog.numino.net/
self_destroy - when the html is unloaded, usually when Maxthon exits
21bNj0 http://blog.numino.net/
Script sidebar plugins
D2v9Mt http://blog.numino.net/
sidebar_tab_change - after the current tab is switched
M4Xhv2 http://blog.numino.net/
sidebar_activate - when the sidebar plugin is activated
Diqwam http://blog.numino.net/
sidebar_deactivate - when the sidebar plugin is deactivated
5UPLvP http://blog.numino.net/
sidebar_unload - when the sidebar plugin is unloaded (Maxthon is closed)
RwNL99 http://blog.numino.net/
18. max_getObj (for Maxthon 2.0 only) - return various Maxthon objects, including:
l41B2i http://blog.numino.net/
Info - general information about Maxthon
6mcJ9A http://blog.numino.net/
Adhunter – about Ad Hunter
29iwy6 http://blog.numino.net/
FavManager – about Favorites
BjnPH4 http://blog.numino.net/
RssManager – about RSS
UZQ03g http://blog.numino.net/
PluginManager - about Plugins, for Maxthon 2.0.5 or later
LZGf6Q http://blog.numino.net/
Example:
ZaJd6b http://blog.numino.net/
var oInfo=external.max_getObj(%max_security_id, 'info');
79qL7G http://blog.numino.net/
Info Object supports the following property and method:
OL6Glu http://blog.numino.net/
Property:
W7682P http://blog.numino.net/
fileProxy - read-only, returns the path of the current user's proxy configuration document.
N570aq http://blog.numino.net/
Example:
JpO0hK http://blog.numino.net/
var oInfo=external.max_getObj(%max_security_id, 'info');
wc1a5T http://blog.numino.net/
alert(oInfo.fileProxy);
jCsD40 http://blog.numino.net/
folderUser - read-only, returns the path of the profile folder of the current user
4FVH25 http://blog.numino.net/
Example:
Ma4d6n http://blog.numino.net/
var oInfo=external.max_getObj(%max_security_id, 'info');
5CkZyW http://blog.numino.net/
alert(oInfo. folderUser);
PHT0Kq http://blog.numino.net/
Method:
B0AcxX http://blog.numino.net/
getFolderPluginData(plugin_name) - obtain the path of plugin data storage folder for the current user and the plugin
H7tpt0 http://blog.numino.net/
Example:
055227 http://blog.numino.net/
var oInfo=external.max_getObj(%max_security_id, 'info');
45lohT http://blog.numino.net/
alert(oInfo.getFolderPluginData('ViewSource!'));
pY58to http://blog.numino.net/
AdHunter object support the following method:
mY65jl http://blog.numino.net/
Method:
D6637I http://blog.numino.net/
reloadFilter(filter_name) – reload the specified Maxthon filter (currently content filter only) after modifying the relevant filter
trdyn8 http://blog.numino.net/
Example:
avhEeV http://blog.numino.net/
var oAdHunter=external.max_getObj(%max_security_id, 'AdHunter');
l3dEvJ http://blog.numino.net/
oAdHunter.reloadFilter('content');
6HkC35 http://blog.numino.net/
enableFilter(filter_name, bEnable) – enable or disable Maxthon's 'content' or 'popup' filter
eV8NO1 http://blog.numino.net/
Example:
u131b1 http://blog.numino.net/
var oAdHunter=external.max_getObj(%max_security_id, 'AdHunter');
03K1IO http://blog.numino.net/
oAdHunter.enableFilter ('content', false);
vMvtpa http://blog.numino.net/
PluginManager object support the following method:
B0Itch http://blog.numino.net/
getPluginFolder - return Maxthon main plugin folder path
2ROy5f http://blog.numino.net/
Example:
C1xz94 http://blog.numino.net/
var oPluginManager=external.max_getObj(%max_security_id, 'PluginManager');
hdNxny http://blog.numino.net/
alert(oPluginManager.getPluginFolder)
Cx18xI http://blog.numino.net/
getCount - return the number of all installed plugins, both enabled and disabled
suV91c http://blog.numino.net/
Example:
7vkz7L http://blog.numino.net/
var oPluginManager=external.max_getObj(%max_security_id, 'PluginManager');
ePx7wo http://blog.numino.net/
alert(oPluginManager.getCount)
lbp3AI http://blog.numino.net/
getList - return a list which contains information like name, author etc of all plugins
82sZOR http://blog.numino.net/
Example:
Y3Z3G4 http://blog.numino.net/
var oPluginManager=external.max_getObj(%max_security_id, 'PluginManager');
mSUnRd http://blog.numino.net/
alert(oPluginManager.getList)
4Rdssv http://blog.numino.net/
getPlugin(Index) - Index is a number, return the corresponding plugin object
14QO73 http://blog.numino.net/
Example:
9Xxa99 http://blog.numino.net/
var oPluginManager=external.max_getObj(%max_security_id, 'PluginManager');
0I6xtS http://blog.numino.net/
var oPlugin=oPluginManager.getPlugin(0);
9auXF0 http://blog.numino.net/
The plugin object returned from getPlugin(Index) supports the following property and method:
qLS1VU http://blog.numino.net/
Property:
Gh59FN http://blog.numino.net/
title - read only, return plugin name
Eej7y5 http://blog.numino.net/
Example:
fC31p1 http://blog.numino.net/
alert(oPlugin.title);
LX0VL3 http://blog.numino.net/
folderName - read only, return plugin's folder name
2gadDg http://blog.numino.net/
Example:
7hydfO http://blog.numino.net/
alert(oPlugin.folderName);
ljt0Jw http://blog.numino.net/
fullPath - read only, return plugin folder's full path
2Ut6XF http://blog.numino.net/
Example:
MDkl3p http://blog.numino.net/
alert(oPlugin.fullPath);
1p46L4 http://blog.numino.net/
enable - read/write, return or set if the plugin is enabled
Y4Fh0w http://blog.numino.net/
Example:
2JpGMb http://blog.numino.net/
oPlugin.enable=false;
1eKgBH http://blog.numino.net/
alert(oPlugin.enable);
w07sJd http://blog.numino.net/
oPlugin.enable=true;
vXuCll http://blog.numino.net/
alert(oPlugin.enable);
9GDJ8L http://blog.numino.net/
startAfterPageDone - read/write, return or set if the plugin is auto started
xNZAfz http://blog.numino.net/
Example:
x91VDo http://blog.numino.net/
oPlugin.startAfterPageDone = true;
R92Up2 http://blog.numino.net/
alert(oPlugin.startAfterPageDone);
JX05N4 http://blog.numino.net/
oPlugin.startAfterPageDone = false;
OUuMjp http://blog.numino.net/
alert(oPlugin.startAfterPageDone);
CdvPJl http://blog.numino.net/
startAfterPageDoneUrl - read/write, return or set the address where the plugin will be auto started
Oc3EZ8 http://blog.numino.net/
Example:
XbfAYd http://blog.numino.net/
oPlugin.startAfterPageDoneUrl='*maxthon.com*|*maxthon.cn*';
cQPH1N http://blog.numino.net/
alert(oPlugin.startAfterPageDoneUrl);
B2VgQk http://blog.numino.net/
Methods:
PeFx02 http://blog.numino.net/
config() - open plugin configuration dialog (config.html)
4kV0HE http://blog.numino.net/
Example:
choMcO http://blog.numino.net/
oPlugin.config();
fE5iPz http://blog.numino.net/
remove() - delete the plugin
IlM1RQ http://blog.numino.net/
Example:
a7xR76 http://blog.numino.net/
oPlugin.remove();
H276Vd http://blog.numino.net/
[edit] Mscript
m8xMO2 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...>
YstTV8 http://blog.numino.net/
Example - the following script button plugin can disable scripting in the current page by changing Maxthon's content control:
ZIzdj1 http://blog.numino.net/
<script language="javascript">
uSGoVg http://blog.numino.net/
external.m2_run_cmd(%max_security_id, 33175);
H2UBDl http://blog.numino.net/
</script>
kn9A6R 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.
86tLnq http://blog.numino.net/
<mscript language="javascript">
mlIon6 http://blog.numino.net/
external.m2_run_cmd(0, 33175);
YDs422 http://blog.numino.net/
</script>
to6ZSC 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