更多相关内容...>>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.
K9UFTJ http://blog.numino.net/
How to obtain the Security ID
aCTZAF http://blog.numino.net/
1. Script button plugins can use "%max_security_id" for the Security ID
ynczCD 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。
1Zz3Il http://blog.numino.net/
<script src=max.src></script>
LbdnL9 http://blog.numino.net/
Reference for Maxthon Plugin Commands
j4o4yM http://blog.numino.net/
Unless specified otherwise, the following plugin commands are applicable for both Maxthon 2.0 and Maxthon 1.X。
hgAqDC http://blog.numino.net/
1. max_version - return Maxthon's version number
g6TbME http://blog.numino.net/
Example:
vqtdQV http://blog.numino.net/
alert(external.max_version);
VeGR63 http://blog.numino.net/
2. max_language_id - return Maxthon's language ID
T463zD http://blog.numino.net/
Example:
yFj0nM http://blog.numino.net/
alert(external.max_language_id);
vwI6x2 http://blog.numino.net/
Note: Maxthon 2.0 and Maxthon 1.X have different language ID format
0F05Et http://blog.numino.net/
3. tab_count - return the number of tabs opened by Maxthon
aFvlsq http://blog.numino.net/
Example:
N7D8Z2 http://blog.numino.net/
alert(external.tab_count);
DIp0Ur http://blog.numino.net/
4. cur_sel - return the index of Maxthon's current tab
NIXDCe http://blog.numino.net/
Example:
V0icy5 http://blog.numino.net/
alert(external.cur_sel);
VY9t9c http://blog.numino.net/
5. m2_plugin_folder( security_id , plugin_name ) - return the folder path of the specified plugin
b2OrK6 http://blog.numino.net/
Example:
cma371 http://blog.numino.net/
alert(external.m2_plugin_folder( %max_security_id , 'ViewSource!'));
F11VA2 http://blog.numino.net/
6. m2_run_cmd( security_id , command_id ) - run the specified command ID
3k92Hv http://blog.numino.net/
Example:
oB0j2P http://blog.numino.net/
external. m2_run_cmd( %max_security_id , 32772 ));
Z5n9mp 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.
yH4ZJE http://blog.numino.net/
7. get_tab( security_id , tab_index ) - return the window object of the specifed tab
h7CIPu http://blog.numino.net/
Example:
gRdh38 http://blog.numino.net/
var oWin=external.get_tab(%max_security_id, 0);
4hwb8b http://blog.numino.net/
alert(oWin.document.URL);
yW1Jcd http://blog.numino.net/
8. activate_tab( security_id , tab_index ) - activate the specified tab
Xvx2CT http://blog.numino.net/
Example:
I89inB http://blog.numino.net/
external.activate_tab(%max_security_id, 0);
EK5P1f http://blog.numino.net/
9. close_tab( security_id , tab_index ) - close the specified tab
V49h7m http://blog.numino.net/
Example:
9W7GOY http://blog.numino.net/
external.close_tab(%max_security_id, 0);
112UL6 http://blog.numino.net/
10. readFile( security_id, plugin_name, file_name) - read the content of specified text file
dqBA7t http://blog.numino.net/
Example:
2W9MYh http://blog.numino.net/
var sText=external.readFile(%max_security_id, 'ViewPage', 'readme.txt');
2IlxUu http://blog.numino.net/
alert(sText);
685vah http://blog.numino.net/
11. writeFile( security_id, plugin_name, file_name, content ) - write content to the specific text file
UYoD0T http://blog.numino.net/
Example:
m9D4xk http://blog.numino.net/
external.writeFile(%max_security_id, 'ViewPage', 'test.txt', 'This is the file content');
Hf5kug http://blog.numino.net/
12. m2_readIni( security_id, plugin_name , file_name , section_name , key , default_value) - read data from specific INI file
d78CWl http://blog.numino.net/
Example:
LkP6UZ http://blog.numino.net/
var sDownloadTool=external.m2_readIni(%max_security_id, 'ViewPage', 'plugin.ini', 'Settings', 'Tool', );
194rCy http://blog.numino.net/
alert(sDownloadTool);
o49s47 http://blog.numino.net/
13. m2_writeIni( security_id , plugin_name , file_name , section_name , key , value ) - write data to specific INI file
HYvE37 http://blog.numino.net/
Example:
9mUE6Q http://blog.numino.net/
external.m2_writeIni(%max_security_id, 'ViewPage', 'test.ini', 'Config', 'height', '100px');
I77W3s http://blog.numino.net/
14. max_modelessDialog( security_id , url , option , attr , window ) - returns a modeless web page dialog
g25H6u http://blog.numino.net/
Example:
UtGPLT http://blog.numino.net/
var oDialog= external.max_modelessDialog( %max_security_id , 'blank.html', window , , window );
JEEgp6 http://blog.numino.net/
var oDoc=oDialog.document;
qV59lh http://blog.numino.net/
oDoc.write('Testing');
kWEdl7 http://blog.numino.net/
oDoc.close();
UkfcjI http://blog.numino.net/
15. max_activex(security_id ,program_id) - return specified ActiveX object
oEo9b7 http://blog.numino.net/
Example:
Qa178Z http://blog.numino.net/
var oWSH=external.max_activex(%max_security_id, 'WScript.Shell');
1O7Q5j http://blog.numino.net/
oWSH.run('notepad.exe');
s3UxKW http://blog.numino.net/
16. m2_search_text(security_id) - return the text in search bar
4DaR9a http://blog.numino.net/
Example:
w04BjK http://blog.numino.net/
alert(m2_search_text(%max_security_id));
3nHh6F 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)
VZWX8p 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.
DOQjtt http://blog.numino.net/
Example:
PwQCAZ http://blog.numino.net/
function max_callback(x){
D6US6a http://blog.numino.net/
if(x=='tab_change') alert('Current tab is changed.');
ajP0Px http://blog.numino.net/
}
bwz1pC http://blog.numino.net/
By checking the parameter of the max_callback function, plugin can get the following browser events:
U2M5EP http://blog.numino.net/
HTML button plugins
ki9K3W http://blog.numino.net/
tab_change – after the current tab is switched
kYbXUH http://blog.numino.net/
document_Complete - after the current tab is fully loaded
EYaRgy http://blog.numino.net/
self_destroy - when the html is unloaded, usually when Maxthon exits
5mceI0 http://blog.numino.net/
Script sidebar plugins
VYP104 http://blog.numino.net/
sidebar_tab_change - after the current tab is switched
fcKgdI http://blog.numino.net/
sidebar_activate - when the sidebar plugin is activated
rLyHbK http://blog.numino.net/
sidebar_deactivate - when the sidebar plugin is deactivated
6niRRy http://blog.numino.net/
sidebar_unload - when the sidebar plugin is unloaded (Maxthon is closed)
pxy2XG http://blog.numino.net/
18. max_getObj (for Maxthon 2.0 only) - return various Maxthon objects, including:
t0uXOR http://blog.numino.net/
Info - general information about Maxthon
6320Xk http://blog.numino.net/
Adhunter – about Ad Hunter
XexMh5 http://blog.numino.net/
FavManager – about Favorites
ra38YV http://blog.numino.net/
RssManager – about RSS
1i8GQi http://blog.numino.net/
PluginManager - about Plugins, for Maxthon 2.0.5 or later
g4zQW5 http://blog.numino.net/
Example:
85FfHg http://blog.numino.net/
var oInfo=external.max_getObj(%max_security_id, 'info');
ai8wi4 http://blog.numino.net/
Info Object supports the following property and method:
90I34I http://blog.numino.net/
Property:
1OiiCI http://blog.numino.net/
fileProxy - read-only, returns the path of the current user's proxy configuration document.
7U73w1 http://blog.numino.net/
Example:
tzgWoV http://blog.numino.net/
var oInfo=external.max_getObj(%max_security_id, 'info');
KJQC8O http://blog.numino.net/
alert(oInfo.fileProxy);
YsE9KS http://blog.numino.net/
folderUser - read-only, returns the path of the profile folder of the current user
N2Y4KY http://blog.numino.net/
Example:
TmkYO3 http://blog.numino.net/
var oInfo=external.max_getObj(%max_security_id, 'info');
KfgU2A http://blog.numino.net/
alert(oInfo. folderUser);
PlltJd http://blog.numino.net/
Method:
kvlFVU http://blog.numino.net/
getFolderPluginData(plugin_name) - obtain the path of plugin data storage folder for the current user and the plugin
3wZMYL http://blog.numino.net/
Example:
tEZk3Z http://blog.numino.net/
var oInfo=external.max_getObj(%max_security_id, 'info');
Sjc4Wy http://blog.numino.net/
alert(oInfo.getFolderPluginData('ViewSource!'));
RVaeMi http://blog.numino.net/
AdHunter object support the following method:
Harsnf http://blog.numino.net/
Method:
Svb0bg http://blog.numino.net/
reloadFilter(filter_name) – reload the specified Maxthon filter (currently content filter only) after modifying the relevant filter
HT9gzd http://blog.numino.net/
Example:
g9fAWl http://blog.numino.net/
var oAdHunter=external.max_getObj(%max_security_id, 'AdHunter');
EEZxft http://blog.numino.net/
oAdHunter.reloadFilter('content');
sn0lhj http://blog.numino.net/
enableFilter(filter_name, bEnable) – enable or disable Maxthon's 'content' or 'popup' filter
NRR6QC http://blog.numino.net/
Example:
IcI4V0 http://blog.numino.net/
var oAdHunter=external.max_getObj(%max_security_id, 'AdHunter');
uqBvJE http://blog.numino.net/
oAdHunter.enableFilter ('content', false);
i275qp http://blog.numino.net/
PluginManager object support the following method:
6H28wA http://blog.numino.net/
getPluginFolder - return Maxthon main plugin folder path
EdpCW5 http://blog.numino.net/
Example:
1oFUvD http://blog.numino.net/
var oPluginManager=external.max_getObj(%max_security_id, 'PluginManager');
RWszyS http://blog.numino.net/
alert(oPluginManager.getPluginFolder)
PM6ga9 http://blog.numino.net/
getCount - return the number of all installed plugins, both enabled and disabled
epNKfq http://blog.numino.net/
Example:
1II1es http://blog.numino.net/
var oPluginManager=external.max_getObj(%max_security_id, 'PluginManager');
eyH4jJ http://blog.numino.net/
alert(oPluginManager.getCount)
OaOpYj http://blog.numino.net/
getList - return a list which contains information like name, author etc of all plugins
QE6215 http://blog.numino.net/
Example:
w03gKK http://blog.numino.net/
var oPluginManager=external.max_getObj(%max_security_id, 'PluginManager');
yX147L http://blog.numino.net/
alert(oPluginManager.getList)
zq4nRc http://blog.numino.net/
getPlugin(Index) - Index is a number, return the corresponding plugin object
EqKwzw http://blog.numino.net/
Example:
23GaBv http://blog.numino.net/
var oPluginManager=external.max_getObj(%max_security_id, 'PluginManager');
HUkeeq http://blog.numino.net/
var oPlugin=oPluginManager.getPlugin(0);
72jsRP http://blog.numino.net/
The plugin object returned from getPlugin(Index) supports the following property and method:
Z2Ub6m http://blog.numino.net/
Property:
Y90Z2D http://blog.numino.net/
title - read only, return plugin name
hQg0tz http://blog.numino.net/
Example:
ABwkgW http://blog.numino.net/
alert(oPlugin.title);
QEOa6f http://blog.numino.net/
folderName - read only, return plugin's folder name
Y7npIt http://blog.numino.net/
Example:
3i142i http://blog.numino.net/
alert(oPlugin.folderName);
1lP17N http://blog.numino.net/
fullPath - read only, return plugin folder's full path
rwcr4l http://blog.numino.net/
Example:
5g033y http://blog.numino.net/
alert(oPlugin.fullPath);
BK45N2 http://blog.numino.net/
enable - read/write, return or set if the plugin is enabled
D969xH http://blog.numino.net/
Example:
2Chg3H http://blog.numino.net/
oPlugin.enable=false;
c1mxdc http://blog.numino.net/
alert(oPlugin.enable);
G6zXEp http://blog.numino.net/
oPlugin.enable=true;
116p08 http://blog.numino.net/
alert(oPlugin.enable);
Fb8u73 http://blog.numino.net/
startAfterPageDone - read/write, return or set if the plugin is auto started
4wLHSy http://blog.numino.net/
Example:
QI6AVt http://blog.numino.net/
oPlugin.startAfterPageDone = true;
C8Bk0k http://blog.numino.net/
alert(oPlugin.startAfterPageDone);
0qx1Xh http://blog.numino.net/
oPlugin.startAfterPageDone = false;
vHQxs9 http://blog.numino.net/
alert(oPlugin.startAfterPageDone);
2kNq8P http://blog.numino.net/
startAfterPageDoneUrl - read/write, return or set the address where the plugin will be auto started
3XL8x0 http://blog.numino.net/
Example:
dO008a http://blog.numino.net/
oPlugin.startAfterPageDoneUrl='*maxthon.com*|*maxthon.cn*';
uxQ0rr http://blog.numino.net/
alert(oPlugin.startAfterPageDoneUrl);
u0GbMi http://blog.numino.net/
Methods:
vAY2Cw http://blog.numino.net/
config() - open plugin configuration dialog (config.html)
z1yzzA http://blog.numino.net/
Example:
2PEkho http://blog.numino.net/
oPlugin.config();
6gKrFz http://blog.numino.net/
remove() - delete the plugin
YuSKwW http://blog.numino.net/
Example:
2JJ9C8 http://blog.numino.net/
oPlugin.remove();
04M1pn http://blog.numino.net/
[edit] Mscript
84jsw9 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...>
g1zoaC http://blog.numino.net/
Example - the following script button plugin can disable scripting in the current page by changing Maxthon's content control:
huTN83 http://blog.numino.net/
<script language="javascript">
6tbMN8 http://blog.numino.net/
external.m2_run_cmd(%max_security_id, 33175);
hfu6Sa http://blog.numino.net/
</script>
gRK8Jk 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.
o1JtR8 http://blog.numino.net/
<mscript language="javascript">
5Y2IDK http://blog.numino.net/
external.m2_run_cmd(0, 33175);
5274Ro http://blog.numino.net/
</script>
8wZ0cS 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