| 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. 4sH0GJ http://blog.numino.net/ How to obtain the Security ID Vxml5E http://blog.numino.net/ 1. Script button plugins can use "%max_security_id" for the Security ID l3i9m3 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。 I8R2n5 http://blog.numino.net/ <script src=max.src></script> 9kDS5e http://blog.numino.net/ Reference for Maxthon Plugin Commands WX6ZTp http://blog.numino.net/ Unless specified otherwise, the following plugin commands are applicable for both Maxthon 2.0 and Maxthon 1.X。 cGPh3G http://blog.numino.net/ 1. max_version - return Maxthon's version number lx0OZZ http://blog.numino.net/ Example: nLojds http://blog.numino.net/ alert(external.max_version); 8VhfiF http://blog.numino.net/ 2. max_language_id - return Maxthon's language ID WursC6 http://blog.numino.net/ Example: VLuO10 http://blog.numino.net/ alert(external.max_language_id); 8cxSvW http://blog.numino.net/ Note: Maxthon 2.0 and Maxthon 1.X have different language ID format qA01jY http://blog.numino.net/ 3. tab_count - return the number of tabs opened by Maxthon IdXoo1 http://blog.numino.net/ Example: J8qdZZ http://blog.numino.net/ alert(external.tab_count); F6r31D http://blog.numino.net/ 4. cur_sel - return the index of Maxthon's current tab 8g9640 http://blog.numino.net/ Example: 4CBvqq http://blog.numino.net/ alert(external.cur_sel); d3C0bb http://blog.numino.net/ 5. m2_plugin_folder( security_id , plugin_name ) - return the folder path of the specified plugin 1I9auX http://blog.numino.net/ Example: N1U76I http://blog.numino.net/ alert(external.m2_plugin_folder( %max_security_id , 'ViewSource!')); YI4MC9 http://blog.numino.net/ 6. m2_run_cmd( security_id , command_id ) - run the specified command ID f6ONK1 http://blog.numino.net/ Example: AyH5EX http://blog.numino.net/ external. m2_run_cmd( %max_security_id , 32772 )); cg5WT2 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. FEMS1z http://blog.numino.net/ 7. get_tab( security_id , tab_index ) - return the window object of the specifed tab UhJJP5 http://blog.numino.net/ Example: vB3nxL http://blog.numino.net/ var oWin=external.get_tab(%max_security_id, 0); h5S1u4 http://blog.numino.net/ alert(oWin.document.URL); Z23JPx http://blog.numino.net/ 8. activate_tab( security_id , tab_index ) - activate the specified tab qZYF02 http://blog.numino.net/ Example: y15Wgv http://blog.numino.net/ external.activate_tab(%max_security_id, 0); 756pJt http://blog.numino.net/ 9. close_tab( security_id , tab_index ) - close the specified tab bCAS8p http://blog.numino.net/ Example: 1GMgv1 http://blog.numino.net/ external.close_tab(%max_security_id, 0); RhXxrn http://blog.numino.net/ 10. readFile( security_id, plugin_name, file_name) - read the content of specified text file mQ0FsH http://blog.numino.net/ Example: eci6fW http://blog.numino.net/ var sText=external.readFile(%max_security_id, 'ViewPage', 'readme.txt'); l5Z2bA http://blog.numino.net/ alert(sText); HCkyRF http://blog.numino.net/ 11. writeFile( security_id, plugin_name, file_name, content ) - write content to the specific text file L0GTZ1 http://blog.numino.net/ Example: 0ARkG6 http://blog.numino.net/ external.writeFile(%max_security_id, 'ViewPage', 'test.txt', 'This is the file content'); 2TtHLG http://blog.numino.net/ 12. m2_readIni( security_id, plugin_name , file_name , section_name , key , default_value) - read data from specific INI file PcrPPz http://blog.numino.net/ Example: 3H4KG4 http://blog.numino.net/ var sDownloadTool=external.m2_readIni(%max_security_id, 'ViewPage', 'plugin.ini', 'Settings', 'Tool', ); 7UIat3 http://blog.numino.net/ alert(sDownloadTool); 6MWSlL http://blog.numino.net/ 13. m2_writeIni( security_id , plugin_name , file_name , section_name , key , value ) - write data to specific INI file tiPjLH http://blog.numino.net/ Example: K45mtG http://blog.numino.net/ external.m2_writeIni(%max_security_id, 'ViewPage', 'test.ini', 'Config', 'height', '100px'); KS76c6 http://blog.numino.net/ 14. max_modelessDialog( security_id , url , option , attr , window ) - returns a modeless web page dialog z79ueZ http://blog.numino.net/ Example: vO0Nx2 http://blog.numino.net/ var oDialog= external.max_modelessDialog( %max_security_id , 'blank.html', window , , window ); YnJOcA http://blog.numino.net/ var oDoc=oDialog.document; R2I7QJ http://blog.numino.net/ oDoc.write('Testing'); A23qE3 http://blog.numino.net/ oDoc.close(); t8IPVy http://blog.numino.net/ 15. max_activex(security_id ,program_id) - return specified ActiveX object U57DF7 http://blog.numino.net/ Example: lc02OJ http://blog.numino.net/ var oWSH=external.max_activex(%max_security_id, 'WScript.Shell'); Z4S10b http://blog.numino.net/ oWSH.run('notepad.exe'); 4MvOi1 http://blog.numino.net/ 16. m2_search_text(security_id) - return the text in search bar 9sHxAt http://blog.numino.net/ Example: suPS6t http://blog.numino.net/ alert(m2_search_text(%max_security_id)); Dr4WOL 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) GJmmR1 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. bAWPrM http://blog.numino.net/ Example: 7U0Imv http://blog.numino.net/ function max_callback(x){ ZB3IU5 http://blog.numino.net/ if(x=='tab_change') alert('Current tab is changed.'); 707Nx1 http://blog.numino.net/ } M21qH8 http://blog.numino.net/ By checking the parameter of the max_callback function, plugin can get the following browser events: J02SQr http://blog.numino.net/ HTML button plugins m2hjFa http://blog.numino.net/ tab_change – after the current tab is switched BJBG8U http://blog.numino.net/ document_Complete - after the current tab is fully loaded L6JXeF http://blog.numino.net/ self_destroy - when the html is unloaded, usually when Maxthon exits 52j69i http://blog.numino.net/ Script sidebar plugins qQ168q http://blog.numino.net/ sidebar_tab_change - after the current tab is switched 4M47kG http://blog.numino.net/ sidebar_activate - when the sidebar plugin is activated GBFdd3 http://blog.numino.net/ sidebar_deactivate - when the sidebar plugin is deactivated mZYZKp http://blog.numino.net/ sidebar_unload - when the sidebar plugin is unloaded (Maxthon is closed) OUDGCU http://blog.numino.net/ 18. max_getObj (for Maxthon 2.0 only) - return various Maxthon objects, including: eun18M http://blog.numino.net/ Info - general information about Maxthon vKy84g http://blog.numino.net/ Adhunter – about Ad Hunter o2U990 http://blog.numino.net/ FavManager – about Favorites ygWq4t http://blog.numino.net/ RssManager – about RSS 7ZUw4Q http://blog.numino.net/ PluginManager - about Plugins, for Maxthon 2.0.5 or later 6cHjU2 http://blog.numino.net/ Example: nHQ4ag http://blog.numino.net/ var oInfo=external.max_getObj(%max_security_id, 'info'); zyCr7q http://blog.numino.net/ Info Object supports the following property and method: wlfxUf http://blog.numino.net/ Property: cudiU9 http://blog.numino.net/ fileProxy - read-only, returns the path of the current user's proxy configuration document. UcmpU7 http://blog.numino.net/ Example: t58wV7 http://blog.numino.net/ var oInfo=external.max_getObj(%max_security_id, 'info'); sQdmZo http://blog.numino.net/ alert(oInfo.fileProxy); 5YCKfl http://blog.numino.net/ folderUser - read-only, returns the path of the profile folder of the current user ap9n8s http://blog.numino.net/ Example: 1vHuj5 http://blog.numino.net/ var oInfo=external.max_getObj(%max_security_id, 'info'); oeWJc5 http://blog.numino.net/ alert(oInfo. folderUser); fza8LE http://blog.numino.net/ Method: BbiK6v http://blog.numino.net/ getFolderPluginData(plugin_name) - obtain the path of plugin data storage folder for the current user and the plugin 1N74yt http://blog.numino.net/ Example: r2jfd9 http://blog.numino.net/ var oInfo=external.max_getObj(%max_security_id, 'info'); xnJ1hz http://blog.numino.net/ alert(oInfo.getFolderPluginData('ViewSource!')); BP6nI2 http://blog.numino.net/ AdHunter object support the following method: G0AeXv http://blog.numino.net/ Method: V1bEGG http://blog.numino.net/ reloadFilter(filter_name) – reload the specified Maxthon filter (currently content filter only) after modifying the relevant filter 34h4GK http://blog.numino.net/ Example: KPZSyC http://blog.numino.net/ var oAdHunter=external.max_getObj(%max_security_id, 'AdHunter'); ZvXO2W http://blog.numino.net/ oAdHunter.reloadFilter('content'); XYgNy7 http://blog.numino.net/ enableFilter(filter_name, bEnable) – enable or disable Maxthon's 'content' or 'popup' filter lnIXYn http://blog.numino.net/ Example: 7IXX3s http://blog.numino.net/ var oAdHunter=external.max_getObj(%max_security_id, 'AdHunter'); JJA2Hy http://blog.numino.net/ oAdHunter.enableFilter ('content', false); uHZL8j http://blog.numino.net/ PluginManager object support the following method: 2XS4M4 http://blog.numino.net/ getPluginFolder - return Maxthon main plugin folder path 0j4sn4 http://blog.numino.net/ Example: HoJPJ3 http://blog.numino.net/ var oPluginManager=external.max_getObj(%max_security_id, 'PluginManager'); 1mc1O9 http://blog.numino.net/ alert(oPluginManager.getPluginFolder) sH5dTD http://blog.numino.net/ getCount - return the number of all installed plugins, both enabled and disabled 9I2x6K http://blog.numino.net/ Example: xnk2q6 http://blog.numino.net/ var oPluginManager=external.max_getObj(%max_security_id, 'PluginManager'); aDLMXU http://blog.numino.net/ alert(oPluginManager.getCount) nbo6JY http://blog.numino.net/ getList - return a list which contains information like name, author etc of all plugins wqRF3x http://blog.numino.net/ Example: A4qVmm http://blog.numino.net/ var oPluginManager=external.max_getObj(%max_security_id, 'PluginManager'); Y67EOx http://blog.numino.net/ alert(oPluginManager.getList) 2cVRO5 http://blog.numino.net/ getPlugin(Index) - Index is a number, return the corresponding plugin object Fip7e7 http://blog.numino.net/ Example: 2oeqVA http://blog.numino.net/ var oPluginManager=external.max_getObj(%max_security_id, 'PluginManager'); D5wa6u http://blog.numino.net/ var oPlugin=oPluginManager.getPlugin(0); E1w6Zw http://blog.numino.net/ The plugin object returned from getPlugin(Index) supports the following property and method: Fb4HJa http://blog.numino.net/ Property: vTvBks http://blog.numino.net/ title - read only, return plugin name myGXWd http://blog.numino.net/ Example: 6ilXu0 http://blog.numino.net/ alert(oPlugin.title); iDaKW1 http://blog.numino.net/ folderName - read only, return plugin's folder name 6Ov3Xc http://blog.numino.net/ Example: U9fc0h http://blog.numino.net/ alert(oPlugin.folderName); LcYi8E http://blog.numino.net/ fullPath - read only, return plugin folder's full path 3aJQiY http://blog.numino.net/ Example: H0bAnz http://blog.numino.net/ alert(oPlugin.fullPath); ZykcP9 http://blog.numino.net/ enable - read/write, return or set if the plugin is enabled 7DPAX3 http://blog.numino.net/ Example: v5SJl1 http://blog.numino.net/ oPlugin.enable=false; OpoGe8 http://blog.numino.net/ alert(oPlugin.enable); 4aOS0x http://blog.numino.net/ oPlugin.enable=true; aOm0rM http://blog.numino.net/ alert(oPlugin.enable); LWBFqS http://blog.numino.net/ startAfterPageDone - read/write, return or set if the plugin is auto started e4SO1e http://blog.numino.net/ Example: uDn9SO http://blog.numino.net/ oPlugin.startAfterPageDone = true; i98qKW http://blog.numino.net/ alert(oPlugin.startAfterPageDone); 383p60 http://blog.numino.net/ oPlugin.startAfterPageDone = false; Kf5NPQ http://blog.numino.net/ alert(oPlugin.startAfterPageDone); sUONdT http://blog.numino.net/ startAfterPageDoneUrl - read/write, return or set the address where the plugin will be auto started 2TvsNG http://blog.numino.net/ Example: V0J9Cz http://blog.numino.net/ oPlugin.startAfterPageDoneUrl='*maxthon.com*|*maxthon.cn*'; IM0VBV http://blog.numino.net/ alert(oPlugin.startAfterPageDoneUrl); wz1WFC http://blog.numino.net/ Methods: HeJ2qu http://blog.numino.net/ config() - open plugin configuration dialog (config.html) SE27r3 http://blog.numino.net/ Example: dD950Z http://blog.numino.net/ oPlugin.config(); G75yVb http://blog.numino.net/ remove() - delete the plugin H2s1M8 http://blog.numino.net/ Example: 8Z4f36 http://blog.numino.net/ oPlugin.remove(); ff5Nba http://blog.numino.net/ [edit] Mscript xVblgw 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...> XxdR0c http://blog.numino.net/ Example - the following script button plugin can disable scripting in the current page by changing Maxthon's content control: EhFma2 http://blog.numino.net/ <script language="javascript"> gp00bR http://blog.numino.net/ external.m2_run_cmd(%max_security_id, 33175); 9wlcC8 http://blog.numino.net/ </script> K3K534 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. Xzqea0 http://blog.numino.net/ <mscript language="javascript"> CLYtK6 http://blog.numino.net/ external.m2_run_cmd(0, 33175); WFI392 http://blog.numino.net/ </script> gwPtO8 http://blog.numino.net/ Note an arbitrary number can be used as %max_security_id when mscript is used
|
|