更多相关内容...>>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.
H69t2l http://www.numino.net
How to obtain the Security ID
qeIl87 http://www.numino.net
1. Script button plugins can use "%max_security_id" for the Security ID
06JztQ http://www.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。
17nP6b http://www.numino.net
<script src=max.src></script>
B5a7zK http://www.numino.net
Reference for Maxthon Plugin Commands
rdGYuq http://www.numino.net
Unless specified otherwise, the following plugin commands are applicable for both Maxthon 2.0 and Maxthon 1.X。
2unQR6 http://www.numino.net
1. max_version - return Maxthon's version number
neYmFl http://www.numino.net
Example:
IS1FNi http://www.numino.net
alert(external.max_version);
tQ4sOD http://www.numino.net
2. max_language_id - return Maxthon's language ID
cKTkE5 http://www.numino.net
Example:
1hSzRZ http://www.numino.net
alert(external.max_language_id);
dNREz1 http://www.numino.net
Note: Maxthon 2.0 and Maxthon 1.X have different language ID format
3eFMpl http://www.numino.net
3. tab_count - return the number of tabs opened by Maxthon
99731H http://www.numino.net
Example:
HcOKUP http://www.numino.net
alert(external.tab_count);
QAqgYl http://www.numino.net
4. cur_sel - return the index of Maxthon's current tab
2uJxi5 http://www.numino.net
Example:
E8kR9S http://www.numino.net
alert(external.cur_sel);
S09T41 http://www.numino.net
5. m2_plugin_folder( security_id , plugin_name ) - return the folder path of the specified plugin
lXLEnV http://www.numino.net
Example:
NTHVVN http://www.numino.net
alert(external.m2_plugin_folder( %max_security_id , 'ViewSource!'));
Y334KT http://www.numino.net
6. m2_run_cmd( security_id , command_id ) - run the specified command ID
NLN3Xo http://www.numino.net
Example:
ZdE6lw http://www.numino.net
external. m2_run_cmd( %max_security_id , 32772 ));
298GXi http://www.numino.net
Note: Maxthon 2.0 and Maxthon 1.X have different command ID. Command ID can be found in Maxthon's language file.
eNlCF4 http://www.numino.net
7. get_tab( security_id , tab_index ) - return the window object of the specifed tab
E55Gf9 http://www.numino.net
Example:
7x2542 http://www.numino.net
var oWin=external.get_tab(%max_security_id, 0);
0Cg9b2 http://www.numino.net
alert(oWin.document.URL);
3H9kw4 http://www.numino.net
8. activate_tab( security_id , tab_index ) - activate the specified tab
29F9oN http://www.numino.net
Example:
pan1Sy http://www.numino.net
external.activate_tab(%max_security_id, 0);
sq4Ml5 http://www.numino.net
9. close_tab( security_id , tab_index ) - close the specified tab
C8NM0y http://www.numino.net
Example:
a11aLk http://www.numino.net
external.close_tab(%max_security_id, 0);
q277gj http://www.numino.net
10. readFile( security_id, plugin_name, file_name) - read the content of specified text file
4k3W0h http://www.numino.net
Example:
Q2sOe4 http://www.numino.net
var sText=external.readFile(%max_security_id, 'ViewPage', 'readme.txt');
10k3cd http://www.numino.net
alert(sText);
93Qhsu http://www.numino.net
11. writeFile( security_id, plugin_name, file_name, content ) - write content to the specific text file
Nvhcoe http://www.numino.net
Example:
Dob94v http://www.numino.net
external.writeFile(%max_security_id, 'ViewPage', 'test.txt', 'This is the file content');
Mnb0KT http://www.numino.net
12. m2_readIni( security_id, plugin_name , file_name , section_name , key , default_value) - read data from specific INI file
n6Hqjv http://www.numino.net
Example:
eUKzA5 http://www.numino.net
var sDownloadTool=external.m2_readIni(%max_security_id, 'ViewPage', 'plugin.ini', 'Settings', 'Tool', );
WxHj40 http://www.numino.net
alert(sDownloadTool);
xP1TGz http://www.numino.net
13. m2_writeIni( security_id , plugin_name , file_name , section_name , key , value ) - write data to specific INI file
FBct2s http://www.numino.net
Example:
Bf4oRo http://www.numino.net
external.m2_writeIni(%max_security_id, 'ViewPage', 'test.ini', 'Config', 'height', '100px');
5sX15F http://www.numino.net
14. max_modelessDialog( security_id , url , option , attr , window ) - returns a modeless web page dialog
lvT88k http://www.numino.net
Example:
zA2OCv http://www.numino.net
var oDialog= external.max_modelessDialog( %max_security_id , 'blank.html', window , , window );
mvrcgP http://www.numino.net
var oDoc=oDialog.document;
ckRa3c http://www.numino.net
oDoc.write('Testing');
dF6mN5 http://www.numino.net
oDoc.close();
kZBA9U http://www.numino.net
15. max_activex(security_id ,program_id) - return specified ActiveX object
lk79IB http://www.numino.net
Example:
KictaH http://www.numino.net
var oWSH=external.max_activex(%max_security_id, 'WScript.Shell');
1iDVus http://www.numino.net
oWSH.run('notepad.exe');
vHAkj9 http://www.numino.net
16. m2_search_text(security_id) - return the text in search bar
V3JQ3K http://www.numino.net
Example:
9jFS6O http://www.numino.net
alert(m2_search_text(%max_security_id));
wNMngJ http://www.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)
x9AetY http://www.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.
rJTU2h http://www.numino.net
Example:
laVVkN http://www.numino.net
function max_callback(x){
BIMxF6 http://www.numino.net
if(x=='tab_change') alert('Current tab is changed.');
CraaO7 http://www.numino.net
}
qg31ba http://www.numino.net
By checking the parameter of the max_callback function, plugin can get the following browser events:
2h7P85 http://www.numino.net
HTML button plugins
iU1D74 http://www.numino.net
tab_change – after the current tab is switched
bg2I9T http://www.numino.net
document_Complete - after the current tab is fully loaded
1XXaLd http://www.numino.net
self_destroy - when the html is unloaded, usually when Maxthon exits
kV16j4 http://www.numino.net
Script sidebar plugins
Y58s8J http://www.numino.net
sidebar_tab_change - after the current tab is switched
S9t6Va http://www.numino.net
sidebar_activate - when the sidebar plugin is activated
dzxMXh http://www.numino.net
sidebar_deactivate - when the sidebar plugin is deactivated
tXkJ9n http://www.numino.net
sidebar_unload - when the sidebar plugin is unloaded (Maxthon is closed)
A6ZV6r http://www.numino.net
18. max_getObj (for Maxthon 2.0 only) - return various Maxthon objects, including:
s7Dg5U http://www.numino.net
Info - general information about Maxthon
t5NZbW http://www.numino.net
Adhunter – about Ad Hunter
foBUk0 http://www.numino.net
FavManager – about Favorites
bdQ8he http://www.numino.net
RssManager – about RSS
76mft0 http://www.numino.net
PluginManager - about Plugins, for Maxthon 2.0.5 or later
kve6BO http://www.numino.net
Example:
vktnmn http://www.numino.net
var oInfo=external.max_getObj(%max_security_id, 'info');
O3V4dM http://www.numino.net
Info Object supports the following property and method:
qIlopB http://www.numino.net
Property:
o8dAkL http://www.numino.net
fileProxy - read-only, returns the path of the current user's proxy configuration document.
rZ91eN http://www.numino.net
Example:
CnZKTY http://www.numino.net
var oInfo=external.max_getObj(%max_security_id, 'info');
8QFxDr http://www.numino.net
alert(oInfo.fileProxy);
Vx3aKe http://www.numino.net
folderUser - read-only, returns the path of the profile folder of the current user
Lg3Ml1 http://www.numino.net
Example:
MZq448 http://www.numino.net
var oInfo=external.max_getObj(%max_security_id, 'info');
5iD7sv http://www.numino.net
alert(oInfo. folderUser);
dROa3x http://www.numino.net
Method:
CW2fIj http://www.numino.net
getFolderPluginData(plugin_name) - obtain the path of plugin data storage folder for the current user and the plugin
RfOkro http://www.numino.net
Example:
Mvgd3S http://www.numino.net
var oInfo=external.max_getObj(%max_security_id, 'info');
qPQzl7 http://www.numino.net
alert(oInfo.getFolderPluginData('ViewSource!'));
9S0siW http://www.numino.net
AdHunter object support the following method:
z3zP8c http://www.numino.net
Method:
PaO6iU http://www.numino.net
reloadFilter(filter_name) – reload the specified Maxthon filter (currently content filter only) after modifying the relevant filter
XHA85W http://www.numino.net
Example:
EK11N2 http://www.numino.net
var oAdHunter=external.max_getObj(%max_security_id, 'AdHunter');
89hOaq http://www.numino.net
oAdHunter.reloadFilter('content');
plgk5s http://www.numino.net
enableFilter(filter_name, bEnable) – enable or disable Maxthon's 'content' or 'popup' filter
ci56o9 http://www.numino.net
Example:
6tMa79 http://www.numino.net
var oAdHunter=external.max_getObj(%max_security_id, 'AdHunter');
Wu3yse http://www.numino.net
oAdHunter.enableFilter ('content', false);
2yv2zJ http://www.numino.net
PluginManager object support the following method:
24p4T5 http://www.numino.net
getPluginFolder - return Maxthon main plugin folder path
qgd0Jk http://www.numino.net
Example:
wYFAY7 http://www.numino.net
var oPluginManager=external.max_getObj(%max_security_id, 'PluginManager');
Oytm66 http://www.numino.net
alert(oPluginManager.getPluginFolder)
ZIr2cb http://www.numino.net
getCount - return the number of all installed plugins, both enabled and disabled
2g50MX http://www.numino.net
Example:
nKpA8R http://www.numino.net
var oPluginManager=external.max_getObj(%max_security_id, 'PluginManager');
Ha9uEy http://www.numino.net
alert(oPluginManager.getCount)
LwMlxG http://www.numino.net
getList - return a list which contains information like name, author etc of all plugins
7o7ej9 http://www.numino.net
Example:
5bTxFU http://www.numino.net
var oPluginManager=external.max_getObj(%max_security_id, 'PluginManager');
VhH9z0 http://www.numino.net
alert(oPluginManager.getList)
nBg994 http://www.numino.net
getPlugin(Index) - Index is a number, return the corresponding plugin object
DwDN0s http://www.numino.net
Example:
Rwu0qd http://www.numino.net
var oPluginManager=external.max_getObj(%max_security_id, 'PluginManager');
z2cWiV http://www.numino.net
var oPlugin=oPluginManager.getPlugin(0);
QJYVFS http://www.numino.net
The plugin object returned from getPlugin(Index) supports the following property and method:
89ay0n http://www.numino.net
Property:
3R94uq http://www.numino.net
title - read only, return plugin name
gnr1P0 http://www.numino.net
Example:
7siwwo http://www.numino.net
alert(oPlugin.title);
DWPyy4 http://www.numino.net
folderName - read only, return plugin's folder name
ExkfkH http://www.numino.net
Example:
3tLnoX http://www.numino.net
alert(oPlugin.folderName);
t7ZO8A http://www.numino.net
fullPath - read only, return plugin folder's full path
C004YM http://www.numino.net
Example:
9xyzBl http://www.numino.net
alert(oPlugin.fullPath);
IdL0Y4 http://www.numino.net
enable - read/write, return or set if the plugin is enabled
ZfQzzi http://www.numino.net
Example:
950k4F http://www.numino.net
oPlugin.enable=false;
YTkPx5 http://www.numino.net
alert(oPlugin.enable);
q77F7z http://www.numino.net
oPlugin.enable=true;
4i9frJ http://www.numino.net
alert(oPlugin.enable);
ZDD3fz http://www.numino.net
startAfterPageDone - read/write, return or set if the plugin is auto started
c6GB9f http://www.numino.net
Example:
YXTR0J http://www.numino.net
oPlugin.startAfterPageDone = true;
4LfD1V http://www.numino.net
alert(oPlugin.startAfterPageDone);
mu4Ze8 http://www.numino.net
oPlugin.startAfterPageDone = false;
gF28i5 http://www.numino.net
alert(oPlugin.startAfterPageDone);
ot4de1 http://www.numino.net
startAfterPageDoneUrl - read/write, return or set the address where the plugin will be auto started
mSgeJ6 http://www.numino.net
Example:
b1bwy2 http://www.numino.net
oPlugin.startAfterPageDoneUrl='*maxthon.com*|*maxthon.cn*';
EXU68R http://www.numino.net
alert(oPlugin.startAfterPageDoneUrl);
gdoLw8 http://www.numino.net
Methods:
13v0rP http://www.numino.net
config() - open plugin configuration dialog (config.html)
5VM8XN http://www.numino.net
Example:
xu4gI6 http://www.numino.net
oPlugin.config();
s9QE6e http://www.numino.net
remove() - delete the plugin
nV5JX2 http://www.numino.net
Example:
jTZcB3 http://www.numino.net
oPlugin.remove();
53wu2n http://www.numino.net
[edit] Mscript
Mo2OvD http://www.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...>
KJcv24 http://www.numino.net
Example - the following script button plugin can disable scripting in the current page by changing Maxthon's content control:
KD5Hjh http://www.numino.net
<script language="javascript">
9Y58Oh http://www.numino.net
external.m2_run_cmd(%max_security_id, 33175);
Y5pZQw http://www.numino.net
</script>
2PdkR1 http://www.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.
d8tC99 http://www.numino.net
<mscript language="javascript">
kv256R http://www.numino.net
external.m2_run_cmd(0, 33175);
5h5U2V http://www.numino.net
</script>
I9t3UD http://www.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