更多相关内容...>>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.
fKh7M0 http://blog.numino.net/
How to obtain the Security ID
pCFNyX http://blog.numino.net/
1. Script button plugins can use "%max_security_id" for the Security ID
hDs2r8 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。
hNy3sX http://blog.numino.net/
<script src=max.src></script>
q3QMzg http://blog.numino.net/
Reference for Maxthon Plugin Commands
VP9zzz http://blog.numino.net/
Unless specified otherwise, the following plugin commands are applicable for both Maxthon 2.0 and Maxthon 1.X。
lDf8Xc http://blog.numino.net/
1. max_version - return Maxthon's version number
SqA6kJ http://blog.numino.net/
Example:
1M9fBJ http://blog.numino.net/
alert(external.max_version);
WNEYVa http://blog.numino.net/
2. max_language_id - return Maxthon's language ID
s6l7LX http://blog.numino.net/
Example:
o2l4zU http://blog.numino.net/
alert(external.max_language_id);
1g5du4 http://blog.numino.net/
Note: Maxthon 2.0 and Maxthon 1.X have different language ID format
rX4LGG http://blog.numino.net/
3. tab_count - return the number of tabs opened by Maxthon
oJIu1J http://blog.numino.net/
Example:
GzwmJx http://blog.numino.net/
alert(external.tab_count);
Q2O8v8 http://blog.numino.net/
4. cur_sel - return the index of Maxthon's current tab
J6q5ww http://blog.numino.net/
Example:
9OkzQQ http://blog.numino.net/
alert(external.cur_sel);
R5prQM http://blog.numino.net/
5. m2_plugin_folder( security_id , plugin_name ) - return the folder path of the specified plugin
uky1T3 http://blog.numino.net/
Example:
ohAbgm http://blog.numino.net/
alert(external.m2_plugin_folder( %max_security_id , 'ViewSource!'));
Ws9z0j http://blog.numino.net/
6. m2_run_cmd( security_id , command_id ) - run the specified command ID
zpS39z http://blog.numino.net/
Example:
5h3Pfx http://blog.numino.net/
external. m2_run_cmd( %max_security_id , 32772 ));
G55Hf9 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.
KKFf6U http://blog.numino.net/
7. get_tab( security_id , tab_index ) - return the window object of the specifed tab
7DttG8 http://blog.numino.net/
Example:
0E97Z6 http://blog.numino.net/
var oWin=external.get_tab(%max_security_id, 0);
60FJUN http://blog.numino.net/
alert(oWin.document.URL);
dI6ty4 http://blog.numino.net/
8. activate_tab( security_id , tab_index ) - activate the specified tab
c4m3uc http://blog.numino.net/
Example:
cUna50 http://blog.numino.net/
external.activate_tab(%max_security_id, 0);
T4Xm7t http://blog.numino.net/
9. close_tab( security_id , tab_index ) - close the specified tab
56HauY http://blog.numino.net/
Example:
YiP0s4 http://blog.numino.net/
external.close_tab(%max_security_id, 0);
jXBniK http://blog.numino.net/
10. readFile( security_id, plugin_name, file_name) - read the content of specified text file
RoXvY5 http://blog.numino.net/
Example:
vNKWYu http://blog.numino.net/
var sText=external.readFile(%max_security_id, 'ViewPage', 'readme.txt');
Kth1yo http://blog.numino.net/
alert(sText);
367c85 http://blog.numino.net/
11. writeFile( security_id, plugin_name, file_name, content ) - write content to the specific text file
gNbWlb http://blog.numino.net/
Example:
UNoAEY http://blog.numino.net/
external.writeFile(%max_security_id, 'ViewPage', 'test.txt', 'This is the file content');
Tc7kCJ http://blog.numino.net/
12. m2_readIni( security_id, plugin_name , file_name , section_name , key , default_value) - read data from specific INI file
lxWn4m http://blog.numino.net/
Example:
eB9M63 http://blog.numino.net/
var sDownloadTool=external.m2_readIni(%max_security_id, 'ViewPage', 'plugin.ini', 'Settings', 'Tool', );
2bjZ3H http://blog.numino.net/
alert(sDownloadTool);
1Pq30b http://blog.numino.net/
13. m2_writeIni( security_id , plugin_name , file_name , section_name , key , value ) - write data to specific INI file
8f0kNt http://blog.numino.net/
Example:
tAEhO7 http://blog.numino.net/
external.m2_writeIni(%max_security_id, 'ViewPage', 'test.ini', 'Config', 'height', '100px');
DCIZFi http://blog.numino.net/
14. max_modelessDialog( security_id , url , option , attr , window ) - returns a modeless web page dialog
M1Hwh3 http://blog.numino.net/
Example:
hP0d8Z http://blog.numino.net/
var oDialog= external.max_modelessDialog( %max_security_id , 'blank.html', window , , window );
uLVKG2 http://blog.numino.net/
var oDoc=oDialog.document;
h9bOIg http://blog.numino.net/
oDoc.write('Testing');
176jvs http://blog.numino.net/
oDoc.close();
Zen1BV http://blog.numino.net/
15. max_activex(security_id ,program_id) - return specified ActiveX object
84sCrS http://blog.numino.net/
Example:
KE8Ma4 http://blog.numino.net/
var oWSH=external.max_activex(%max_security_id, 'WScript.Shell');
G86QTz http://blog.numino.net/
oWSH.run('notepad.exe');
x0NH63 http://blog.numino.net/
16. m2_search_text(security_id) - return the text in search bar
DOGZuA http://blog.numino.net/
Example:
r4Rtue http://blog.numino.net/
alert(m2_search_text(%max_security_id));
wCEwu4 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)
8AjG6l 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.
ve1bAd http://blog.numino.net/
Example:
ahRwC9 http://blog.numino.net/
function max_callback(x){
VB2PrO http://blog.numino.net/
if(x=='tab_change') alert('Current tab is changed.');
iJ7yyo http://blog.numino.net/
}
iW3n7c http://blog.numino.net/
By checking the parameter of the max_callback function, plugin can get the following browser events:
tMr8Dj http://blog.numino.net/
HTML button plugins
fczod5 http://blog.numino.net/
tab_change – after the current tab is switched
B5PXr7 http://blog.numino.net/
document_Complete - after the current tab is fully loaded
iYxWbP http://blog.numino.net/
self_destroy - when the html is unloaded, usually when Maxthon exits
7fPP88 http://blog.numino.net/
Script sidebar plugins
E9h8GW http://blog.numino.net/
sidebar_tab_change - after the current tab is switched
w0XkSZ http://blog.numino.net/
sidebar_activate - when the sidebar plugin is activated
PPrNx6 http://blog.numino.net/
sidebar_deactivate - when the sidebar plugin is deactivated
tliVGv http://blog.numino.net/
sidebar_unload - when the sidebar plugin is unloaded (Maxthon is closed)
5TxJ6P http://blog.numino.net/
18. max_getObj (for Maxthon 2.0 only) - return various Maxthon objects, including:
E39K84 http://blog.numino.net/
Info - general information about Maxthon
vG2Lwg http://blog.numino.net/
Adhunter – about Ad Hunter
Ms96xO http://blog.numino.net/
FavManager – about Favorites
Oy9rSi http://blog.numino.net/
RssManager – about RSS
sSrSsu http://blog.numino.net/
PluginManager - about Plugins, for Maxthon 2.0.5 or later
J3zjnC http://blog.numino.net/
Example:
gVdptW http://blog.numino.net/
var oInfo=external.max_getObj(%max_security_id, 'info');
0S3O0E http://blog.numino.net/
Info Object supports the following property and method:
3N1t8Y http://blog.numino.net/
Property:
2hmL0G http://blog.numino.net/
fileProxy - read-only, returns the path of the current user's proxy configuration document.
822rNf http://blog.numino.net/
Example:
d5AkQZ http://blog.numino.net/
var oInfo=external.max_getObj(%max_security_id, 'info');
rfwZsl http://blog.numino.net/
alert(oInfo.fileProxy);
2v9zg0 http://blog.numino.net/
folderUser - read-only, returns the path of the profile folder of the current user
6xzPR1 http://blog.numino.net/
Example:
C8tmZD http://blog.numino.net/
var oInfo=external.max_getObj(%max_security_id, 'info');
03EiJr http://blog.numino.net/
alert(oInfo. folderUser);
pC8pLX http://blog.numino.net/
Method:
dFyi14 http://blog.numino.net/
getFolderPluginData(plugin_name) - obtain the path of plugin data storage folder for the current user and the plugin
VReFhl http://blog.numino.net/
Example:
UeUt68 http://blog.numino.net/
var oInfo=external.max_getObj(%max_security_id, 'info');
GE9ta6 http://blog.numino.net/
alert(oInfo.getFolderPluginData('ViewSource!'));
nzpMM3 http://blog.numino.net/
AdHunter object support the following method:
PdS9uR http://blog.numino.net/
Method:
wf2Ztx http://blog.numino.net/
reloadFilter(filter_name) – reload the specified Maxthon filter (currently content filter only) after modifying the relevant filter
9ttwog http://blog.numino.net/
Example:
0aiv4R http://blog.numino.net/
var oAdHunter=external.max_getObj(%max_security_id, 'AdHunter');
6kFdOT http://blog.numino.net/
oAdHunter.reloadFilter('content');
784UYJ http://blog.numino.net/
enableFilter(filter_name, bEnable) – enable or disable Maxthon's 'content' or 'popup' filter
22f5RW http://blog.numino.net/
Example:
hYe9q6 http://blog.numino.net/
var oAdHunter=external.max_getObj(%max_security_id, 'AdHunter');
9yI8P0 http://blog.numino.net/
oAdHunter.enableFilter ('content', false);
lrqEcw http://blog.numino.net/
PluginManager object support the following method:
mujpRS http://blog.numino.net/
getPluginFolder - return Maxthon main plugin folder path
uKW66h http://blog.numino.net/
Example:
f9XL8B http://blog.numino.net/
var oPluginManager=external.max_getObj(%max_security_id, 'PluginManager');
4D3Im5 http://blog.numino.net/
alert(oPluginManager.getPluginFolder)
FqT6Sz http://blog.numino.net/
getCount - return the number of all installed plugins, both enabled and disabled
m0g9Zt http://blog.numino.net/
Example:
Rw1xVd http://blog.numino.net/
var oPluginManager=external.max_getObj(%max_security_id, 'PluginManager');
f1Gwrk http://blog.numino.net/
alert(oPluginManager.getCount)
Y7ug3S http://blog.numino.net/
getList - return a list which contains information like name, author etc of all plugins
7uCRAu http://blog.numino.net/
Example:
ihu1Af http://blog.numino.net/
var oPluginManager=external.max_getObj(%max_security_id, 'PluginManager');
mawvvT http://blog.numino.net/
alert(oPluginManager.getList)
aPNu1m http://blog.numino.net/
getPlugin(Index) - Index is a number, return the corresponding plugin object
i74P7P http://blog.numino.net/
Example:
5e9Lnh http://blog.numino.net/
var oPluginManager=external.max_getObj(%max_security_id, 'PluginManager');
P191B9 http://blog.numino.net/
var oPlugin=oPluginManager.getPlugin(0);
f0C2ag http://blog.numino.net/
The plugin object returned from getPlugin(Index) supports the following property and method:
2G7Ih5 http://blog.numino.net/
Property:
6E0Twm http://blog.numino.net/
title - read only, return plugin name
iaTpUa http://blog.numino.net/
Example:
M4Vq7L http://blog.numino.net/
alert(oPlugin.title);
NCYd4S http://blog.numino.net/
folderName - read only, return plugin's folder name
T7mOfj http://blog.numino.net/
Example:
YEFjiD http://blog.numino.net/
alert(oPlugin.folderName);
ubRjr0 http://blog.numino.net/
fullPath - read only, return plugin folder's full path
uqh3VT http://blog.numino.net/
Example:
L4yl2Y http://blog.numino.net/
alert(oPlugin.fullPath);
PQA15r http://blog.numino.net/
enable - read/write, return or set if the plugin is enabled
3Qx1ch http://blog.numino.net/
Example:
4mYfuZ http://blog.numino.net/
oPlugin.enable=false;
wnHriN http://blog.numino.net/
alert(oPlugin.enable);
KBT231 http://blog.numino.net/
oPlugin.enable=true;
fYml8E http://blog.numino.net/
alert(oPlugin.enable);
qK7x2U http://blog.numino.net/
startAfterPageDone - read/write, return or set if the plugin is auto started
QON4t2 http://blog.numino.net/
Example:
umZ66G http://blog.numino.net/
oPlugin.startAfterPageDone = true;
BNWUg0 http://blog.numino.net/
alert(oPlugin.startAfterPageDone);
MdLG7l http://blog.numino.net/
oPlugin.startAfterPageDone = false;
01CIdO http://blog.numino.net/
alert(oPlugin.startAfterPageDone);
OuUOEs http://blog.numino.net/
startAfterPageDoneUrl - read/write, return or set the address where the plugin will be auto started
lN7InB http://blog.numino.net/
Example:
iPj447 http://blog.numino.net/
oPlugin.startAfterPageDoneUrl='*maxthon.com*|*maxthon.cn*';
IKRqJ5 http://blog.numino.net/
alert(oPlugin.startAfterPageDoneUrl);
8l0GRv http://blog.numino.net/
Methods:
NEXOBa http://blog.numino.net/
config() - open plugin configuration dialog (config.html)
FjJqPJ http://blog.numino.net/
Example:
b8gE62 http://blog.numino.net/
oPlugin.config();
88HcQ1 http://blog.numino.net/
remove() - delete the plugin
ihnj1s http://blog.numino.net/
Example:
KHiG57 http://blog.numino.net/
oPlugin.remove();
Y8CO3r http://blog.numino.net/
[edit] Mscript
8et16h 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...>
F5k8fg http://blog.numino.net/
Example - the following script button plugin can disable scripting in the current page by changing Maxthon's content control:
Ol9BmW http://blog.numino.net/
<script language="javascript">
PPSYI6 http://blog.numino.net/
external.m2_run_cmd(%max_security_id, 33175);
h90Ut9 http://blog.numino.net/
</script>
diSYCv 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.
08BlAX http://blog.numino.net/
<mscript language="javascript">
Ajxvhd http://blog.numino.net/
external.m2_run_cmd(0, 33175);
YuHIGR http://blog.numino.net/
</script>
l5KLk8 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