更多相关内容...>>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.
9LX7tR http://blog.numino.net/
How to obtain the Security ID
8b4OHc http://blog.numino.net/
1. Script button plugins can use "%max_security_id" for the Security ID
QyyaJ1 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。
1uEFcm http://blog.numino.net/
<script src=max.src></script>
PX4Itr http://blog.numino.net/
Reference for Maxthon Plugin Commands
fXESpu http://blog.numino.net/
Unless specified otherwise, the following plugin commands are applicable for both Maxthon 2.0 and Maxthon 1.X。
3qOro5 http://blog.numino.net/
1. max_version - return Maxthon's version number
G598G2 http://blog.numino.net/
Example:
3U6J6F http://blog.numino.net/
alert(external.max_version);
52bgEX http://blog.numino.net/
2. max_language_id - return Maxthon's language ID
AQi094 http://blog.numino.net/
Example:
rSu44f http://blog.numino.net/
alert(external.max_language_id);
qk3zyS http://blog.numino.net/
Note: Maxthon 2.0 and Maxthon 1.X have different language ID format
2hZjmp http://blog.numino.net/
3. tab_count - return the number of tabs opened by Maxthon
WoI4CS http://blog.numino.net/
Example:
SU0FQa http://blog.numino.net/
alert(external.tab_count);
O3H93s http://blog.numino.net/
4. cur_sel - return the index of Maxthon's current tab
ZgcCx0 http://blog.numino.net/
Example:
KLmSaG http://blog.numino.net/
alert(external.cur_sel);
2hsfFv http://blog.numino.net/
5. m2_plugin_folder( security_id , plugin_name ) - return the folder path of the specified plugin
d5b45V http://blog.numino.net/
Example:
mC62Dv http://blog.numino.net/
alert(external.m2_plugin_folder( %max_security_id , 'ViewSource!'));
gX1K3Z http://blog.numino.net/
6. m2_run_cmd( security_id , command_id ) - run the specified command ID
9C4H2a http://blog.numino.net/
Example:
1ZZ5JY http://blog.numino.net/
external. m2_run_cmd( %max_security_id , 32772 ));
icwoma 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.
n0JgLq http://blog.numino.net/
7. get_tab( security_id , tab_index ) - return the window object of the specifed tab
fqufo4 http://blog.numino.net/
Example:
rv12tO http://blog.numino.net/
var oWin=external.get_tab(%max_security_id, 0);
TW946l http://blog.numino.net/
alert(oWin.document.URL);
MfV56l http://blog.numino.net/
8. activate_tab( security_id , tab_index ) - activate the specified tab
h1A1M6 http://blog.numino.net/
Example:
ggvCYC http://blog.numino.net/
external.activate_tab(%max_security_id, 0);
1bWH19 http://blog.numino.net/
9. close_tab( security_id , tab_index ) - close the specified tab
m8Cjz6 http://blog.numino.net/
Example:
YaPmcq http://blog.numino.net/
external.close_tab(%max_security_id, 0);
mXjqt4 http://blog.numino.net/
10. readFile( security_id, plugin_name, file_name) - read the content of specified text file
0EWbGr http://blog.numino.net/
Example:
gQO95H http://blog.numino.net/
var sText=external.readFile(%max_security_id, 'ViewPage', 'readme.txt');
ur7uK5 http://blog.numino.net/
alert(sText);
upGsD8 http://blog.numino.net/
11. writeFile( security_id, plugin_name, file_name, content ) - write content to the specific text file
fkwM28 http://blog.numino.net/
Example:
VK9n12 http://blog.numino.net/
external.writeFile(%max_security_id, 'ViewPage', 'test.txt', 'This is the file content');
Qrim4r http://blog.numino.net/
12. m2_readIni( security_id, plugin_name , file_name , section_name , key , default_value) - read data from specific INI file
3d73u1 http://blog.numino.net/
Example:
ggrq8J http://blog.numino.net/
var sDownloadTool=external.m2_readIni(%max_security_id, 'ViewPage', 'plugin.ini', 'Settings', 'Tool', );
6Nh92v http://blog.numino.net/
alert(sDownloadTool);
Z2vy81 http://blog.numino.net/
13. m2_writeIni( security_id , plugin_name , file_name , section_name , key , value ) - write data to specific INI file
UR9coh http://blog.numino.net/
Example:
rd04YY http://blog.numino.net/
external.m2_writeIni(%max_security_id, 'ViewPage', 'test.ini', 'Config', 'height', '100px');
zZUX0e http://blog.numino.net/
14. max_modelessDialog( security_id , url , option , attr , window ) - returns a modeless web page dialog
4oh56D http://blog.numino.net/
Example:
8e8zCh http://blog.numino.net/
var oDialog= external.max_modelessDialog( %max_security_id , 'blank.html', window , , window );
dJ4q9b http://blog.numino.net/
var oDoc=oDialog.document;
2HwiKA http://blog.numino.net/
oDoc.write('Testing');
vQ8mv3 http://blog.numino.net/
oDoc.close();
PVT8JG http://blog.numino.net/
15. max_activex(security_id ,program_id) - return specified ActiveX object
GSTbJ5 http://blog.numino.net/
Example:
Py4fvz http://blog.numino.net/
var oWSH=external.max_activex(%max_security_id, 'WScript.Shell');
FGBycu http://blog.numino.net/
oWSH.run('notepad.exe');
7SOcBu http://blog.numino.net/
16. m2_search_text(security_id) - return the text in search bar
HuCrEz http://blog.numino.net/
Example:
yKd2pc http://blog.numino.net/
alert(m2_search_text(%max_security_id));
oC7I23 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)
enwcv4 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.
5rptI4 http://blog.numino.net/
Example:
P2Cgs0 http://blog.numino.net/
function max_callback(x){
700Mw3 http://blog.numino.net/
if(x=='tab_change') alert('Current tab is changed.');
Kh4lGF http://blog.numino.net/
}
12l378 http://blog.numino.net/
By checking the parameter of the max_callback function, plugin can get the following browser events:
5neCWH http://blog.numino.net/
HTML button plugins
eojnnH http://blog.numino.net/
tab_change – after the current tab is switched
4hM0b1 http://blog.numino.net/
document_Complete - after the current tab is fully loaded
1h4ImM http://blog.numino.net/
self_destroy - when the html is unloaded, usually when Maxthon exits
4T4ij3 http://blog.numino.net/
Script sidebar plugins
56Pw5s http://blog.numino.net/
sidebar_tab_change - after the current tab is switched
Y12ok5 http://blog.numino.net/
sidebar_activate - when the sidebar plugin is activated
cT3v3f http://blog.numino.net/
sidebar_deactivate - when the sidebar plugin is deactivated
4yHjC5 http://blog.numino.net/
sidebar_unload - when the sidebar plugin is unloaded (Maxthon is closed)
ClRphO http://blog.numino.net/
18. max_getObj (for Maxthon 2.0 only) - return various Maxthon objects, including:
GzUdih http://blog.numino.net/
Info - general information about Maxthon
RMiN18 http://blog.numino.net/
Adhunter – about Ad Hunter
I5kcsy http://blog.numino.net/
FavManager – about Favorites
U9N7tn http://blog.numino.net/
RssManager – about RSS
lPhTqA http://blog.numino.net/
PluginManager - about Plugins, for Maxthon 2.0.5 or later
23DRDT http://blog.numino.net/
Example:
i2UV89 http://blog.numino.net/
var oInfo=external.max_getObj(%max_security_id, 'info');
JXDWFF http://blog.numino.net/
Info Object supports the following property and method:
1uUgc3 http://blog.numino.net/
Property:
BsCuao http://blog.numino.net/
fileProxy - read-only, returns the path of the current user's proxy configuration document.
9Kw91D http://blog.numino.net/
Example:
xQwqrw http://blog.numino.net/
var oInfo=external.max_getObj(%max_security_id, 'info');
H6e12J http://blog.numino.net/
alert(oInfo.fileProxy);
28ggfL http://blog.numino.net/
folderUser - read-only, returns the path of the profile folder of the current user
N886Sx http://blog.numino.net/
Example:
04ctIV http://blog.numino.net/
var oInfo=external.max_getObj(%max_security_id, 'info');
cMAK4n http://blog.numino.net/
alert(oInfo. folderUser);
T76Khd http://blog.numino.net/
Method:
1X7kDc http://blog.numino.net/
getFolderPluginData(plugin_name) - obtain the path of plugin data storage folder for the current user and the plugin
8GPf9M http://blog.numino.net/
Example:
7dQsWe http://blog.numino.net/
var oInfo=external.max_getObj(%max_security_id, 'info');
niUb4e http://blog.numino.net/
alert(oInfo.getFolderPluginData('ViewSource!'));
mkFz59 http://blog.numino.net/
AdHunter object support the following method:
LWFShp http://blog.numino.net/
Method:
4891pY http://blog.numino.net/
reloadFilter(filter_name) – reload the specified Maxthon filter (currently content filter only) after modifying the relevant filter
9HJOLh http://blog.numino.net/
Example:
33qWRi http://blog.numino.net/
var oAdHunter=external.max_getObj(%max_security_id, 'AdHunter');
jeka7l http://blog.numino.net/
oAdHunter.reloadFilter('content');
iZG5p9 http://blog.numino.net/
enableFilter(filter_name, bEnable) – enable or disable Maxthon's 'content' or 'popup' filter
3blVsF http://blog.numino.net/
Example:
B9yyrc http://blog.numino.net/
var oAdHunter=external.max_getObj(%max_security_id, 'AdHunter');
445lIm http://blog.numino.net/
oAdHunter.enableFilter ('content', false);
K2wHvH http://blog.numino.net/
PluginManager object support the following method:
mR0B76 http://blog.numino.net/
getPluginFolder - return Maxthon main plugin folder path
bIeAcc http://blog.numino.net/
Example:
84Y66L http://blog.numino.net/
var oPluginManager=external.max_getObj(%max_security_id, 'PluginManager');
CHSv51 http://blog.numino.net/
alert(oPluginManager.getPluginFolder)
OfYEs3 http://blog.numino.net/
getCount - return the number of all installed plugins, both enabled and disabled
WXXtFg http://blog.numino.net/
Example:
c5IDT2 http://blog.numino.net/
var oPluginManager=external.max_getObj(%max_security_id, 'PluginManager');
7YT27e http://blog.numino.net/
alert(oPluginManager.getCount)
XbjB22 http://blog.numino.net/
getList - return a list which contains information like name, author etc of all plugins
69kJTD http://blog.numino.net/
Example:
l317x6 http://blog.numino.net/
var oPluginManager=external.max_getObj(%max_security_id, 'PluginManager');
F2nPEw http://blog.numino.net/
alert(oPluginManager.getList)
LoRG9U http://blog.numino.net/
getPlugin(Index) - Index is a number, return the corresponding plugin object
ovyU7o http://blog.numino.net/
Example:
O1Ttba http://blog.numino.net/
var oPluginManager=external.max_getObj(%max_security_id, 'PluginManager');
hupwLh http://blog.numino.net/
var oPlugin=oPluginManager.getPlugin(0);
rThVEB http://blog.numino.net/
The plugin object returned from getPlugin(Index) supports the following property and method:
8eoMvw http://blog.numino.net/
Property:
FNXywd http://blog.numino.net/
title - read only, return plugin name
c6RHvQ http://blog.numino.net/
Example:
pKPHZw http://blog.numino.net/
alert(oPlugin.title);
r3lUB4 http://blog.numino.net/
folderName - read only, return plugin's folder name
p7256Z http://blog.numino.net/
Example:
wPqVlW http://blog.numino.net/
alert(oPlugin.folderName);
hgZiS8 http://blog.numino.net/
fullPath - read only, return plugin folder's full path
9uBAUs http://blog.numino.net/
Example:
8KCF7r http://blog.numino.net/
alert(oPlugin.fullPath);
LV0IZx http://blog.numino.net/
enable - read/write, return or set if the plugin is enabled
jLSe5x http://blog.numino.net/
Example:
nn9SEV http://blog.numino.net/
oPlugin.enable=false;
Pxs296 http://blog.numino.net/
alert(oPlugin.enable);
0MH5dy http://blog.numino.net/
oPlugin.enable=true;
3uEM74 http://blog.numino.net/
alert(oPlugin.enable);
5RS4p7 http://blog.numino.net/
startAfterPageDone - read/write, return or set if the plugin is auto started
D15IXy http://blog.numino.net/
Example:
9L4Lyq http://blog.numino.net/
oPlugin.startAfterPageDone = true;
DbtM65 http://blog.numino.net/
alert(oPlugin.startAfterPageDone);
g3rsP4 http://blog.numino.net/
oPlugin.startAfterPageDone = false;
pAtxKO http://blog.numino.net/
alert(oPlugin.startAfterPageDone);
A9SCh0 http://blog.numino.net/
startAfterPageDoneUrl - read/write, return or set the address where the plugin will be auto started
tqxI57 http://blog.numino.net/
Example:
54g31Y http://blog.numino.net/
oPlugin.startAfterPageDoneUrl='*maxthon.com*|*maxthon.cn*';
tyD3FT http://blog.numino.net/
alert(oPlugin.startAfterPageDoneUrl);
A1N8ZE http://blog.numino.net/
Methods:
S1u0eP http://blog.numino.net/
config() - open plugin configuration dialog (config.html)
8z40Zv http://blog.numino.net/
Example:
aiYF0d http://blog.numino.net/
oPlugin.config();
4s8S0f http://blog.numino.net/
remove() - delete the plugin
FWI6nL http://blog.numino.net/
Example:
LOnKh1 http://blog.numino.net/
oPlugin.remove();
ZCyIZ6 http://blog.numino.net/
[edit] Mscript
uR5MBx 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...>
WSoTz3 http://blog.numino.net/
Example - the following script button plugin can disable scripting in the current page by changing Maxthon's content control:
naBWf9 http://blog.numino.net/
<script language="javascript">
xDvVsF http://blog.numino.net/
external.m2_run_cmd(%max_security_id, 33175);
0DfXr8 http://blog.numino.net/
</script>
S2689U 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.
02j2v6 http://blog.numino.net/
<mscript language="javascript">
EnC5AN http://blog.numino.net/
external.m2_run_cmd(0, 33175);
RdQgsF http://blog.numino.net/
</script>
3PvXUJ 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