更多相关内容...>>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.
neQ58a http://blog.numino.net/
How to obtain the Security ID
F19619 http://blog.numino.net/
1. Script button plugins can use "%max_security_id" for the Security ID
p97m05 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。
6j5r93 http://blog.numino.net/
<script src=max.src></script>
WFdNhO http://blog.numino.net/
Reference for Maxthon Plugin Commands
tKn5LP http://blog.numino.net/
Unless specified otherwise, the following plugin commands are applicable for both Maxthon 2.0 and Maxthon 1.X。
5jyT16 http://blog.numino.net/
1. max_version - return Maxthon's version number
PmF4O5 http://blog.numino.net/
Example:
NXr5Bf http://blog.numino.net/
alert(external.max_version);
133n3c http://blog.numino.net/
2. max_language_id - return Maxthon's language ID
Df2ZIy http://blog.numino.net/
Example:
GWaSCw http://blog.numino.net/
alert(external.max_language_id);
a9VnKk http://blog.numino.net/
Note: Maxthon 2.0 and Maxthon 1.X have different language ID format
bj1tZE http://blog.numino.net/
3. tab_count - return the number of tabs opened by Maxthon
8N0IV3 http://blog.numino.net/
Example:
2bNwFx http://blog.numino.net/
alert(external.tab_count);
Cam4Pb http://blog.numino.net/
4. cur_sel - return the index of Maxthon's current tab
PA7fNy http://blog.numino.net/
Example:
60peOv http://blog.numino.net/
alert(external.cur_sel);
6S8Sxd http://blog.numino.net/
5. m2_plugin_folder( security_id , plugin_name ) - return the folder path of the specified plugin
ENfNNC http://blog.numino.net/
Example:
gW5f7w http://blog.numino.net/
alert(external.m2_plugin_folder( %max_security_id , 'ViewSource!'));
tW9kBs http://blog.numino.net/
6. m2_run_cmd( security_id , command_id ) - run the specified command ID
KLdMGx http://blog.numino.net/
Example:
08cLw0 http://blog.numino.net/
external. m2_run_cmd( %max_security_id , 32772 ));
0H65L3 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.
WI9aZ4 http://blog.numino.net/
7. get_tab( security_id , tab_index ) - return the window object of the specifed tab
uPPNmj http://blog.numino.net/
Example:
CnCK9V http://blog.numino.net/
var oWin=external.get_tab(%max_security_id, 0);
Rqvdhx http://blog.numino.net/
alert(oWin.document.URL);
8oi5FD http://blog.numino.net/
8. activate_tab( security_id , tab_index ) - activate the specified tab
8p38Yk http://blog.numino.net/
Example:
5Mfc40 http://blog.numino.net/
external.activate_tab(%max_security_id, 0);
GftD1l http://blog.numino.net/
9. close_tab( security_id , tab_index ) - close the specified tab
xJDxBM http://blog.numino.net/
Example:
Lr0kae http://blog.numino.net/
external.close_tab(%max_security_id, 0);
C8C27H http://blog.numino.net/
10. readFile( security_id, plugin_name, file_name) - read the content of specified text file
X43wKg http://blog.numino.net/
Example:
17OpPT http://blog.numino.net/
var sText=external.readFile(%max_security_id, 'ViewPage', 'readme.txt');
DJRQYC http://blog.numino.net/
alert(sText);
4u71Y5 http://blog.numino.net/
11. writeFile( security_id, plugin_name, file_name, content ) - write content to the specific text file
13zJpr http://blog.numino.net/
Example:
lbJbHT http://blog.numino.net/
external.writeFile(%max_security_id, 'ViewPage', 'test.txt', 'This is the file content');
EPI5JR http://blog.numino.net/
12. m2_readIni( security_id, plugin_name , file_name , section_name , key , default_value) - read data from specific INI file
Xdpnv7 http://blog.numino.net/
Example:
n3EkT7 http://blog.numino.net/
var sDownloadTool=external.m2_readIni(%max_security_id, 'ViewPage', 'plugin.ini', 'Settings', 'Tool', );
m5euEq http://blog.numino.net/
alert(sDownloadTool);
5E8nN7 http://blog.numino.net/
13. m2_writeIni( security_id , plugin_name , file_name , section_name , key , value ) - write data to specific INI file
BYZjd9 http://blog.numino.net/
Example:
OaB5FI http://blog.numino.net/
external.m2_writeIni(%max_security_id, 'ViewPage', 'test.ini', 'Config', 'height', '100px');
27sw6y http://blog.numino.net/
14. max_modelessDialog( security_id , url , option , attr , window ) - returns a modeless web page dialog
rKGEk9 http://blog.numino.net/
Example:
CYMkW1 http://blog.numino.net/
var oDialog= external.max_modelessDialog( %max_security_id , 'blank.html', window , , window );
9e8lX8 http://blog.numino.net/
var oDoc=oDialog.document;
61D5xB http://blog.numino.net/
oDoc.write('Testing');
V9rOur http://blog.numino.net/
oDoc.close();
y8Yf6U http://blog.numino.net/
15. max_activex(security_id ,program_id) - return specified ActiveX object
Y5u2wm http://blog.numino.net/
Example:
GLBOvd http://blog.numino.net/
var oWSH=external.max_activex(%max_security_id, 'WScript.Shell');
5AqwFn http://blog.numino.net/
oWSH.run('notepad.exe');
gOHb0F http://blog.numino.net/
16. m2_search_text(security_id) - return the text in search bar
610rox http://blog.numino.net/
Example:
aXql24 http://blog.numino.net/
alert(m2_search_text(%max_security_id));
0eUr44 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)
K3tFn6 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.
6fBOqJ http://blog.numino.net/
Example:
Ut49a2 http://blog.numino.net/
function max_callback(x){
yi4s1p http://blog.numino.net/
if(x=='tab_change') alert('Current tab is changed.');
uGf9G9 http://blog.numino.net/
}
31I13A http://blog.numino.net/
By checking the parameter of the max_callback function, plugin can get the following browser events:
6hcUEW http://blog.numino.net/
HTML button plugins
InEebU http://blog.numino.net/
tab_change – after the current tab is switched
234u2K http://blog.numino.net/
document_Complete - after the current tab is fully loaded
wflOCL http://blog.numino.net/
self_destroy - when the html is unloaded, usually when Maxthon exits
CdLzDd http://blog.numino.net/
Script sidebar plugins
oXsP9q http://blog.numino.net/
sidebar_tab_change - after the current tab is switched
PmoUyO http://blog.numino.net/
sidebar_activate - when the sidebar plugin is activated
XSl2k5 http://blog.numino.net/
sidebar_deactivate - when the sidebar plugin is deactivated
qDH61L http://blog.numino.net/
sidebar_unload - when the sidebar plugin is unloaded (Maxthon is closed)
W94bm9 http://blog.numino.net/
18. max_getObj (for Maxthon 2.0 only) - return various Maxthon objects, including:
55j6O2 http://blog.numino.net/
Info - general information about Maxthon
vQb55l http://blog.numino.net/
Adhunter – about Ad Hunter
b3a7T2 http://blog.numino.net/
FavManager – about Favorites
cBIuEn http://blog.numino.net/
RssManager – about RSS
tur0N8 http://blog.numino.net/
PluginManager - about Plugins, for Maxthon 2.0.5 or later
31Sw9X http://blog.numino.net/
Example:
87W83y http://blog.numino.net/
var oInfo=external.max_getObj(%max_security_id, 'info');
q1yP1M http://blog.numino.net/
Info Object supports the following property and method:
GJzLCp http://blog.numino.net/
Property:
3mRk0q http://blog.numino.net/
fileProxy - read-only, returns the path of the current user's proxy configuration document.
O2yWhP http://blog.numino.net/
Example:
kjv9aB http://blog.numino.net/
var oInfo=external.max_getObj(%max_security_id, 'info');
j7vrDn http://blog.numino.net/
alert(oInfo.fileProxy);
SCcMB4 http://blog.numino.net/
folderUser - read-only, returns the path of the profile folder of the current user
oHs89B http://blog.numino.net/
Example:
H92D9f http://blog.numino.net/
var oInfo=external.max_getObj(%max_security_id, 'info');
D6P8yP http://blog.numino.net/
alert(oInfo. folderUser);
4y547q http://blog.numino.net/
Method:
0DuIMH http://blog.numino.net/
getFolderPluginData(plugin_name) - obtain the path of plugin data storage folder for the current user and the plugin
8Hl0s7 http://blog.numino.net/
Example:
pV8z6h http://blog.numino.net/
var oInfo=external.max_getObj(%max_security_id, 'info');
Teix12 http://blog.numino.net/
alert(oInfo.getFolderPluginData('ViewSource!'));
Isl6xb http://blog.numino.net/
AdHunter object support the following method:
U2IwC2 http://blog.numino.net/
Method:
696ve2 http://blog.numino.net/
reloadFilter(filter_name) – reload the specified Maxthon filter (currently content filter only) after modifying the relevant filter
6Ifw7A http://blog.numino.net/
Example:
Q5i2q7 http://blog.numino.net/
var oAdHunter=external.max_getObj(%max_security_id, 'AdHunter');
JVuvaN http://blog.numino.net/
oAdHunter.reloadFilter('content');
J9JTSJ http://blog.numino.net/
enableFilter(filter_name, bEnable) – enable or disable Maxthon's 'content' or 'popup' filter
o9ycxd http://blog.numino.net/
Example:
Z0ObUQ http://blog.numino.net/
var oAdHunter=external.max_getObj(%max_security_id, 'AdHunter');
hpYE02 http://blog.numino.net/
oAdHunter.enableFilter ('content', false);
TGrdqi http://blog.numino.net/
PluginManager object support the following method:
3nNPB0 http://blog.numino.net/
getPluginFolder - return Maxthon main plugin folder path
LHR6C8 http://blog.numino.net/
Example:
LqqHWF http://blog.numino.net/
var oPluginManager=external.max_getObj(%max_security_id, 'PluginManager');
GHNHHF http://blog.numino.net/
alert(oPluginManager.getPluginFolder)
fUzY4Q http://blog.numino.net/
getCount - return the number of all installed plugins, both enabled and disabled
KT59Ok http://blog.numino.net/
Example:
nvjQ5u http://blog.numino.net/
var oPluginManager=external.max_getObj(%max_security_id, 'PluginManager');
d3elvA http://blog.numino.net/
alert(oPluginManager.getCount)
tjCuZb http://blog.numino.net/
getList - return a list which contains information like name, author etc of all plugins
HaF4E9 http://blog.numino.net/
Example:
6flST7 http://blog.numino.net/
var oPluginManager=external.max_getObj(%max_security_id, 'PluginManager');
hsJ6Cl http://blog.numino.net/
alert(oPluginManager.getList)
a22ppR http://blog.numino.net/
getPlugin(Index) - Index is a number, return the corresponding plugin object
BCsjsC http://blog.numino.net/
Example:
74Krh5 http://blog.numino.net/
var oPluginManager=external.max_getObj(%max_security_id, 'PluginManager');
JLcYqf http://blog.numino.net/
var oPlugin=oPluginManager.getPlugin(0);
eb7WEJ http://blog.numino.net/
The plugin object returned from getPlugin(Index) supports the following property and method:
B7jbgd http://blog.numino.net/
Property:
4TrAJ2 http://blog.numino.net/
title - read only, return plugin name
rpLSUA http://blog.numino.net/
Example:
iZi4b8 http://blog.numino.net/
alert(oPlugin.title);
kVwo5m http://blog.numino.net/
folderName - read only, return plugin's folder name
epzCAt http://blog.numino.net/
Example:
18E9VX http://blog.numino.net/
alert(oPlugin.folderName);
YBSdU7 http://blog.numino.net/
fullPath - read only, return plugin folder's full path
3mEZj4 http://blog.numino.net/
Example:
qf7H2l http://blog.numino.net/
alert(oPlugin.fullPath);
27pLkn http://blog.numino.net/
enable - read/write, return or set if the plugin is enabled
aEHCPw http://blog.numino.net/
Example:
fSyzPc http://blog.numino.net/
oPlugin.enable=false;
1TVxc3 http://blog.numino.net/
alert(oPlugin.enable);
H1gnr1 http://blog.numino.net/
oPlugin.enable=true;
ESq92B http://blog.numino.net/
alert(oPlugin.enable);
XpgbgI http://blog.numino.net/
startAfterPageDone - read/write, return or set if the plugin is auto started
Su6yF3 http://blog.numino.net/
Example:
BpVQ3v http://blog.numino.net/
oPlugin.startAfterPageDone = true;
RrTxKP http://blog.numino.net/
alert(oPlugin.startAfterPageDone);
690guI http://blog.numino.net/
oPlugin.startAfterPageDone = false;
wiz06G http://blog.numino.net/
alert(oPlugin.startAfterPageDone);
k1Yui2 http://blog.numino.net/
startAfterPageDoneUrl - read/write, return or set the address where the plugin will be auto started
Gr9994 http://blog.numino.net/
Example:
9B0dFq http://blog.numino.net/
oPlugin.startAfterPageDoneUrl='*maxthon.com*|*maxthon.cn*';
7LS8Lb http://blog.numino.net/
alert(oPlugin.startAfterPageDoneUrl);
2F6aMN http://blog.numino.net/
Methods:
M4GBu1 http://blog.numino.net/
config() - open plugin configuration dialog (config.html)
dxZMO8 http://blog.numino.net/
Example:
jtNcs6 http://blog.numino.net/
oPlugin.config();
srx1g9 http://blog.numino.net/
remove() - delete the plugin
1J2032 http://blog.numino.net/
Example:
A85yi6 http://blog.numino.net/
oPlugin.remove();
S6HvvS http://blog.numino.net/
[edit] Mscript
3q7hhH 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...>
1saD4a http://blog.numino.net/
Example - the following script button plugin can disable scripting in the current page by changing Maxthon's content control:
9Hp3Zn http://blog.numino.net/
<script language="javascript">
uwoVH2 http://blog.numino.net/
external.m2_run_cmd(%max_security_id, 33175);
Mgcw88 http://blog.numino.net/
</script>
39vPA4 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.
6PxX1e http://blog.numino.net/
<mscript language="javascript">
fNVZRo http://blog.numino.net/
external.m2_run_cmd(0, 33175);
zhcbo9 http://blog.numino.net/
</script>
R39bOW 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