更多相关内容...>>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.
TE9roy http://blog.numino.net/
How to obtain the Security ID
z31OT2 http://blog.numino.net/
1. Script button plugins can use "%max_security_id" for the Security ID
i2XEVA 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。
dRYUV1 http://blog.numino.net/
<script src=max.src></script>
7k2Zcy http://blog.numino.net/
Reference for Maxthon Plugin Commands
zNfq6M http://blog.numino.net/
Unless specified otherwise, the following plugin commands are applicable for both Maxthon 2.0 and Maxthon 1.X。
q89jc6 http://blog.numino.net/
1. max_version - return Maxthon's version number
dBB98t http://blog.numino.net/
Example:
5oKv6l http://blog.numino.net/
alert(external.max_version);
b3S5JL http://blog.numino.net/
2. max_language_id - return Maxthon's language ID
93V8A5 http://blog.numino.net/
Example:
QjH8AY http://blog.numino.net/
alert(external.max_language_id);
fW32SE http://blog.numino.net/
Note: Maxthon 2.0 and Maxthon 1.X have different language ID format
70w58r http://blog.numino.net/
3. tab_count - return the number of tabs opened by Maxthon
9IO2f0 http://blog.numino.net/
Example:
B1rX5u http://blog.numino.net/
alert(external.tab_count);
agyuhl http://blog.numino.net/
4. cur_sel - return the index of Maxthon's current tab
rWeaL7 http://blog.numino.net/
Example:
TKpCuY http://blog.numino.net/
alert(external.cur_sel);
KO08b2 http://blog.numino.net/
5. m2_plugin_folder( security_id , plugin_name ) - return the folder path of the specified plugin
59yEIN http://blog.numino.net/
Example:
OFaK7u http://blog.numino.net/
alert(external.m2_plugin_folder( %max_security_id , 'ViewSource!'));
kEJ0Lk http://blog.numino.net/
6. m2_run_cmd( security_id , command_id ) - run the specified command ID
Fm63uf http://blog.numino.net/
Example:
BW1vS7 http://blog.numino.net/
external. m2_run_cmd( %max_security_id , 32772 ));
Zb5nR0 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.
E0CpbB http://blog.numino.net/
7. get_tab( security_id , tab_index ) - return the window object of the specifed tab
2lNJ3g http://blog.numino.net/
Example:
E1sfB0 http://blog.numino.net/
var oWin=external.get_tab(%max_security_id, 0);
1iJca9 http://blog.numino.net/
alert(oWin.document.URL);
x1Nbgv http://blog.numino.net/
8. activate_tab( security_id , tab_index ) - activate the specified tab
1nD4Lc http://blog.numino.net/
Example:
lu19pl http://blog.numino.net/
external.activate_tab(%max_security_id, 0);
4Hnunu http://blog.numino.net/
9. close_tab( security_id , tab_index ) - close the specified tab
0z9roz http://blog.numino.net/
Example:
dRQoU9 http://blog.numino.net/
external.close_tab(%max_security_id, 0);
H50Y9b http://blog.numino.net/
10. readFile( security_id, plugin_name, file_name) - read the content of specified text file
6jzib7 http://blog.numino.net/
Example:
P9Qiai http://blog.numino.net/
var sText=external.readFile(%max_security_id, 'ViewPage', 'readme.txt');
FzSo35 http://blog.numino.net/
alert(sText);
2u5qPa http://blog.numino.net/
11. writeFile( security_id, plugin_name, file_name, content ) - write content to the specific text file
9GZRfF http://blog.numino.net/
Example:
yV3FRv http://blog.numino.net/
external.writeFile(%max_security_id, 'ViewPage', 'test.txt', 'This is the file content');
T27F6E http://blog.numino.net/
12. m2_readIni( security_id, plugin_name , file_name , section_name , key , default_value) - read data from specific INI file
7gvYq4 http://blog.numino.net/
Example:
l7NHFn http://blog.numino.net/
var sDownloadTool=external.m2_readIni(%max_security_id, 'ViewPage', 'plugin.ini', 'Settings', 'Tool', );
a6zUmg http://blog.numino.net/
alert(sDownloadTool);
uyZg15 http://blog.numino.net/
13. m2_writeIni( security_id , plugin_name , file_name , section_name , key , value ) - write data to specific INI file
R5YuXr http://blog.numino.net/
Example:
ElGHla http://blog.numino.net/
external.m2_writeIni(%max_security_id, 'ViewPage', 'test.ini', 'Config', 'height', '100px');
5KXWis http://blog.numino.net/
14. max_modelessDialog( security_id , url , option , attr , window ) - returns a modeless web page dialog
9sY8hx http://blog.numino.net/
Example:
prbl19 http://blog.numino.net/
var oDialog= external.max_modelessDialog( %max_security_id , 'blank.html', window , , window );
0tu6wO http://blog.numino.net/
var oDoc=oDialog.document;
jq709i http://blog.numino.net/
oDoc.write('Testing');
hx3zMd http://blog.numino.net/
oDoc.close();
H9zlK7 http://blog.numino.net/
15. max_activex(security_id ,program_id) - return specified ActiveX object
dpd1Fu http://blog.numino.net/
Example:
GT4h0M http://blog.numino.net/
var oWSH=external.max_activex(%max_security_id, 'WScript.Shell');
q3tHDu http://blog.numino.net/
oWSH.run('notepad.exe');
xBKG3D http://blog.numino.net/
16. m2_search_text(security_id) - return the text in search bar
pR8hyD http://blog.numino.net/
Example:
9mu6YZ http://blog.numino.net/
alert(m2_search_text(%max_security_id));
51601b 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)
uDw75v 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.
t7L1kA http://blog.numino.net/
Example:
OVMR9B http://blog.numino.net/
function max_callback(x){
L6EgW6 http://blog.numino.net/
if(x=='tab_change') alert('Current tab is changed.');
j0QO87 http://blog.numino.net/
}
M3UA3b http://blog.numino.net/
By checking the parameter of the max_callback function, plugin can get the following browser events:
u9Y6lI http://blog.numino.net/
HTML button plugins
FEUeok http://blog.numino.net/
tab_change – after the current tab is switched
xpMvm2 http://blog.numino.net/
document_Complete - after the current tab is fully loaded
6722FB http://blog.numino.net/
self_destroy - when the html is unloaded, usually when Maxthon exits
2J1NnI http://blog.numino.net/
Script sidebar plugins
DnOh3s http://blog.numino.net/
sidebar_tab_change - after the current tab is switched
4VNEuw http://blog.numino.net/
sidebar_activate - when the sidebar plugin is activated
vYKx4x http://blog.numino.net/
sidebar_deactivate - when the sidebar plugin is deactivated
43KT9y http://blog.numino.net/
sidebar_unload - when the sidebar plugin is unloaded (Maxthon is closed)
l07X8q http://blog.numino.net/
18. max_getObj (for Maxthon 2.0 only) - return various Maxthon objects, including:
13qGG3 http://blog.numino.net/
Info - general information about Maxthon
RKMXSz http://blog.numino.net/
Adhunter – about Ad Hunter
K981Jm http://blog.numino.net/
FavManager – about Favorites
tVB7tz http://blog.numino.net/
RssManager – about RSS
8myt46 http://blog.numino.net/
PluginManager - about Plugins, for Maxthon 2.0.5 or later
m166y5 http://blog.numino.net/
Example:
a5fnQi http://blog.numino.net/
var oInfo=external.max_getObj(%max_security_id, 'info');
2lkF97 http://blog.numino.net/
Info Object supports the following property and method:
7Id6j8 http://blog.numino.net/
Property:
CiPboX http://blog.numino.net/
fileProxy - read-only, returns the path of the current user's proxy configuration document.
sL9RTW http://blog.numino.net/
Example:
P1L143 http://blog.numino.net/
var oInfo=external.max_getObj(%max_security_id, 'info');
G1D7t9 http://blog.numino.net/
alert(oInfo.fileProxy);
yRreSz http://blog.numino.net/
folderUser - read-only, returns the path of the profile folder of the current user
Us0a51 http://blog.numino.net/
Example:
P1oTTn http://blog.numino.net/
var oInfo=external.max_getObj(%max_security_id, 'info');
y3Lj4p http://blog.numino.net/
alert(oInfo. folderUser);
i08Bvc http://blog.numino.net/
Method:
XJEnTF http://blog.numino.net/
getFolderPluginData(plugin_name) - obtain the path of plugin data storage folder for the current user and the plugin
1aaAZE http://blog.numino.net/
Example:
x9Dmdh http://blog.numino.net/
var oInfo=external.max_getObj(%max_security_id, 'info');
YCaFcw http://blog.numino.net/
alert(oInfo.getFolderPluginData('ViewSource!'));
Km0BqN http://blog.numino.net/
AdHunter object support the following method:
cwfHvH http://blog.numino.net/
Method:
5y6zAE http://blog.numino.net/
reloadFilter(filter_name) – reload the specified Maxthon filter (currently content filter only) after modifying the relevant filter
2L5a01 http://blog.numino.net/
Example:
VsjMQp http://blog.numino.net/
var oAdHunter=external.max_getObj(%max_security_id, 'AdHunter');
hL1O9b http://blog.numino.net/
oAdHunter.reloadFilter('content');
SwEids http://blog.numino.net/
enableFilter(filter_name, bEnable) – enable or disable Maxthon's 'content' or 'popup' filter
ijSnzi http://blog.numino.net/
Example:
Z261JW http://blog.numino.net/
var oAdHunter=external.max_getObj(%max_security_id, 'AdHunter');
4IzhHC http://blog.numino.net/
oAdHunter.enableFilter ('content', false);
0eeQkN http://blog.numino.net/
PluginManager object support the following method:
nbphos http://blog.numino.net/
getPluginFolder - return Maxthon main plugin folder path
l09Bk6 http://blog.numino.net/
Example:
18Gz70 http://blog.numino.net/
var oPluginManager=external.max_getObj(%max_security_id, 'PluginManager');
ppLrg1 http://blog.numino.net/
alert(oPluginManager.getPluginFolder)
Tj4y93 http://blog.numino.net/
getCount - return the number of all installed plugins, both enabled and disabled
kr9J6A http://blog.numino.net/
Example:
lzqZ38 http://blog.numino.net/
var oPluginManager=external.max_getObj(%max_security_id, 'PluginManager');
98cj9F http://blog.numino.net/
alert(oPluginManager.getCount)
vpr3Uc http://blog.numino.net/
getList - return a list which contains information like name, author etc of all plugins
y6Ff0w http://blog.numino.net/
Example:
KKiptg http://blog.numino.net/
var oPluginManager=external.max_getObj(%max_security_id, 'PluginManager');
aBHi3L http://blog.numino.net/
alert(oPluginManager.getList)
hs28dC http://blog.numino.net/
getPlugin(Index) - Index is a number, return the corresponding plugin object
gLOfRp http://blog.numino.net/
Example:
LL15v7 http://blog.numino.net/
var oPluginManager=external.max_getObj(%max_security_id, 'PluginManager');
goddyu http://blog.numino.net/
var oPlugin=oPluginManager.getPlugin(0);
9tj5S4 http://blog.numino.net/
The plugin object returned from getPlugin(Index) supports the following property and method:
TtX2a9 http://blog.numino.net/
Property:
7DwZuR http://blog.numino.net/
title - read only, return plugin name
AzdaFq http://blog.numino.net/
Example:
neKKDr http://blog.numino.net/
alert(oPlugin.title);
rWHgs4 http://blog.numino.net/
folderName - read only, return plugin's folder name
SyRC47 http://blog.numino.net/
Example:
ezdgtt http://blog.numino.net/
alert(oPlugin.folderName);
s3wb3S http://blog.numino.net/
fullPath - read only, return plugin folder's full path
5p9m8d http://blog.numino.net/
Example:
Tmt67T http://blog.numino.net/
alert(oPlugin.fullPath);
DnV3VN http://blog.numino.net/
enable - read/write, return or set if the plugin is enabled
89zpSj http://blog.numino.net/
Example:
flGXGa http://blog.numino.net/
oPlugin.enable=false;
5rQM4a http://blog.numino.net/
alert(oPlugin.enable);
Xl2uH7 http://blog.numino.net/
oPlugin.enable=true;
ekLtvf http://blog.numino.net/
alert(oPlugin.enable);
Zm4nsg http://blog.numino.net/
startAfterPageDone - read/write, return or set if the plugin is auto started
USF5Dx http://blog.numino.net/
Example:
HOV99J http://blog.numino.net/
oPlugin.startAfterPageDone = true;
2300X2 http://blog.numino.net/
alert(oPlugin.startAfterPageDone);
z9KrZj http://blog.numino.net/
oPlugin.startAfterPageDone = false;
Pgxwn4 http://blog.numino.net/
alert(oPlugin.startAfterPageDone);
lieyjA http://blog.numino.net/
startAfterPageDoneUrl - read/write, return or set the address where the plugin will be auto started
yjfjTq http://blog.numino.net/
Example:
eynQAk http://blog.numino.net/
oPlugin.startAfterPageDoneUrl='*maxthon.com*|*maxthon.cn*';
r5qVjC http://blog.numino.net/
alert(oPlugin.startAfterPageDoneUrl);
5nGmfu http://blog.numino.net/
Methods:
3b1A0A http://blog.numino.net/
config() - open plugin configuration dialog (config.html)
M1V6Iv http://blog.numino.net/
Example:
68uxfo http://blog.numino.net/
oPlugin.config();
qKU8cJ http://blog.numino.net/
remove() - delete the plugin
EqF5lZ http://blog.numino.net/
Example:
36F1NI http://blog.numino.net/
oPlugin.remove();
ld66o6 http://blog.numino.net/
[edit] Mscript
N9YYJ2 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...>
pG6ZuB http://blog.numino.net/
Example - the following script button plugin can disable scripting in the current page by changing Maxthon's content control:
BL6S2C http://blog.numino.net/
<script language="javascript">
gI2tc5 http://blog.numino.net/
external.m2_run_cmd(%max_security_id, 33175);
Hn2Fb6 http://blog.numino.net/
</script>
WUlN27 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.
GdZVd8 http://blog.numino.net/
<mscript language="javascript">
xGvv8K http://blog.numino.net/
external.m2_run_cmd(0, 33175);
7529LG http://blog.numino.net/
</script>
r9tn8y 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