更多相关内容...>>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.
805B60 http://blog.numino.net/
How to obtain the Security ID
XhVlu6 http://blog.numino.net/
1. Script button plugins can use "%max_security_id" for the Security ID
qyVEc2 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。
8EzOh6 http://blog.numino.net/
<script src=max.src></script>
8AM06y http://blog.numino.net/
Reference for Maxthon Plugin Commands
Q0GJH0 http://blog.numino.net/
Unless specified otherwise, the following plugin commands are applicable for both Maxthon 2.0 and Maxthon 1.X。
iS76kb http://blog.numino.net/
1. max_version - return Maxthon's version number
zveZZS http://blog.numino.net/
Example:
2ddaqK http://blog.numino.net/
alert(external.max_version);
IMELbF http://blog.numino.net/
2. max_language_id - return Maxthon's language ID
3VVt2Q http://blog.numino.net/
Example:
og0rx3 http://blog.numino.net/
alert(external.max_language_id);
k7n5m3 http://blog.numino.net/
Note: Maxthon 2.0 and Maxthon 1.X have different language ID format
q0C8Wb http://blog.numino.net/
3. tab_count - return the number of tabs opened by Maxthon
T8raR3 http://blog.numino.net/
Example:
zmkdw6 http://blog.numino.net/
alert(external.tab_count);
lB0I6L http://blog.numino.net/
4. cur_sel - return the index of Maxthon's current tab
C7Ni4c http://blog.numino.net/
Example:
6jd0U8 http://blog.numino.net/
alert(external.cur_sel);
jR4D0H http://blog.numino.net/
5. m2_plugin_folder( security_id , plugin_name ) - return the folder path of the specified plugin
X5A53s http://blog.numino.net/
Example:
T9JAa2 http://blog.numino.net/
alert(external.m2_plugin_folder( %max_security_id , 'ViewSource!'));
e70Rqs http://blog.numino.net/
6. m2_run_cmd( security_id , command_id ) - run the specified command ID
UeqDpk http://blog.numino.net/
Example:
hd5Gty http://blog.numino.net/
external. m2_run_cmd( %max_security_id , 32772 ));
3zP0Fd 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.
ozWpQj http://blog.numino.net/
7. get_tab( security_id , tab_index ) - return the window object of the specifed tab
5knPln http://blog.numino.net/
Example:
R2yIbk http://blog.numino.net/
var oWin=external.get_tab(%max_security_id, 0);
7ihw5D http://blog.numino.net/
alert(oWin.document.URL);
PncIG0 http://blog.numino.net/
8. activate_tab( security_id , tab_index ) - activate the specified tab
R1hpIj http://blog.numino.net/
Example:
pLwPqv http://blog.numino.net/
external.activate_tab(%max_security_id, 0);
E5gZPR http://blog.numino.net/
9. close_tab( security_id , tab_index ) - close the specified tab
1jiuKj http://blog.numino.net/
Example:
J7NA02 http://blog.numino.net/
external.close_tab(%max_security_id, 0);
WPZ2di http://blog.numino.net/
10. readFile( security_id, plugin_name, file_name) - read the content of specified text file
4g1kV2 http://blog.numino.net/
Example:
vZdLf0 http://blog.numino.net/
var sText=external.readFile(%max_security_id, 'ViewPage', 'readme.txt');
B9X8fe http://blog.numino.net/
alert(sText);
wH7nOm http://blog.numino.net/
11. writeFile( security_id, plugin_name, file_name, content ) - write content to the specific text file
L7lIjo http://blog.numino.net/
Example:
QG5gFS http://blog.numino.net/
external.writeFile(%max_security_id, 'ViewPage', 'test.txt', 'This is the file content');
y6xA9g http://blog.numino.net/
12. m2_readIni( security_id, plugin_name , file_name , section_name , key , default_value) - read data from specific INI file
5y468A http://blog.numino.net/
Example:
AAQDJL http://blog.numino.net/
var sDownloadTool=external.m2_readIni(%max_security_id, 'ViewPage', 'plugin.ini', 'Settings', 'Tool', );
67hXYm http://blog.numino.net/
alert(sDownloadTool);
VB4uKo http://blog.numino.net/
13. m2_writeIni( security_id , plugin_name , file_name , section_name , key , value ) - write data to specific INI file
56N9Mw http://blog.numino.net/
Example:
LK38iT http://blog.numino.net/
external.m2_writeIni(%max_security_id, 'ViewPage', 'test.ini', 'Config', 'height', '100px');
4hi9sO http://blog.numino.net/
14. max_modelessDialog( security_id , url , option , attr , window ) - returns a modeless web page dialog
s8XGWS http://blog.numino.net/
Example:
DX3nDu http://blog.numino.net/
var oDialog= external.max_modelessDialog( %max_security_id , 'blank.html', window , , window );
GRx9d0 http://blog.numino.net/
var oDoc=oDialog.document;
Zh05R2 http://blog.numino.net/
oDoc.write('Testing');
SScVJD http://blog.numino.net/
oDoc.close();
wkmw1s http://blog.numino.net/
15. max_activex(security_id ,program_id) - return specified ActiveX object
T0ZsVn http://blog.numino.net/
Example:
Vg4J2K http://blog.numino.net/
var oWSH=external.max_activex(%max_security_id, 'WScript.Shell');
7Qvpj9 http://blog.numino.net/
oWSH.run('notepad.exe');
8n7Jky http://blog.numino.net/
16. m2_search_text(security_id) - return the text in search bar
8xY01o http://blog.numino.net/
Example:
b376W8 http://blog.numino.net/
alert(m2_search_text(%max_security_id));
NybqO6 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)
iNXAv4 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.
5shR6d http://blog.numino.net/
Example:
s06NW3 http://blog.numino.net/
function max_callback(x){
TX9Aps http://blog.numino.net/
if(x=='tab_change') alert('Current tab is changed.');
t0c6WO http://blog.numino.net/
}
98Ov0B http://blog.numino.net/
By checking the parameter of the max_callback function, plugin can get the following browser events:
2QO8VR http://blog.numino.net/
HTML button plugins
ZV1x8h http://blog.numino.net/
tab_change – after the current tab is switched
QhA19E http://blog.numino.net/
document_Complete - after the current tab is fully loaded
alK30g http://blog.numino.net/
self_destroy - when the html is unloaded, usually when Maxthon exits
U5GmP9 http://blog.numino.net/
Script sidebar plugins
kgt53g http://blog.numino.net/
sidebar_tab_change - after the current tab is switched
BFPomz http://blog.numino.net/
sidebar_activate - when the sidebar plugin is activated
29KHyA http://blog.numino.net/
sidebar_deactivate - when the sidebar plugin is deactivated
2N5MTf http://blog.numino.net/
sidebar_unload - when the sidebar plugin is unloaded (Maxthon is closed)
XM7r2q http://blog.numino.net/
18. max_getObj (for Maxthon 2.0 only) - return various Maxthon objects, including:
c32AMy http://blog.numino.net/
Info - general information about Maxthon
V8ZCDK http://blog.numino.net/
Adhunter – about Ad Hunter
4r78tk http://blog.numino.net/
FavManager – about Favorites
t1BCg2 http://blog.numino.net/
RssManager – about RSS
RtBwwJ http://blog.numino.net/
PluginManager - about Plugins, for Maxthon 2.0.5 or later
klyLUu http://blog.numino.net/
Example:
0WT6po http://blog.numino.net/
var oInfo=external.max_getObj(%max_security_id, 'info');
109jb2 http://blog.numino.net/
Info Object supports the following property and method:
3Raf78 http://blog.numino.net/
Property:
qAnyG6 http://blog.numino.net/
fileProxy - read-only, returns the path of the current user's proxy configuration document.
wyrC2R http://blog.numino.net/
Example:
qzKI7a http://blog.numino.net/
var oInfo=external.max_getObj(%max_security_id, 'info');
aFTBot http://blog.numino.net/
alert(oInfo.fileProxy);
Vi92SJ http://blog.numino.net/
folderUser - read-only, returns the path of the profile folder of the current user
b3p0wK http://blog.numino.net/
Example:
K0E2R0 http://blog.numino.net/
var oInfo=external.max_getObj(%max_security_id, 'info');
9JSape http://blog.numino.net/
alert(oInfo. folderUser);
AebzR1 http://blog.numino.net/
Method:
2x7InE http://blog.numino.net/
getFolderPluginData(plugin_name) - obtain the path of plugin data storage folder for the current user and the plugin
zsRU86 http://blog.numino.net/
Example:
Z4mg15 http://blog.numino.net/
var oInfo=external.max_getObj(%max_security_id, 'info');
rW9W9z http://blog.numino.net/
alert(oInfo.getFolderPluginData('ViewSource!'));
ic0jpQ http://blog.numino.net/
AdHunter object support the following method:
FRnbis http://blog.numino.net/
Method:
iDB1NP http://blog.numino.net/
reloadFilter(filter_name) – reload the specified Maxthon filter (currently content filter only) after modifying the relevant filter
Daz0vd http://blog.numino.net/
Example:
4mcjPO http://blog.numino.net/
var oAdHunter=external.max_getObj(%max_security_id, 'AdHunter');
Db1qoG http://blog.numino.net/
oAdHunter.reloadFilter('content');
6JD57U http://blog.numino.net/
enableFilter(filter_name, bEnable) – enable or disable Maxthon's 'content' or 'popup' filter
7ZNedA http://blog.numino.net/
Example:
o2xeYj http://blog.numino.net/
var oAdHunter=external.max_getObj(%max_security_id, 'AdHunter');
91eW9m http://blog.numino.net/
oAdHunter.enableFilter ('content', false);
QDU2qS http://blog.numino.net/
PluginManager object support the following method:
R2UFG4 http://blog.numino.net/
getPluginFolder - return Maxthon main plugin folder path
1JexeL http://blog.numino.net/
Example:
E34rTZ http://blog.numino.net/
var oPluginManager=external.max_getObj(%max_security_id, 'PluginManager');
bys9Hl http://blog.numino.net/
alert(oPluginManager.getPluginFolder)
60SyP7 http://blog.numino.net/
getCount - return the number of all installed plugins, both enabled and disabled
7Sdhgv http://blog.numino.net/
Example:
saD4AS http://blog.numino.net/
var oPluginManager=external.max_getObj(%max_security_id, 'PluginManager');
T3x4gI http://blog.numino.net/
alert(oPluginManager.getCount)
0jcXII http://blog.numino.net/
getList - return a list which contains information like name, author etc of all plugins
zPVFiE http://blog.numino.net/
Example:
xOduHk http://blog.numino.net/
var oPluginManager=external.max_getObj(%max_security_id, 'PluginManager');
h13jnQ http://blog.numino.net/
alert(oPluginManager.getList)
lSj00I http://blog.numino.net/
getPlugin(Index) - Index is a number, return the corresponding plugin object
gQ29JK http://blog.numino.net/
Example:
0QN793 http://blog.numino.net/
var oPluginManager=external.max_getObj(%max_security_id, 'PluginManager');
jE2wsI http://blog.numino.net/
var oPlugin=oPluginManager.getPlugin(0);
7IeO7l http://blog.numino.net/
The plugin object returned from getPlugin(Index) supports the following property and method:
xQpT0O http://blog.numino.net/
Property:
GOOMfm http://blog.numino.net/
title - read only, return plugin name
8fHtIg http://blog.numino.net/
Example:
iw757j http://blog.numino.net/
alert(oPlugin.title);
hCaZri http://blog.numino.net/
folderName - read only, return plugin's folder name
Rfl82T http://blog.numino.net/
Example:
o05OMm http://blog.numino.net/
alert(oPlugin.folderName);
a83805 http://blog.numino.net/
fullPath - read only, return plugin folder's full path
snOuIp http://blog.numino.net/
Example:
9IM875 http://blog.numino.net/
alert(oPlugin.fullPath);
r1EbNp http://blog.numino.net/
enable - read/write, return or set if the plugin is enabled
P0YIC7 http://blog.numino.net/
Example:
0eUbCE http://blog.numino.net/
oPlugin.enable=false;
O07o9O http://blog.numino.net/
alert(oPlugin.enable);
Iw5piy http://blog.numino.net/
oPlugin.enable=true;
A7Yzri http://blog.numino.net/
alert(oPlugin.enable);
JFnAah http://blog.numino.net/
startAfterPageDone - read/write, return or set if the plugin is auto started
N0X5Mt http://blog.numino.net/
Example:
xnI9If http://blog.numino.net/
oPlugin.startAfterPageDone = true;
FT7Qgi http://blog.numino.net/
alert(oPlugin.startAfterPageDone);
VcxgPU http://blog.numino.net/
oPlugin.startAfterPageDone = false;
ed1X06 http://blog.numino.net/
alert(oPlugin.startAfterPageDone);
8c08Tw http://blog.numino.net/
startAfterPageDoneUrl - read/write, return or set the address where the plugin will be auto started
4liTZu http://blog.numino.net/
Example:
lKuABM http://blog.numino.net/
oPlugin.startAfterPageDoneUrl='*maxthon.com*|*maxthon.cn*';
17RVsU http://blog.numino.net/
alert(oPlugin.startAfterPageDoneUrl);
s13s5o http://blog.numino.net/
Methods:
8TZaqf http://blog.numino.net/
config() - open plugin configuration dialog (config.html)
A5ZN6g http://blog.numino.net/
Example:
Dw1aW2 http://blog.numino.net/
oPlugin.config();
Y5a2eU http://blog.numino.net/
remove() - delete the plugin
3T76is http://blog.numino.net/
Example:
0vjTfh http://blog.numino.net/
oPlugin.remove();
8x0Ye3 http://blog.numino.net/
[edit] Mscript
x7YnXw 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...>
CUmff8 http://blog.numino.net/
Example - the following script button plugin can disable scripting in the current page by changing Maxthon's content control:
Z3XblX http://blog.numino.net/
<script language="javascript">
GAbQK4 http://blog.numino.net/
external.m2_run_cmd(%max_security_id, 33175);
8r453l http://blog.numino.net/
</script>
8vj84E 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.
0ua4xg http://blog.numino.net/
<mscript language="javascript">
KtqQi4 http://blog.numino.net/
external.m2_run_cmd(0, 33175);
g0r1Zh http://blog.numino.net/
</script>
9vj4ZC 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