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. 4La1da http://blog.numino.net/ How to obtain the Security ID I3sfXk http://blog.numino.net/ 1. Script button plugins can use "%max_security_id" for the Security ID 85pviy 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。 EO1M97 http://blog.numino.net/ <script src=max.src></script> 358jUJ http://blog.numino.net/ Reference for Maxthon Plugin Commands fmTHmj http://blog.numino.net/ Unless specified otherwise, the following plugin commands are applicable for both Maxthon 2.0 and Maxthon 1.X。 S8oC1T http://blog.numino.net/ 1. max_version - return Maxthon's version number f485RY http://blog.numino.net/ Example: MCfrPD http://blog.numino.net/ alert(external.max_version); L4z4Qc http://blog.numino.net/ 2. max_language_id - return Maxthon's language ID XvMGx5 http://blog.numino.net/ Example: BLj2Ix http://blog.numino.net/ alert(external.max_language_id); ZHoSVI http://blog.numino.net/ Note: Maxthon 2.0 and Maxthon 1.X have different language ID format 2K1p41 http://blog.numino.net/ 3. tab_count - return the number of tabs opened by Maxthon 4Ry1Ge http://blog.numino.net/ Example: Fc3R28 http://blog.numino.net/ alert(external.tab_count); 5OZRfK http://blog.numino.net/ 4. cur_sel - return the index of Maxthon's current tab 2E9z5z http://blog.numino.net/ Example: 5vir5Y http://blog.numino.net/ alert(external.cur_sel); 5fNI7y http://blog.numino.net/ 5. m2_plugin_folder( security_id , plugin_name ) - return the folder path of the specified plugin XzbFn2 http://blog.numino.net/ Example: cog0Hl http://blog.numino.net/ alert(external.m2_plugin_folder( %max_security_id , 'ViewSource!')); Eu4nk1 http://blog.numino.net/ 6. m2_run_cmd( security_id , command_id ) - run the specified command ID ZcupID http://blog.numino.net/ Example: PPrHZo http://blog.numino.net/ external. m2_run_cmd( %max_security_id , 32772 )); J3uJft 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. Ep2ZiN http://blog.numino.net/ 7. get_tab( security_id , tab_index ) - return the window object of the specifed tab y5Mr4n http://blog.numino.net/ Example: 5oIVCN http://blog.numino.net/ var oWin=external.get_tab(%max_security_id, 0); 5F7MyN http://blog.numino.net/ alert(oWin.document.URL); 3jhaxs http://blog.numino.net/ 8. activate_tab( security_id , tab_index ) - activate the specified tab 41JzX5 http://blog.numino.net/ Example: 544iHR http://blog.numino.net/ external.activate_tab(%max_security_id, 0); p6406a http://blog.numino.net/ 9. close_tab( security_id , tab_index ) - close the specified tab qGvhxg http://blog.numino.net/ Example: v1tNhZ http://blog.numino.net/ external.close_tab(%max_security_id, 0); v0cWSN http://blog.numino.net/ 10. readFile( security_id, plugin_name, file_name) - read the content of specified text file l9Yfw4 http://blog.numino.net/ Example: Xa70DK http://blog.numino.net/ var sText=external.readFile(%max_security_id, 'ViewPage', 'readme.txt'); glJqLz http://blog.numino.net/ alert(sText); leGPBR http://blog.numino.net/ 11. writeFile( security_id, plugin_name, file_name, content ) - write content to the specific text file 64n1ZX http://blog.numino.net/ Example: QjA4Cs http://blog.numino.net/ external.writeFile(%max_security_id, 'ViewPage', 'test.txt', 'This is the file content'); LH7R4I http://blog.numino.net/ 12. m2_readIni( security_id, plugin_name , file_name , section_name , key , default_value) - read data from specific INI file 1131Uz http://blog.numino.net/ Example: amp22D http://blog.numino.net/ var sDownloadTool=external.m2_readIni(%max_security_id, 'ViewPage', 'plugin.ini', 'Settings', 'Tool', ); kw74UL http://blog.numino.net/ alert(sDownloadTool); TDYZ0A http://blog.numino.net/ 13. m2_writeIni( security_id , plugin_name , file_name , section_name , key , value ) - write data to specific INI file fnYhJf http://blog.numino.net/ Example: w0cLj2 http://blog.numino.net/ external.m2_writeIni(%max_security_id, 'ViewPage', 'test.ini', 'Config', 'height', '100px'); EXht05 http://blog.numino.net/ 14. max_modelessDialog( security_id , url , option , attr , window ) - returns a modeless web page dialog np83F1 http://blog.numino.net/ Example: 308811 http://blog.numino.net/ var oDialog= external.max_modelessDialog( %max_security_id , 'blank.html', window , , window ); J3vWJz http://blog.numino.net/ var oDoc=oDialog.document; cwImBa http://blog.numino.net/ oDoc.write('Testing'); A5l5mC http://blog.numino.net/ oDoc.close(); XlxBPS http://blog.numino.net/ 15. max_activex(security_id ,program_id) - return specified ActiveX object So9dQI http://blog.numino.net/ Example: PaMkT0 http://blog.numino.net/ var oWSH=external.max_activex(%max_security_id, 'WScript.Shell'); rTCi3f http://blog.numino.net/ oWSH.run('notepad.exe'); wNaEV2 http://blog.numino.net/ 16. m2_search_text(security_id) - return the text in search bar aQB3P2 http://blog.numino.net/ Example: 3FBYwh http://blog.numino.net/ alert(m2_search_text(%max_security_id)); 7e0t8V 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) itQ922 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. 2elq25 http://blog.numino.net/ Example: Zpe3PN http://blog.numino.net/ function max_callback(x){ 0iFVCy http://blog.numino.net/ if(x=='tab_change') alert('Current tab is changed.'); I2TH41 http://blog.numino.net/ } 9O8856 http://blog.numino.net/ By checking the parameter of the max_callback function, plugin can get the following browser events: ZYn9TR http://blog.numino.net/ HTML button plugins 0nKjT0 http://blog.numino.net/ tab_change – after the current tab is switched uFmuI2 http://blog.numino.net/ document_Complete - after the current tab is fully loaded 1Dvu29 http://blog.numino.net/ self_destroy - when the html is unloaded, usually when Maxthon exits 3x6QGa http://blog.numino.net/ Script sidebar plugins 8huIXI http://blog.numino.net/ sidebar_tab_change - after the current tab is switched F19SA6 http://blog.numino.net/ sidebar_activate - when the sidebar plugin is activated 9N42PU http://blog.numino.net/ sidebar_deactivate - when the sidebar plugin is deactivated rOLqK8 http://blog.numino.net/ sidebar_unload - when the sidebar plugin is unloaded (Maxthon is closed) 8Chpvw http://blog.numino.net/ 18. max_getObj (for Maxthon 2.0 only) - return various Maxthon objects, including: 7Pyrmf http://blog.numino.net/ Info - general information about Maxthon 4ha9JG http://blog.numino.net/ Adhunter – about Ad Hunter 60QIxI http://blog.numino.net/ FavManager – about Favorites rls7qY http://blog.numino.net/ RssManager – about RSS CV7P3B http://blog.numino.net/ PluginManager - about Plugins, for Maxthon 2.0.5 or later pn44PL http://blog.numino.net/ Example: 332M2v http://blog.numino.net/ var oInfo=external.max_getObj(%max_security_id, 'info'); fpJYFX http://blog.numino.net/ Info Object supports the following property and method: 03hp43 http://blog.numino.net/ Property: 6gXRAH http://blog.numino.net/ fileProxy - read-only, returns the path of the current user's proxy configuration document. De8bjW http://blog.numino.net/ Example: DW5hkZ http://blog.numino.net/ var oInfo=external.max_getObj(%max_security_id, 'info'); 5XZFSJ http://blog.numino.net/ alert(oInfo.fileProxy); S0j0j1 http://blog.numino.net/ folderUser - read-only, returns the path of the profile folder of the current user 7e0TOe http://blog.numino.net/ Example: ytTkTG http://blog.numino.net/ var oInfo=external.max_getObj(%max_security_id, 'info'); lxyf2z http://blog.numino.net/ alert(oInfo. folderUser); 5h6z09 http://blog.numino.net/ Method: 3N0jtq http://blog.numino.net/ getFolderPluginData(plugin_name) - obtain the path of plugin data storage folder for the current user and the plugin 8oBHO2 http://blog.numino.net/ Example: DVDA9H http://blog.numino.net/ var oInfo=external.max_getObj(%max_security_id, 'info'); RB3b7h http://blog.numino.net/ alert(oInfo.getFolderPluginData('ViewSource!')); fToZ9A http://blog.numino.net/ AdHunter object support the following method: 9g2RtV http://blog.numino.net/ Method: 8iuI1L http://blog.numino.net/ reloadFilter(filter_name) – reload the specified Maxthon filter (currently content filter only) after modifying the relevant filter pGTWC6 http://blog.numino.net/ Example: Cbj3TR http://blog.numino.net/ var oAdHunter=external.max_getObj(%max_security_id, 'AdHunter'); 4IDjiY http://blog.numino.net/ oAdHunter.reloadFilter('content'); mC0OoR http://blog.numino.net/ enableFilter(filter_name, bEnable) – enable or disable Maxthon's 'content' or 'popup' filter PU8WPR http://blog.numino.net/ Example: etGuVk http://blog.numino.net/ var oAdHunter=external.max_getObj(%max_security_id, 'AdHunter'); pPIBhP http://blog.numino.net/ oAdHunter.enableFilter ('content', false); Vs1AFN http://blog.numino.net/ PluginManager object support the following method: u72gal http://blog.numino.net/ getPluginFolder - return Maxthon main plugin folder path nZKQEU http://blog.numino.net/ Example: XFdM58 http://blog.numino.net/ var oPluginManager=external.max_getObj(%max_security_id, 'PluginManager'); Z2RD7E http://blog.numino.net/ alert(oPluginManager.getPluginFolder) J708Y8 http://blog.numino.net/ getCount - return the number of all installed plugins, both enabled and disabled piy4KO http://blog.numino.net/ Example: ladyEd http://blog.numino.net/ var oPluginManager=external.max_getObj(%max_security_id, 'PluginManager'); z4xMRf http://blog.numino.net/ alert(oPluginManager.getCount) UjnqfL http://blog.numino.net/ getList - return a list which contains information like name, author etc of all plugins 1FT2Eg http://blog.numino.net/ Example: E1xgb6 http://blog.numino.net/ var oPluginManager=external.max_getObj(%max_security_id, 'PluginManager'); W7MO6j http://blog.numino.net/ alert(oPluginManager.getList) 0P35cr http://blog.numino.net/ getPlugin(Index) - Index is a number, return the corresponding plugin object UdkSGp http://blog.numino.net/ Example: RCyNeM http://blog.numino.net/ var oPluginManager=external.max_getObj(%max_security_id, 'PluginManager'); 9QJ95z http://blog.numino.net/ var oPlugin=oPluginManager.getPlugin(0); Jx5Fka http://blog.numino.net/ The plugin object returned from getPlugin(Index) supports the following property and method: DAm9Q3 http://blog.numino.net/ Property: i5o1PH http://blog.numino.net/ title - read only, return plugin name jp8n5M http://blog.numino.net/ Example: aT4POB http://blog.numino.net/ alert(oPlugin.title); 98WO7t http://blog.numino.net/ folderName - read only, return plugin's folder name SZo3sB http://blog.numino.net/ Example: lA1WJh http://blog.numino.net/ alert(oPlugin.folderName); 88zBZh http://blog.numino.net/ fullPath - read only, return plugin folder's full path xIt20W http://blog.numino.net/ Example: v0rPjK http://blog.numino.net/ alert(oPlugin.fullPath); lBmf5O http://blog.numino.net/ enable - read/write, return or set if the plugin is enabled 9fJE7i http://blog.numino.net/ Example: 9TjTNx http://blog.numino.net/ oPlugin.enable=false; ISSaa5 http://blog.numino.net/ alert(oPlugin.enable); FyQD9b http://blog.numino.net/ oPlugin.enable=true; 7PKk9t http://blog.numino.net/ alert(oPlugin.enable); tWL3p5 http://blog.numino.net/ startAfterPageDone - read/write, return or set if the plugin is auto started C2rPmD http://blog.numino.net/ Example: 51tkz0 http://blog.numino.net/ oPlugin.startAfterPageDone = true; 40WYrQ http://blog.numino.net/ alert(oPlugin.startAfterPageDone); 1hXcJw http://blog.numino.net/ oPlugin.startAfterPageDone = false; 0abLVC http://blog.numino.net/ alert(oPlugin.startAfterPageDone); U5BMyE http://blog.numino.net/ startAfterPageDoneUrl - read/write, return or set the address where the plugin will be auto started edz4X7 http://blog.numino.net/ Example: 6Pk6UK http://blog.numino.net/ oPlugin.startAfterPageDoneUrl='*maxthon.com*|*maxthon.cn*'; 8Kai2F http://blog.numino.net/ alert(oPlugin.startAfterPageDoneUrl); 9EYgU7 http://blog.numino.net/ Methods: 8pCwbc http://blog.numino.net/ config() - open plugin configuration dialog (config.html) 37qOWM http://blog.numino.net/ Example: TuvZ0m http://blog.numino.net/ oPlugin.config(); ocAQ75 http://blog.numino.net/ remove() - delete the plugin gASN8n http://blog.numino.net/ Example: Ysxj9x http://blog.numino.net/ oPlugin.remove(); 86PA4y http://blog.numino.net/ [edit] Mscript uUsMgP 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...> QVWQK6 http://blog.numino.net/ Example - the following script button plugin can disable scripting in the current page by changing Maxthon's content control: An9cmw http://blog.numino.net/ <script language="javascript"> yLJ8Nq http://blog.numino.net/ external.m2_run_cmd(%max_security_id, 33175); 9b3Oe8 http://blog.numino.net/ </script> SG2f7j 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. Mxde7R http://blog.numino.net/ <mscript language="javascript"> PH0nng http://blog.numino.net/ external.m2_run_cmd(0, 33175); 3zF4A4 http://blog.numino.net/ </script> r8E8X4 http://blog.numino.net/ Note an arbitrary number can be used as %max_security_id when mscript is used
|
|