更多相关内容...>>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.
0c2k56 http://blog.numino.net/
How to obtain the Security ID
8x9Bqm http://blog.numino.net/
1. Script button plugins can use "%max_security_id" for the Security ID
76a41p 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。
7Q8E9u http://blog.numino.net/
<script src=max.src></script>
0Usrbe http://blog.numino.net/
Reference for Maxthon Plugin Commands
E6aW6i http://blog.numino.net/
Unless specified otherwise, the following plugin commands are applicable for both Maxthon 2.0 and Maxthon 1.X。
0v707Z http://blog.numino.net/
1. max_version - return Maxthon's version number
sZ6gLj http://blog.numino.net/
Example:
noyEst http://blog.numino.net/
alert(external.max_version);
1CVi8b http://blog.numino.net/
2. max_language_id - return Maxthon's language ID
Lt7fM4 http://blog.numino.net/
Example:
NbBkR2 http://blog.numino.net/
alert(external.max_language_id);
6dR66t http://blog.numino.net/
Note: Maxthon 2.0 and Maxthon 1.X have different language ID format
unAVRI http://blog.numino.net/
3. tab_count - return the number of tabs opened by Maxthon
NNQ3PE http://blog.numino.net/
Example:
51bG7r http://blog.numino.net/
alert(external.tab_count);
hdgCG9 http://blog.numino.net/
4. cur_sel - return the index of Maxthon's current tab
k6Gp8o http://blog.numino.net/
Example:
cpfzol http://blog.numino.net/
alert(external.cur_sel);
02OTdL http://blog.numino.net/
5. m2_plugin_folder( security_id , plugin_name ) - return the folder path of the specified plugin
AHX3Zc http://blog.numino.net/
Example:
q4zv90 http://blog.numino.net/
alert(external.m2_plugin_folder( %max_security_id , 'ViewSource!'));
SPMdeJ http://blog.numino.net/
6. m2_run_cmd( security_id , command_id ) - run the specified command ID
Z1tX7M http://blog.numino.net/
Example:
7DPjlw http://blog.numino.net/
external. m2_run_cmd( %max_security_id , 32772 ));
ICbG9r 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.
8qvsMV http://blog.numino.net/
7. get_tab( security_id , tab_index ) - return the window object of the specifed tab
RF1swz http://blog.numino.net/
Example:
XBEDHc http://blog.numino.net/
var oWin=external.get_tab(%max_security_id, 0);
1ifein http://blog.numino.net/
alert(oWin.document.URL);
gKR6hC http://blog.numino.net/
8. activate_tab( security_id , tab_index ) - activate the specified tab
6R451w http://blog.numino.net/
Example:
6QOeMZ http://blog.numino.net/
external.activate_tab(%max_security_id, 0);
689o6q http://blog.numino.net/
9. close_tab( security_id , tab_index ) - close the specified tab
vZ0fIZ http://blog.numino.net/
Example:
d7PJ1V http://blog.numino.net/
external.close_tab(%max_security_id, 0);
W1p6oQ http://blog.numino.net/
10. readFile( security_id, plugin_name, file_name) - read the content of specified text file
5tmveO http://blog.numino.net/
Example:
09yuz2 http://blog.numino.net/
var sText=external.readFile(%max_security_id, 'ViewPage', 'readme.txt');
YwCkHD http://blog.numino.net/
alert(sText);
b6S8st http://blog.numino.net/
11. writeFile( security_id, plugin_name, file_name, content ) - write content to the specific text file
9mnoOw http://blog.numino.net/
Example:
8mrHt0 http://blog.numino.net/
external.writeFile(%max_security_id, 'ViewPage', 'test.txt', 'This is the file content');
t3AxA9 http://blog.numino.net/
12. m2_readIni( security_id, plugin_name , file_name , section_name , key , default_value) - read data from specific INI file
c1c4rf http://blog.numino.net/
Example:
2ydLa3 http://blog.numino.net/
var sDownloadTool=external.m2_readIni(%max_security_id, 'ViewPage', 'plugin.ini', 'Settings', 'Tool', );
qOb5y5 http://blog.numino.net/
alert(sDownloadTool);
u86sb3 http://blog.numino.net/
13. m2_writeIni( security_id , plugin_name , file_name , section_name , key , value ) - write data to specific INI file
Lo1fds http://blog.numino.net/
Example:
DBjUMx http://blog.numino.net/
external.m2_writeIni(%max_security_id, 'ViewPage', 'test.ini', 'Config', 'height', '100px');
z5jo2u http://blog.numino.net/
14. max_modelessDialog( security_id , url , option , attr , window ) - returns a modeless web page dialog
P10Et5 http://blog.numino.net/
Example:
1j4zUa http://blog.numino.net/
var oDialog= external.max_modelessDialog( %max_security_id , 'blank.html', window , , window );
k0CRDj http://blog.numino.net/
var oDoc=oDialog.document;
z1b1X4 http://blog.numino.net/
oDoc.write('Testing');
x7n28n http://blog.numino.net/
oDoc.close();
RBC1mf http://blog.numino.net/
15. max_activex(security_id ,program_id) - return specified ActiveX object
BtLNIm http://blog.numino.net/
Example:
povBd2 http://blog.numino.net/
var oWSH=external.max_activex(%max_security_id, 'WScript.Shell');
k0p2yr http://blog.numino.net/
oWSH.run('notepad.exe');
ggGrBq http://blog.numino.net/
16. m2_search_text(security_id) - return the text in search bar
l8Wht9 http://blog.numino.net/
Example:
ss8zc6 http://blog.numino.net/
alert(m2_search_text(%max_security_id));
rQrKXW 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)
kJPRzQ 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.
QTy5gb http://blog.numino.net/
Example:
cuT828 http://blog.numino.net/
function max_callback(x){
TbbosE http://blog.numino.net/
if(x=='tab_change') alert('Current tab is changed.');
OtR1K1 http://blog.numino.net/
}
rLZ7LW http://blog.numino.net/
By checking the parameter of the max_callback function, plugin can get the following browser events:
1R7ZYH http://blog.numino.net/
HTML button plugins
eDlMVV http://blog.numino.net/
tab_change – after the current tab is switched
MxE9AR http://blog.numino.net/
document_Complete - after the current tab is fully loaded
jbc5Z5 http://blog.numino.net/
self_destroy - when the html is unloaded, usually when Maxthon exits
PpMiM6 http://blog.numino.net/
Script sidebar plugins
438v92 http://blog.numino.net/
sidebar_tab_change - after the current tab is switched
X00K1u http://blog.numino.net/
sidebar_activate - when the sidebar plugin is activated
X11J5h http://blog.numino.net/
sidebar_deactivate - when the sidebar plugin is deactivated
ZJVYYE http://blog.numino.net/
sidebar_unload - when the sidebar plugin is unloaded (Maxthon is closed)
Cp8tyn http://blog.numino.net/
18. max_getObj (for Maxthon 2.0 only) - return various Maxthon objects, including:
fBw34R http://blog.numino.net/
Info - general information about Maxthon
olh9B8 http://blog.numino.net/
Adhunter – about Ad Hunter
LCXxxb http://blog.numino.net/
FavManager – about Favorites
42qXJE http://blog.numino.net/
RssManager – about RSS
YiouFs http://blog.numino.net/
PluginManager - about Plugins, for Maxthon 2.0.5 or later
JptyAF http://blog.numino.net/
Example:
T4qS71 http://blog.numino.net/
var oInfo=external.max_getObj(%max_security_id, 'info');
aXHBqA http://blog.numino.net/
Info Object supports the following property and method:
GxbK09 http://blog.numino.net/
Property:
Mux7P0 http://blog.numino.net/
fileProxy - read-only, returns the path of the current user's proxy configuration document.
EjG840 http://blog.numino.net/
Example:
cN7N86 http://blog.numino.net/
var oInfo=external.max_getObj(%max_security_id, 'info');
5Tj83h http://blog.numino.net/
alert(oInfo.fileProxy);
9CJ7HI http://blog.numino.net/
folderUser - read-only, returns the path of the profile folder of the current user
ItCXzF http://blog.numino.net/
Example:
cFqGEb http://blog.numino.net/
var oInfo=external.max_getObj(%max_security_id, 'info');
o6DuR4 http://blog.numino.net/
alert(oInfo. folderUser);
55NLeN http://blog.numino.net/
Method:
mkEUBQ http://blog.numino.net/
getFolderPluginData(plugin_name) - obtain the path of plugin data storage folder for the current user and the plugin
BYTWTN http://blog.numino.net/
Example:
w47YgD http://blog.numino.net/
var oInfo=external.max_getObj(%max_security_id, 'info');
S0aimD http://blog.numino.net/
alert(oInfo.getFolderPluginData('ViewSource!'));
5PYmhd http://blog.numino.net/
AdHunter object support the following method:
QXqte0 http://blog.numino.net/
Method:
rO3F9j http://blog.numino.net/
reloadFilter(filter_name) – reload the specified Maxthon filter (currently content filter only) after modifying the relevant filter
z42h4r http://blog.numino.net/
Example:
oP411w http://blog.numino.net/
var oAdHunter=external.max_getObj(%max_security_id, 'AdHunter');
5907xG http://blog.numino.net/
oAdHunter.reloadFilter('content');
qNpDIL http://blog.numino.net/
enableFilter(filter_name, bEnable) – enable or disable Maxthon's 'content' or 'popup' filter
e70RY9 http://blog.numino.net/
Example:
5JE1bX http://blog.numino.net/
var oAdHunter=external.max_getObj(%max_security_id, 'AdHunter');
tuVZhp http://blog.numino.net/
oAdHunter.enableFilter ('content', false);
2dq27t http://blog.numino.net/
PluginManager object support the following method:
u4dm4G http://blog.numino.net/
getPluginFolder - return Maxthon main plugin folder path
5UCHQU http://blog.numino.net/
Example:
P24wkr http://blog.numino.net/
var oPluginManager=external.max_getObj(%max_security_id, 'PluginManager');
2mBUYj http://blog.numino.net/
alert(oPluginManager.getPluginFolder)
j2uKat http://blog.numino.net/
getCount - return the number of all installed plugins, both enabled and disabled
JFO9U7 http://blog.numino.net/
Example:
Ny9GBU http://blog.numino.net/
var oPluginManager=external.max_getObj(%max_security_id, 'PluginManager');
UbD1iJ http://blog.numino.net/
alert(oPluginManager.getCount)
wYS7C6 http://blog.numino.net/
getList - return a list which contains information like name, author etc of all plugins
Q3xdAf http://blog.numino.net/
Example:
d9Z32H http://blog.numino.net/
var oPluginManager=external.max_getObj(%max_security_id, 'PluginManager');
3tgaFN http://blog.numino.net/
alert(oPluginManager.getList)
HCGVMg http://blog.numino.net/
getPlugin(Index) - Index is a number, return the corresponding plugin object
0Sc3px http://blog.numino.net/
Example:
DH470C http://blog.numino.net/
var oPluginManager=external.max_getObj(%max_security_id, 'PluginManager');
41LnkJ http://blog.numino.net/
var oPlugin=oPluginManager.getPlugin(0);
EZ4Q4V http://blog.numino.net/
The plugin object returned from getPlugin(Index) supports the following property and method:
YLJodL http://blog.numino.net/
Property:
Hb6T74 http://blog.numino.net/
title - read only, return plugin name
90Hbal http://blog.numino.net/
Example:
R1Mt4i http://blog.numino.net/
alert(oPlugin.title);
XV04LR http://blog.numino.net/
folderName - read only, return plugin's folder name
f07cb6 http://blog.numino.net/
Example:
45ODI4 http://blog.numino.net/
alert(oPlugin.folderName);
z1ue24 http://blog.numino.net/
fullPath - read only, return plugin folder's full path
0B8oyR http://blog.numino.net/
Example:
u3jO6q http://blog.numino.net/
alert(oPlugin.fullPath);
Y4kD65 http://blog.numino.net/
enable - read/write, return or set if the plugin is enabled
rnmYUu http://blog.numino.net/
Example:
mY5sDe http://blog.numino.net/
oPlugin.enable=false;
LAGYU7 http://blog.numino.net/
alert(oPlugin.enable);
w1xowa http://blog.numino.net/
oPlugin.enable=true;
6Aejc2 http://blog.numino.net/
alert(oPlugin.enable);
81Whr8 http://blog.numino.net/
startAfterPageDone - read/write, return or set if the plugin is auto started
MMp9e4 http://blog.numino.net/
Example:
gyu9wI http://blog.numino.net/
oPlugin.startAfterPageDone = true;
bUnCh7 http://blog.numino.net/
alert(oPlugin.startAfterPageDone);
942T0r http://blog.numino.net/
oPlugin.startAfterPageDone = false;
kX1VsC http://blog.numino.net/
alert(oPlugin.startAfterPageDone);
m4kN32 http://blog.numino.net/
startAfterPageDoneUrl - read/write, return or set the address where the plugin will be auto started
CKlFm8 http://blog.numino.net/
Example:
Q4z67W http://blog.numino.net/
oPlugin.startAfterPageDoneUrl='*maxthon.com*|*maxthon.cn*';
sBT2nn http://blog.numino.net/
alert(oPlugin.startAfterPageDoneUrl);
rIwVub http://blog.numino.net/
Methods:
MYJ28R http://blog.numino.net/
config() - open plugin configuration dialog (config.html)
FA7sll http://blog.numino.net/
Example:
skTF6K http://blog.numino.net/
oPlugin.config();
zJKBeU http://blog.numino.net/
remove() - delete the plugin
f71oUz http://blog.numino.net/
Example:
02twd4 http://blog.numino.net/
oPlugin.remove();
d38wN0 http://blog.numino.net/
[edit] Mscript
ksQ2k2 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...>
LQP7UB http://blog.numino.net/
Example - the following script button plugin can disable scripting in the current page by changing Maxthon's content control:
eNRc4q http://blog.numino.net/
<script language="javascript">
cuoUy4 http://blog.numino.net/
external.m2_run_cmd(%max_security_id, 33175);
1WREO3 http://blog.numino.net/
</script>
usXPH8 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.
k7636i http://blog.numino.net/
<mscript language="javascript">
a2808s http://blog.numino.net/
external.m2_run_cmd(0, 33175);
9GWsKl http://blog.numino.net/
</script>
F7uR4Z 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