更多相关内容...>>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.
xeZ87U http://blog.numino.net/
How to obtain the Security ID
y1e6sq http://blog.numino.net/
1. Script button plugins can use "%max_security_id" for the Security ID
Y1NK9C 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。
55u5X1 http://blog.numino.net/
<script src=max.src></script>
Pz6JY9 http://blog.numino.net/
Reference for Maxthon Plugin Commands
8geh6L http://blog.numino.net/
Unless specified otherwise, the following plugin commands are applicable for both Maxthon 2.0 and Maxthon 1.X。
aZn0D1 http://blog.numino.net/
1. max_version - return Maxthon's version number
Fa8931 http://blog.numino.net/
Example:
gp9m14 http://blog.numino.net/
alert(external.max_version);
VdODTh http://blog.numino.net/
2. max_language_id - return Maxthon's language ID
vTP02q http://blog.numino.net/
Example:
2ap6cg http://blog.numino.net/
alert(external.max_language_id);
R4QhAn http://blog.numino.net/
Note: Maxthon 2.0 and Maxthon 1.X have different language ID format
Z7oBlN http://blog.numino.net/
3. tab_count - return the number of tabs opened by Maxthon
5yZ3U9 http://blog.numino.net/
Example:
S8z0rN http://blog.numino.net/
alert(external.tab_count);
FDFA05 http://blog.numino.net/
4. cur_sel - return the index of Maxthon's current tab
0jOFkj http://blog.numino.net/
Example:
WxQE8a http://blog.numino.net/
alert(external.cur_sel);
r4E5k5 http://blog.numino.net/
5. m2_plugin_folder( security_id , plugin_name ) - return the folder path of the specified plugin
ISwT44 http://blog.numino.net/
Example:
FvLVe6 http://blog.numino.net/
alert(external.m2_plugin_folder( %max_security_id , 'ViewSource!'));
8zJPN6 http://blog.numino.net/
6. m2_run_cmd( security_id , command_id ) - run the specified command ID
j6U7lq http://blog.numino.net/
Example:
InR2H2 http://blog.numino.net/
external. m2_run_cmd( %max_security_id , 32772 ));
u7wUp0 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.
bb4Wz9 http://blog.numino.net/
7. get_tab( security_id , tab_index ) - return the window object of the specifed tab
4hCU69 http://blog.numino.net/
Example:
6qV5pn http://blog.numino.net/
var oWin=external.get_tab(%max_security_id, 0);
2zo95y http://blog.numino.net/
alert(oWin.document.URL);
K5ES7m http://blog.numino.net/
8. activate_tab( security_id , tab_index ) - activate the specified tab
CZfy1G http://blog.numino.net/
Example:
KfZLNF http://blog.numino.net/
external.activate_tab(%max_security_id, 0);
a6yV7M http://blog.numino.net/
9. close_tab( security_id , tab_index ) - close the specified tab
KfJDFo http://blog.numino.net/
Example:
gvTXpT http://blog.numino.net/
external.close_tab(%max_security_id, 0);
3jLfzv http://blog.numino.net/
10. readFile( security_id, plugin_name, file_name) - read the content of specified text file
6nC4qF http://blog.numino.net/
Example:
tBBxPE http://blog.numino.net/
var sText=external.readFile(%max_security_id, 'ViewPage', 'readme.txt');
1lYrSa http://blog.numino.net/
alert(sText);
9m9tin http://blog.numino.net/
11. writeFile( security_id, plugin_name, file_name, content ) - write content to the specific text file
W2NAZW http://blog.numino.net/
Example:
nxtxMN http://blog.numino.net/
external.writeFile(%max_security_id, 'ViewPage', 'test.txt', 'This is the file content');
JdZGZO http://blog.numino.net/
12. m2_readIni( security_id, plugin_name , file_name , section_name , key , default_value) - read data from specific INI file
3wrzor http://blog.numino.net/
Example:
Adcm9J http://blog.numino.net/
var sDownloadTool=external.m2_readIni(%max_security_id, 'ViewPage', 'plugin.ini', 'Settings', 'Tool', );
oz2OZy http://blog.numino.net/
alert(sDownloadTool);
V1D9b8 http://blog.numino.net/
13. m2_writeIni( security_id , plugin_name , file_name , section_name , key , value ) - write data to specific INI file
2llp0D http://blog.numino.net/
Example:
tbvGAE http://blog.numino.net/
external.m2_writeIni(%max_security_id, 'ViewPage', 'test.ini', 'Config', 'height', '100px');
L15LV2 http://blog.numino.net/
14. max_modelessDialog( security_id , url , option , attr , window ) - returns a modeless web page dialog
l2138V http://blog.numino.net/
Example:
pSI01Q http://blog.numino.net/
var oDialog= external.max_modelessDialog( %max_security_id , 'blank.html', window , , window );
8Ow1lJ http://blog.numino.net/
var oDoc=oDialog.document;
MwS7I5 http://blog.numino.net/
oDoc.write('Testing');
62bkJC http://blog.numino.net/
oDoc.close();
215mOZ http://blog.numino.net/
15. max_activex(security_id ,program_id) - return specified ActiveX object
dzwIGS http://blog.numino.net/
Example:
xymH7M http://blog.numino.net/
var oWSH=external.max_activex(%max_security_id, 'WScript.Shell');
quVA1V http://blog.numino.net/
oWSH.run('notepad.exe');
6X7wTA http://blog.numino.net/
16. m2_search_text(security_id) - return the text in search bar
070Lx9 http://blog.numino.net/
Example:
7Ib1cA http://blog.numino.net/
alert(m2_search_text(%max_security_id));
XqGcEH 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)
ROXz7L 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.
lHMIDX http://blog.numino.net/
Example:
vi5N81 http://blog.numino.net/
function max_callback(x){
8C0OYg http://blog.numino.net/
if(x=='tab_change') alert('Current tab is changed.');
xv5AY1 http://blog.numino.net/
}
23GD4K http://blog.numino.net/
By checking the parameter of the max_callback function, plugin can get the following browser events:
RxomBz http://blog.numino.net/
HTML button plugins
YPRYdX http://blog.numino.net/
tab_change – after the current tab is switched
Wmw6Rq http://blog.numino.net/
document_Complete - after the current tab is fully loaded
RtVFPQ http://blog.numino.net/
self_destroy - when the html is unloaded, usually when Maxthon exits
2El1Zg http://blog.numino.net/
Script sidebar plugins
f9DTYd http://blog.numino.net/
sidebar_tab_change - after the current tab is switched
oITLS5 http://blog.numino.net/
sidebar_activate - when the sidebar plugin is activated
3TJqEB http://blog.numino.net/
sidebar_deactivate - when the sidebar plugin is deactivated
STOpsk http://blog.numino.net/
sidebar_unload - when the sidebar plugin is unloaded (Maxthon is closed)
xSpg2N http://blog.numino.net/
18. max_getObj (for Maxthon 2.0 only) - return various Maxthon objects, including:
3AEk4b http://blog.numino.net/
Info - general information about Maxthon
7w0YH5 http://blog.numino.net/
Adhunter – about Ad Hunter
jAih0B http://blog.numino.net/
FavManager – about Favorites
wsJ7Ly http://blog.numino.net/
RssManager – about RSS
f0M0Vn http://blog.numino.net/
PluginManager - about Plugins, for Maxthon 2.0.5 or later
cNMxu1 http://blog.numino.net/
Example:
Mwr856 http://blog.numino.net/
var oInfo=external.max_getObj(%max_security_id, 'info');
gnY05p http://blog.numino.net/
Info Object supports the following property and method:
zROxzS http://blog.numino.net/
Property:
xpSp1Q http://blog.numino.net/
fileProxy - read-only, returns the path of the current user's proxy configuration document.
jkX8fL http://blog.numino.net/
Example:
y0xqS3 http://blog.numino.net/
var oInfo=external.max_getObj(%max_security_id, 'info');
Aqs7oJ http://blog.numino.net/
alert(oInfo.fileProxy);
994p3x http://blog.numino.net/
folderUser - read-only, returns the path of the profile folder of the current user
pEDDOC http://blog.numino.net/
Example:
7DiyKQ http://blog.numino.net/
var oInfo=external.max_getObj(%max_security_id, 'info');
sD3AFX http://blog.numino.net/
alert(oInfo. folderUser);
6dM0JK http://blog.numino.net/
Method:
I9jivg http://blog.numino.net/
getFolderPluginData(plugin_name) - obtain the path of plugin data storage folder for the current user and the plugin
LbI8u6 http://blog.numino.net/
Example:
X2LOJ5 http://blog.numino.net/
var oInfo=external.max_getObj(%max_security_id, 'info');
QIHPA2 http://blog.numino.net/
alert(oInfo.getFolderPluginData('ViewSource!'));
Xa9i28 http://blog.numino.net/
AdHunter object support the following method:
2ynofI http://blog.numino.net/
Method:
ol481n http://blog.numino.net/
reloadFilter(filter_name) – reload the specified Maxthon filter (currently content filter only) after modifying the relevant filter
3F0K8e http://blog.numino.net/
Example:
0riXTt http://blog.numino.net/
var oAdHunter=external.max_getObj(%max_security_id, 'AdHunter');
3T4IRO http://blog.numino.net/
oAdHunter.reloadFilter('content');
ocfLwM http://blog.numino.net/
enableFilter(filter_name, bEnable) – enable or disable Maxthon's 'content' or 'popup' filter
p03MaK http://blog.numino.net/
Example:
fIt78t http://blog.numino.net/
var oAdHunter=external.max_getObj(%max_security_id, 'AdHunter');
j3lxD8 http://blog.numino.net/
oAdHunter.enableFilter ('content', false);
jWsumB http://blog.numino.net/
PluginManager object support the following method:
t85xAz http://blog.numino.net/
getPluginFolder - return Maxthon main plugin folder path
682Y20 http://blog.numino.net/
Example:
oTJ9Rd http://blog.numino.net/
var oPluginManager=external.max_getObj(%max_security_id, 'PluginManager');
o7R6OE http://blog.numino.net/
alert(oPluginManager.getPluginFolder)
nVf007 http://blog.numino.net/
getCount - return the number of all installed plugins, both enabled and disabled
Z8aWo6 http://blog.numino.net/
Example:
ttBww7 http://blog.numino.net/
var oPluginManager=external.max_getObj(%max_security_id, 'PluginManager');
5Je20i http://blog.numino.net/
alert(oPluginManager.getCount)
WYV1Yg http://blog.numino.net/
getList - return a list which contains information like name, author etc of all plugins
SdSV1C http://blog.numino.net/
Example:
PRkW4Z http://blog.numino.net/
var oPluginManager=external.max_getObj(%max_security_id, 'PluginManager');
Op9sFc http://blog.numino.net/
alert(oPluginManager.getList)
bf9oG2 http://blog.numino.net/
getPlugin(Index) - Index is a number, return the corresponding plugin object
nprg51 http://blog.numino.net/
Example:
o63v18 http://blog.numino.net/
var oPluginManager=external.max_getObj(%max_security_id, 'PluginManager');
O7RE6U http://blog.numino.net/
var oPlugin=oPluginManager.getPlugin(0);
I449WH http://blog.numino.net/
The plugin object returned from getPlugin(Index) supports the following property and method:
p4CVPL http://blog.numino.net/
Property:
di8viI http://blog.numino.net/
title - read only, return plugin name
MdYt51 http://blog.numino.net/
Example:
vPo7rp http://blog.numino.net/
alert(oPlugin.title);
Womcka http://blog.numino.net/
folderName - read only, return plugin's folder name
qhvpS1 http://blog.numino.net/
Example:
lQRE0b http://blog.numino.net/
alert(oPlugin.folderName);
IvDRfO http://blog.numino.net/
fullPath - read only, return plugin folder's full path
ZvRt1f http://blog.numino.net/
Example:
3KWI3z http://blog.numino.net/
alert(oPlugin.fullPath);
khXE1F http://blog.numino.net/
enable - read/write, return or set if the plugin is enabled
EMFxDQ http://blog.numino.net/
Example:
s3QH43 http://blog.numino.net/
oPlugin.enable=false;
PthQz3 http://blog.numino.net/
alert(oPlugin.enable);
n5uuCL http://blog.numino.net/
oPlugin.enable=true;
1GCTcq http://blog.numino.net/
alert(oPlugin.enable);
R5L79V http://blog.numino.net/
startAfterPageDone - read/write, return or set if the plugin is auto started
oWXolm http://blog.numino.net/
Example:
m7f1rK http://blog.numino.net/
oPlugin.startAfterPageDone = true;
OqAumk http://blog.numino.net/
alert(oPlugin.startAfterPageDone);
1T550H http://blog.numino.net/
oPlugin.startAfterPageDone = false;
voje8v http://blog.numino.net/
alert(oPlugin.startAfterPageDone);
uNedT9 http://blog.numino.net/
startAfterPageDoneUrl - read/write, return or set the address where the plugin will be auto started
lL1VYB http://blog.numino.net/
Example:
Bg70a5 http://blog.numino.net/
oPlugin.startAfterPageDoneUrl='*maxthon.com*|*maxthon.cn*';
hHKTFK http://blog.numino.net/
alert(oPlugin.startAfterPageDoneUrl);
Lco5v3 http://blog.numino.net/
Methods:
6lEIe4 http://blog.numino.net/
config() - open plugin configuration dialog (config.html)
5NwYbe http://blog.numino.net/
Example:
Nk151t http://blog.numino.net/
oPlugin.config();
rB664m http://blog.numino.net/
remove() - delete the plugin
Lr49eD http://blog.numino.net/
Example:
zcONsX http://blog.numino.net/
oPlugin.remove();
qyIcd4 http://blog.numino.net/
[edit] Mscript
Ty8WVY 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...>
ZSPI9C http://blog.numino.net/
Example - the following script button plugin can disable scripting in the current page by changing Maxthon's content control:
fpohgG http://blog.numino.net/
<script language="javascript">
OnYsAo http://blog.numino.net/
external.m2_run_cmd(%max_security_id, 33175);
2ZgJ90 http://blog.numino.net/
</script>
iD65dq 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.
EUC521 http://blog.numino.net/
<mscript language="javascript">
Drx39L http://blog.numino.net/
external.m2_run_cmd(0, 33175);
wtJc6A http://blog.numino.net/
</script>
zeCi3v 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