| 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. QXK0J3 http://blog.numino.net/ How to obtain the Security ID MP37Ew http://blog.numino.net/ 1. Script button plugins can use "%max_security_id" for the Security ID 0x6Ktp 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。 lG9ddP http://blog.numino.net/ <script src=max.src></script> nkHhSa http://blog.numino.net/ Reference for Maxthon Plugin Commands y2sc4d http://blog.numino.net/ Unless specified otherwise, the following plugin commands are applicable for both Maxthon 2.0 and Maxthon 1.X。 s9H7gb http://blog.numino.net/ 1. max_version - return Maxthon's version number Ibxxhm http://blog.numino.net/ Example: 2Qa11H http://blog.numino.net/ alert(external.max_version); eBQ9r2 http://blog.numino.net/ 2. max_language_id - return Maxthon's language ID kH6DbP http://blog.numino.net/ Example: ED0782 http://blog.numino.net/ alert(external.max_language_id); x7QhaX http://blog.numino.net/ Note: Maxthon 2.0 and Maxthon 1.X have different language ID format 78bA3m http://blog.numino.net/ 3. tab_count - return the number of tabs opened by Maxthon CNNaDe http://blog.numino.net/ Example: lFz1nl http://blog.numino.net/ alert(external.tab_count); 4l9g1U http://blog.numino.net/ 4. cur_sel - return the index of Maxthon's current tab NG5qkz http://blog.numino.net/ Example: AenlK3 http://blog.numino.net/ alert(external.cur_sel); aUPZWB http://blog.numino.net/ 5. m2_plugin_folder( security_id , plugin_name ) - return the folder path of the specified plugin R4MeOQ http://blog.numino.net/ Example: Cv2V2f http://blog.numino.net/ alert(external.m2_plugin_folder( %max_security_id , 'ViewSource!')); Wp14xz http://blog.numino.net/ 6. m2_run_cmd( security_id , command_id ) - run the specified command ID 7kPqyx http://blog.numino.net/ Example: 8w4HAD http://blog.numino.net/ external. m2_run_cmd( %max_security_id , 32772 )); bi103i 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. PK9MLo http://blog.numino.net/ 7. get_tab( security_id , tab_index ) - return the window object of the specifed tab lh6uY1 http://blog.numino.net/ Example: P30hG8 http://blog.numino.net/ var oWin=external.get_tab(%max_security_id, 0); GYjnNq http://blog.numino.net/ alert(oWin.document.URL); e5irnh http://blog.numino.net/ 8. activate_tab( security_id , tab_index ) - activate the specified tab 9oxfl3 http://blog.numino.net/ Example: o00R79 http://blog.numino.net/ external.activate_tab(%max_security_id, 0); ijvi0V http://blog.numino.net/ 9. close_tab( security_id , tab_index ) - close the specified tab K0K3xf http://blog.numino.net/ Example: GIjv8f http://blog.numino.net/ external.close_tab(%max_security_id, 0); ljK57C http://blog.numino.net/ 10. readFile( security_id, plugin_name, file_name) - read the content of specified text file 22wEJc http://blog.numino.net/ Example: dymXEL http://blog.numino.net/ var sText=external.readFile(%max_security_id, 'ViewPage', 'readme.txt'); WTR3xJ http://blog.numino.net/ alert(sText); 1nATdw http://blog.numino.net/ 11. writeFile( security_id, plugin_name, file_name, content ) - write content to the specific text file p7K2i5 http://blog.numino.net/ Example: 5FCal4 http://blog.numino.net/ external.writeFile(%max_security_id, 'ViewPage', 'test.txt', 'This is the file content'); FGU6X2 http://blog.numino.net/ 12. m2_readIni( security_id, plugin_name , file_name , section_name , key , default_value) - read data from specific INI file AdVBUo http://blog.numino.net/ Example: Jm6cRr http://blog.numino.net/ var sDownloadTool=external.m2_readIni(%max_security_id, 'ViewPage', 'plugin.ini', 'Settings', 'Tool', ); rhhEyw http://blog.numino.net/ alert(sDownloadTool); R03081 http://blog.numino.net/ 13. m2_writeIni( security_id , plugin_name , file_name , section_name , key , value ) - write data to specific INI file vw0928 http://blog.numino.net/ Example: UAjAFD http://blog.numino.net/ external.m2_writeIni(%max_security_id, 'ViewPage', 'test.ini', 'Config', 'height', '100px'); CP8Gin http://blog.numino.net/ 14. max_modelessDialog( security_id , url , option , attr , window ) - returns a modeless web page dialog 5I31hI http://blog.numino.net/ Example: 0nqzb0 http://blog.numino.net/ var oDialog= external.max_modelessDialog( %max_security_id , 'blank.html', window , , window ); 60F153 http://blog.numino.net/ var oDoc=oDialog.document; fB956l http://blog.numino.net/ oDoc.write('Testing'); mX92g0 http://blog.numino.net/ oDoc.close(); 3ySJ3b http://blog.numino.net/ 15. max_activex(security_id ,program_id) - return specified ActiveX object cTXuJI http://blog.numino.net/ Example: BDiD1b http://blog.numino.net/ var oWSH=external.max_activex(%max_security_id, 'WScript.Shell'); Pb9UYs http://blog.numino.net/ oWSH.run('notepad.exe'); eGNSZG http://blog.numino.net/ 16. m2_search_text(security_id) - return the text in search bar LObucH http://blog.numino.net/ Example: 1ha3PP http://blog.numino.net/ alert(m2_search_text(%max_security_id)); 7NgtUf 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) ZAq4ys 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. Oao8Je http://blog.numino.net/ Example: YzcJrI http://blog.numino.net/ function max_callback(x){ GcVlgP http://blog.numino.net/ if(x=='tab_change') alert('Current tab is changed.'); pH6YsB http://blog.numino.net/ } WifK72 http://blog.numino.net/ By checking the parameter of the max_callback function, plugin can get the following browser events: 3KLvaT http://blog.numino.net/ HTML button plugins D9094u http://blog.numino.net/ tab_change – after the current tab is switched D474B9 http://blog.numino.net/ document_Complete - after the current tab is fully loaded IQR6Y2 http://blog.numino.net/ self_destroy - when the html is unloaded, usually when Maxthon exits Ce6icj http://blog.numino.net/ Script sidebar plugins JxNp76 http://blog.numino.net/ sidebar_tab_change - after the current tab is switched 2GJk8K http://blog.numino.net/ sidebar_activate - when the sidebar plugin is activated Cx3MoG http://blog.numino.net/ sidebar_deactivate - when the sidebar plugin is deactivated 0L1SWw http://blog.numino.net/ sidebar_unload - when the sidebar plugin is unloaded (Maxthon is closed) TPxa9R http://blog.numino.net/ 18. max_getObj (for Maxthon 2.0 only) - return various Maxthon objects, including: 60KsFp http://blog.numino.net/ Info - general information about Maxthon 5f3cRy http://blog.numino.net/ Adhunter – about Ad Hunter yd7M53 http://blog.numino.net/ FavManager – about Favorites sfMmf0 http://blog.numino.net/ RssManager – about RSS ToTOYi http://blog.numino.net/ PluginManager - about Plugins, for Maxthon 2.0.5 or later 51pD8D http://blog.numino.net/ Example: z3dnb9 http://blog.numino.net/ var oInfo=external.max_getObj(%max_security_id, 'info'); 4qIx8k http://blog.numino.net/ Info Object supports the following property and method: 6juq49 http://blog.numino.net/ Property: ZtTkJU http://blog.numino.net/ fileProxy - read-only, returns the path of the current user's proxy configuration document. mVB31P http://blog.numino.net/ Example: 3PeXkS http://blog.numino.net/ var oInfo=external.max_getObj(%max_security_id, 'info'); DVNbp4 http://blog.numino.net/ alert(oInfo.fileProxy); AX0Z2b http://blog.numino.net/ folderUser - read-only, returns the path of the profile folder of the current user raBe4v http://blog.numino.net/ Example: 9lxLSZ http://blog.numino.net/ var oInfo=external.max_getObj(%max_security_id, 'info'); POq81r http://blog.numino.net/ alert(oInfo. folderUser); ch04P1 http://blog.numino.net/ Method: 41M16U http://blog.numino.net/ getFolderPluginData(plugin_name) - obtain the path of plugin data storage folder for the current user and the plugin 0Yc5hG http://blog.numino.net/ Example: EbRh7Q http://blog.numino.net/ var oInfo=external.max_getObj(%max_security_id, 'info'); iD1QAK http://blog.numino.net/ alert(oInfo.getFolderPluginData('ViewSource!')); vN4EbL http://blog.numino.net/ AdHunter object support the following method: M39yOK http://blog.numino.net/ Method: o0Db79 http://blog.numino.net/ reloadFilter(filter_name) – reload the specified Maxthon filter (currently content filter only) after modifying the relevant filter V8gPJg http://blog.numino.net/ Example: Vc81M6 http://blog.numino.net/ var oAdHunter=external.max_getObj(%max_security_id, 'AdHunter'); BO0E5b http://blog.numino.net/ oAdHunter.reloadFilter('content'); yz5lI9 http://blog.numino.net/ enableFilter(filter_name, bEnable) – enable or disable Maxthon's 'content' or 'popup' filter 3Hbqj1 http://blog.numino.net/ Example: 64cal3 http://blog.numino.net/ var oAdHunter=external.max_getObj(%max_security_id, 'AdHunter'); JOEg4h http://blog.numino.net/ oAdHunter.enableFilter ('content', false); fKJ739 http://blog.numino.net/ PluginManager object support the following method: 0rzbZ2 http://blog.numino.net/ getPluginFolder - return Maxthon main plugin folder path w72Men http://blog.numino.net/ Example: H7ffFi http://blog.numino.net/ var oPluginManager=external.max_getObj(%max_security_id, 'PluginManager'); L4Hjha http://blog.numino.net/ alert(oPluginManager.getPluginFolder) Qfme2s http://blog.numino.net/ getCount - return the number of all installed plugins, both enabled and disabled b1u8Et http://blog.numino.net/ Example: zIb61l http://blog.numino.net/ var oPluginManager=external.max_getObj(%max_security_id, 'PluginManager'); FKLlRX http://blog.numino.net/ alert(oPluginManager.getCount) 6nWO9k http://blog.numino.net/ getList - return a list which contains information like name, author etc of all plugins WhgRJo http://blog.numino.net/ Example: 1t20ga http://blog.numino.net/ var oPluginManager=external.max_getObj(%max_security_id, 'PluginManager'); dRYm3c http://blog.numino.net/ alert(oPluginManager.getList) 0w8Rhu http://blog.numino.net/ getPlugin(Index) - Index is a number, return the corresponding plugin object 7U0n02 http://blog.numino.net/ Example: nCfAqU http://blog.numino.net/ var oPluginManager=external.max_getObj(%max_security_id, 'PluginManager'); n8wq21 http://blog.numino.net/ var oPlugin=oPluginManager.getPlugin(0); K2hBw2 http://blog.numino.net/ The plugin object returned from getPlugin(Index) supports the following property and method: sf7v5w http://blog.numino.net/ Property: y72vZ8 http://blog.numino.net/ title - read only, return plugin name jTbxb2 http://blog.numino.net/ Example: 5QRGT4 http://blog.numino.net/ alert(oPlugin.title); 80tjGD http://blog.numino.net/ folderName - read only, return plugin's folder name RT3yha http://blog.numino.net/ Example: r3XhA4 http://blog.numino.net/ alert(oPlugin.folderName); uP2tV2 http://blog.numino.net/ fullPath - read only, return plugin folder's full path OV7MBX http://blog.numino.net/ Example: 2u0cgd http://blog.numino.net/ alert(oPlugin.fullPath); wwAYJ6 http://blog.numino.net/ enable - read/write, return or set if the plugin is enabled 5wp3L2 http://blog.numino.net/ Example: d8BTP6 http://blog.numino.net/ oPlugin.enable=false; l4E61I http://blog.numino.net/ alert(oPlugin.enable); 50Sx10 http://blog.numino.net/ oPlugin.enable=true; uwEd61 http://blog.numino.net/ alert(oPlugin.enable); 06H1Pj http://blog.numino.net/ startAfterPageDone - read/write, return or set if the plugin is auto started BSsovh http://blog.numino.net/ Example: dUvh1P http://blog.numino.net/ oPlugin.startAfterPageDone = true; kf3r3B http://blog.numino.net/ alert(oPlugin.startAfterPageDone); PmstmH http://blog.numino.net/ oPlugin.startAfterPageDone = false; 1lR5S9 http://blog.numino.net/ alert(oPlugin.startAfterPageDone); Say1mX http://blog.numino.net/ startAfterPageDoneUrl - read/write, return or set the address where the plugin will be auto started bmYTOJ http://blog.numino.net/ Example: XNKY5Y http://blog.numino.net/ oPlugin.startAfterPageDoneUrl='*maxthon.com*|*maxthon.cn*'; Frg9u7 http://blog.numino.net/ alert(oPlugin.startAfterPageDoneUrl); 8XwJ3S http://blog.numino.net/ Methods: i2a7h9 http://blog.numino.net/ config() - open plugin configuration dialog (config.html) BN5zEL http://blog.numino.net/ Example: nUPUjB http://blog.numino.net/ oPlugin.config(); Jce57e http://blog.numino.net/ remove() - delete the plugin YhV60f http://blog.numino.net/ Example: DgnBo6 http://blog.numino.net/ oPlugin.remove(); 5y5VJD http://blog.numino.net/ [edit] Mscript L1Q1vd 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...> REuAou http://blog.numino.net/ Example - the following script button plugin can disable scripting in the current page by changing Maxthon's content control: ug9Qey http://blog.numino.net/ <script language="javascript"> fgtu6A http://blog.numino.net/ external.m2_run_cmd(%max_security_id, 33175); rH824z http://blog.numino.net/ </script> 5T21nH 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. fS81h8 http://blog.numino.net/ <mscript language="javascript"> sI1lQY http://blog.numino.net/ external.m2_run_cmd(0, 33175); sKduNa http://blog.numino.net/ </script> lr6DUK http://blog.numino.net/ Note an arbitrary number can be used as %max_security_id when mscript is used
|
|