更多相关内容...>>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.
XhzS83 http://blog.numino.net/
How to obtain the Security ID
1RRkJ6 http://blog.numino.net/
1. Script button plugins can use "%max_security_id" for the Security ID
ROg03P 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。
Rk4fu7 http://blog.numino.net/
<script src=max.src></script>
zj69jK http://blog.numino.net/
Reference for Maxthon Plugin Commands
9onSTL http://blog.numino.net/
Unless specified otherwise, the following plugin commands are applicable for both Maxthon 2.0 and Maxthon 1.X。
4n4Tx9 http://blog.numino.net/
1. max_version - return Maxthon's version number
oS9DT4 http://blog.numino.net/
Example:
ZORx9M http://blog.numino.net/
alert(external.max_version);
NCdhYa http://blog.numino.net/
2. max_language_id - return Maxthon's language ID
vHtZNG http://blog.numino.net/
Example:
Zvv9m2 http://blog.numino.net/
alert(external.max_language_id);
QLwfyp http://blog.numino.net/
Note: Maxthon 2.0 and Maxthon 1.X have different language ID format
Tk384U http://blog.numino.net/
3. tab_count - return the number of tabs opened by Maxthon
QNGeqV http://blog.numino.net/
Example:
AZu34b http://blog.numino.net/
alert(external.tab_count);
z1Ebdd http://blog.numino.net/
4. cur_sel - return the index of Maxthon's current tab
t8TjI8 http://blog.numino.net/
Example:
znak31 http://blog.numino.net/
alert(external.cur_sel);
icTxHO http://blog.numino.net/
5. m2_plugin_folder( security_id , plugin_name ) - return the folder path of the specified plugin
oj7F6H http://blog.numino.net/
Example:
4JeiT2 http://blog.numino.net/
alert(external.m2_plugin_folder( %max_security_id , 'ViewSource!'));
5fo1lv http://blog.numino.net/
6. m2_run_cmd( security_id , command_id ) - run the specified command ID
r7zKvz http://blog.numino.net/
Example:
F6Nd45 http://blog.numino.net/
external. m2_run_cmd( %max_security_id , 32772 ));
3q5su4 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.
We8Bco http://blog.numino.net/
7. get_tab( security_id , tab_index ) - return the window object of the specifed tab
OHJxB9 http://blog.numino.net/
Example:
D6hDqG http://blog.numino.net/
var oWin=external.get_tab(%max_security_id, 0);
7QvJ9E http://blog.numino.net/
alert(oWin.document.URL);
Ho1Y1Y http://blog.numino.net/
8. activate_tab( security_id , tab_index ) - activate the specified tab
tTW3uD http://blog.numino.net/
Example:
4LZJq3 http://blog.numino.net/
external.activate_tab(%max_security_id, 0);
F2Tt2P http://blog.numino.net/
9. close_tab( security_id , tab_index ) - close the specified tab
5D4way http://blog.numino.net/
Example:
ntdm8m http://blog.numino.net/
external.close_tab(%max_security_id, 0);
so8Xca http://blog.numino.net/
10. readFile( security_id, plugin_name, file_name) - read the content of specified text file
QstT1t http://blog.numino.net/
Example:
TKf0kb http://blog.numino.net/
var sText=external.readFile(%max_security_id, 'ViewPage', 'readme.txt');
Ceutxg http://blog.numino.net/
alert(sText);
56n4gl http://blog.numino.net/
11. writeFile( security_id, plugin_name, file_name, content ) - write content to the specific text file
h9P5g7 http://blog.numino.net/
Example:
8fY7XC http://blog.numino.net/
external.writeFile(%max_security_id, 'ViewPage', 'test.txt', 'This is the file content');
sG6wMd http://blog.numino.net/
12. m2_readIni( security_id, plugin_name , file_name , section_name , key , default_value) - read data from specific INI file
dbA2m0 http://blog.numino.net/
Example:
DmG36g http://blog.numino.net/
var sDownloadTool=external.m2_readIni(%max_security_id, 'ViewPage', 'plugin.ini', 'Settings', 'Tool', );
AWXi9g http://blog.numino.net/
alert(sDownloadTool);
8R8OFi http://blog.numino.net/
13. m2_writeIni( security_id , plugin_name , file_name , section_name , key , value ) - write data to specific INI file
jfeW1X http://blog.numino.net/
Example:
e8A2c4 http://blog.numino.net/
external.m2_writeIni(%max_security_id, 'ViewPage', 'test.ini', 'Config', 'height', '100px');
U23cuO http://blog.numino.net/
14. max_modelessDialog( security_id , url , option , attr , window ) - returns a modeless web page dialog
6oLlwW http://blog.numino.net/
Example:
GqWUzf http://blog.numino.net/
var oDialog= external.max_modelessDialog( %max_security_id , 'blank.html', window , , window );
09bykU http://blog.numino.net/
var oDoc=oDialog.document;
Pc41Nw http://blog.numino.net/
oDoc.write('Testing');
JUljrQ http://blog.numino.net/
oDoc.close();
HYl5va http://blog.numino.net/
15. max_activex(security_id ,program_id) - return specified ActiveX object
yZ0i1U http://blog.numino.net/
Example:
7otD66 http://blog.numino.net/
var oWSH=external.max_activex(%max_security_id, 'WScript.Shell');
o86hud http://blog.numino.net/
oWSH.run('notepad.exe');
OmZ5lf http://blog.numino.net/
16. m2_search_text(security_id) - return the text in search bar
OwCU6l http://blog.numino.net/
Example:
ggzJpS http://blog.numino.net/
alert(m2_search_text(%max_security_id));
n8KKTF 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)
64PwH8 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.
M9Ev0q http://blog.numino.net/
Example:
XoDGjJ http://blog.numino.net/
function max_callback(x){
09m6A5 http://blog.numino.net/
if(x=='tab_change') alert('Current tab is changed.');
c5474t http://blog.numino.net/
}
wuAOQL http://blog.numino.net/
By checking the parameter of the max_callback function, plugin can get the following browser events:
CuAS9m http://blog.numino.net/
HTML button plugins
f6ucWA http://blog.numino.net/
tab_change – after the current tab is switched
0iIEiR http://blog.numino.net/
document_Complete - after the current tab is fully loaded
02oZ4n http://blog.numino.net/
self_destroy - when the html is unloaded, usually when Maxthon exits
kk8D1w http://blog.numino.net/
Script sidebar plugins
QQQyhQ http://blog.numino.net/
sidebar_tab_change - after the current tab is switched
9A6Idt http://blog.numino.net/
sidebar_activate - when the sidebar plugin is activated
cisi61 http://blog.numino.net/
sidebar_deactivate - when the sidebar plugin is deactivated
VrI28b http://blog.numino.net/
sidebar_unload - when the sidebar plugin is unloaded (Maxthon is closed)
S71Ozu http://blog.numino.net/
18. max_getObj (for Maxthon 2.0 only) - return various Maxthon objects, including:
FcJkCv http://blog.numino.net/
Info - general information about Maxthon
M33R1m http://blog.numino.net/
Adhunter – about Ad Hunter
Ydov67 http://blog.numino.net/
FavManager – about Favorites
G23Enp http://blog.numino.net/
RssManager – about RSS
264d4c http://blog.numino.net/
PluginManager - about Plugins, for Maxthon 2.0.5 or later
gR9B07 http://blog.numino.net/
Example:
qU12Qx http://blog.numino.net/
var oInfo=external.max_getObj(%max_security_id, 'info');
A5u095 http://blog.numino.net/
Info Object supports the following property and method:
TROugK http://blog.numino.net/
Property:
1v58Xv http://blog.numino.net/
fileProxy - read-only, returns the path of the current user's proxy configuration document.
kq22ra http://blog.numino.net/
Example:
31t9g7 http://blog.numino.net/
var oInfo=external.max_getObj(%max_security_id, 'info');
Zq99o9 http://blog.numino.net/
alert(oInfo.fileProxy);
7rRI9j http://blog.numino.net/
folderUser - read-only, returns the path of the profile folder of the current user
NEdsRi http://blog.numino.net/
Example:
ZeTdYb http://blog.numino.net/
var oInfo=external.max_getObj(%max_security_id, 'info');
F7saP5 http://blog.numino.net/
alert(oInfo. folderUser);
kWmE1J http://blog.numino.net/
Method:
oS42JS http://blog.numino.net/
getFolderPluginData(plugin_name) - obtain the path of plugin data storage folder for the current user and the plugin
jXX055 http://blog.numino.net/
Example:
WsIyh8 http://blog.numino.net/
var oInfo=external.max_getObj(%max_security_id, 'info');
AtU7c4 http://blog.numino.net/
alert(oInfo.getFolderPluginData('ViewSource!'));
7wW1cr http://blog.numino.net/
AdHunter object support the following method:
Dy20KB http://blog.numino.net/
Method:
4Hrx6t http://blog.numino.net/
reloadFilter(filter_name) – reload the specified Maxthon filter (currently content filter only) after modifying the relevant filter
eHd2HQ http://blog.numino.net/
Example:
kAOQbo http://blog.numino.net/
var oAdHunter=external.max_getObj(%max_security_id, 'AdHunter');
03rZMv http://blog.numino.net/
oAdHunter.reloadFilter('content');
0IQZSV http://blog.numino.net/
enableFilter(filter_name, bEnable) – enable or disable Maxthon's 'content' or 'popup' filter
7FE106 http://blog.numino.net/
Example:
2E61w5 http://blog.numino.net/
var oAdHunter=external.max_getObj(%max_security_id, 'AdHunter');
JfTvZq http://blog.numino.net/
oAdHunter.enableFilter ('content', false);
JwWz3p http://blog.numino.net/
PluginManager object support the following method:
8iw211 http://blog.numino.net/
getPluginFolder - return Maxthon main plugin folder path
pR4URz http://blog.numino.net/
Example:
DyPki9 http://blog.numino.net/
var oPluginManager=external.max_getObj(%max_security_id, 'PluginManager');
hSLnk3 http://blog.numino.net/
alert(oPluginManager.getPluginFolder)
3TfQ7c http://blog.numino.net/
getCount - return the number of all installed plugins, both enabled and disabled
xDR74s http://blog.numino.net/
Example:
kbhaHq http://blog.numino.net/
var oPluginManager=external.max_getObj(%max_security_id, 'PluginManager');
t46OUv http://blog.numino.net/
alert(oPluginManager.getCount)
LCW7jJ http://blog.numino.net/
getList - return a list which contains information like name, author etc of all plugins
56XN2f http://blog.numino.net/
Example:
kTywnx http://blog.numino.net/
var oPluginManager=external.max_getObj(%max_security_id, 'PluginManager');
sIrIAl http://blog.numino.net/
alert(oPluginManager.getList)
3E4mC5 http://blog.numino.net/
getPlugin(Index) - Index is a number, return the corresponding plugin object
8mH1ok http://blog.numino.net/
Example:
V31dno http://blog.numino.net/
var oPluginManager=external.max_getObj(%max_security_id, 'PluginManager');
R7fdTF http://blog.numino.net/
var oPlugin=oPluginManager.getPlugin(0);
A3iWC4 http://blog.numino.net/
The plugin object returned from getPlugin(Index) supports the following property and method:
De7O04 http://blog.numino.net/
Property:
3KQ05O http://blog.numino.net/
title - read only, return plugin name
O67g79 http://blog.numino.net/
Example:
70fJ9H http://blog.numino.net/
alert(oPlugin.title);
QY60Bd http://blog.numino.net/
folderName - read only, return plugin's folder name
QPu6OZ http://blog.numino.net/
Example:
8pQpx9 http://blog.numino.net/
alert(oPlugin.folderName);
f6d3xY http://blog.numino.net/
fullPath - read only, return plugin folder's full path
28oNwv http://blog.numino.net/
Example:
dm3bdU http://blog.numino.net/
alert(oPlugin.fullPath);
ooadHN http://blog.numino.net/
enable - read/write, return or set if the plugin is enabled
OZqc2Z http://blog.numino.net/
Example:
Jl2KRo http://blog.numino.net/
oPlugin.enable=false;
d4MKk9 http://blog.numino.net/
alert(oPlugin.enable);
iIuifZ http://blog.numino.net/
oPlugin.enable=true;
eBVA6W http://blog.numino.net/
alert(oPlugin.enable);
4yFPt9 http://blog.numino.net/
startAfterPageDone - read/write, return or set if the plugin is auto started
p20Hh8 http://blog.numino.net/
Example:
LRcYB6 http://blog.numino.net/
oPlugin.startAfterPageDone = true;
mNNsxn http://blog.numino.net/
alert(oPlugin.startAfterPageDone);
9eI5gp http://blog.numino.net/
oPlugin.startAfterPageDone = false;
J6iYir http://blog.numino.net/
alert(oPlugin.startAfterPageDone);
Nrhmu7 http://blog.numino.net/
startAfterPageDoneUrl - read/write, return or set the address where the plugin will be auto started
oSYNVR http://blog.numino.net/
Example:
6mo1rZ http://blog.numino.net/
oPlugin.startAfterPageDoneUrl='*maxthon.com*|*maxthon.cn*';
PYVdy2 http://blog.numino.net/
alert(oPlugin.startAfterPageDoneUrl);
mfNOl7 http://blog.numino.net/
Methods:
i5wgF2 http://blog.numino.net/
config() - open plugin configuration dialog (config.html)
9DgEX1 http://blog.numino.net/
Example:
vLH26T http://blog.numino.net/
oPlugin.config();
EHskr3 http://blog.numino.net/
remove() - delete the plugin
1GI248 http://blog.numino.net/
Example:
7UY0GJ http://blog.numino.net/
oPlugin.remove();
zC8GVR http://blog.numino.net/
[edit] Mscript
2HuJCD 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...>
7Wwtfs http://blog.numino.net/
Example - the following script button plugin can disable scripting in the current page by changing Maxthon's content control:
OPhzx3 http://blog.numino.net/
<script language="javascript">
xo84w6 http://blog.numino.net/
external.m2_run_cmd(%max_security_id, 33175);
cdjpze http://blog.numino.net/
</script>
GRIlB1 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.
3Qw5Yn http://blog.numino.net/
<mscript language="javascript">
7Sc2Qi http://blog.numino.net/
external.m2_run_cmd(0, 33175);
xYdP5i http://blog.numino.net/
</script>
yxQSS2 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