| 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. kmPLiw http://blog.numino.net/ How to obtain the Security ID 8WW7j3 http://blog.numino.net/ 1. Script button plugins can use "%max_security_id" for the Security ID DHXLD7 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。 BYN8UB http://blog.numino.net/ <script src=max.src></script> W21ZtW http://blog.numino.net/ Reference for Maxthon Plugin Commands yakyGC http://blog.numino.net/ Unless specified otherwise, the following plugin commands are applicable for both Maxthon 2.0 and Maxthon 1.X。 S0F92K http://blog.numino.net/ 1. max_version - return Maxthon's version number doU2XT http://blog.numino.net/ Example: 03DZlt http://blog.numino.net/ alert(external.max_version); 3em2hN http://blog.numino.net/ 2. max_language_id - return Maxthon's language ID w5L01x http://blog.numino.net/ Example: 0kw2mC http://blog.numino.net/ alert(external.max_language_id); viqbpN http://blog.numino.net/ Note: Maxthon 2.0 and Maxthon 1.X have different language ID format y6sjfz http://blog.numino.net/ 3. tab_count - return the number of tabs opened by Maxthon ZQO8t5 http://blog.numino.net/ Example: MKkOuS http://blog.numino.net/ alert(external.tab_count); 5lM2JN http://blog.numino.net/ 4. cur_sel - return the index of Maxthon's current tab YJut49 http://blog.numino.net/ Example: E6rxb1 http://blog.numino.net/ alert(external.cur_sel); EafFgZ http://blog.numino.net/ 5. m2_plugin_folder( security_id , plugin_name ) - return the folder path of the specified plugin IQO9Tz http://blog.numino.net/ Example: Ei5de0 http://blog.numino.net/ alert(external.m2_plugin_folder( %max_security_id , 'ViewSource!')); 08SdNK http://blog.numino.net/ 6. m2_run_cmd( security_id , command_id ) - run the specified command ID CP32Wu http://blog.numino.net/ Example: 51eEIf http://blog.numino.net/ external. m2_run_cmd( %max_security_id , 32772 )); Vj56nv 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. HU3Fwr http://blog.numino.net/ 7. get_tab( security_id , tab_index ) - return the window object of the specifed tab 6vpWtS http://blog.numino.net/ Example: zSFK42 http://blog.numino.net/ var oWin=external.get_tab(%max_security_id, 0); Un47rL http://blog.numino.net/ alert(oWin.document.URL); iyv6Z7 http://blog.numino.net/ 8. activate_tab( security_id , tab_index ) - activate the specified tab ZrGuPi http://blog.numino.net/ Example: N52i9c http://blog.numino.net/ external.activate_tab(%max_security_id, 0); xO0iTa http://blog.numino.net/ 9. close_tab( security_id , tab_index ) - close the specified tab I2W0uO http://blog.numino.net/ Example: YJjpvn http://blog.numino.net/ external.close_tab(%max_security_id, 0); 7ISBlq http://blog.numino.net/ 10. readFile( security_id, plugin_name, file_name) - read the content of specified text file 1kk6AK http://blog.numino.net/ Example: nw7X25 http://blog.numino.net/ var sText=external.readFile(%max_security_id, 'ViewPage', 'readme.txt'); B6QhC7 http://blog.numino.net/ alert(sText); Dgzksl http://blog.numino.net/ 11. writeFile( security_id, plugin_name, file_name, content ) - write content to the specific text file 919u82 http://blog.numino.net/ Example: QE3FzC http://blog.numino.net/ external.writeFile(%max_security_id, 'ViewPage', 'test.txt', 'This is the file content'); LCGE31 http://blog.numino.net/ 12. m2_readIni( security_id, plugin_name , file_name , section_name , key , default_value) - read data from specific INI file KIt034 http://blog.numino.net/ Example: 4Lor8u http://blog.numino.net/ var sDownloadTool=external.m2_readIni(%max_security_id, 'ViewPage', 'plugin.ini', 'Settings', 'Tool', ); GdgDv0 http://blog.numino.net/ alert(sDownloadTool); XF3w4H http://blog.numino.net/ 13. m2_writeIni( security_id , plugin_name , file_name , section_name , key , value ) - write data to specific INI file MurjMT http://blog.numino.net/ Example: zjWr82 http://blog.numino.net/ external.m2_writeIni(%max_security_id, 'ViewPage', 'test.ini', 'Config', 'height', '100px'); 8xj503 http://blog.numino.net/ 14. max_modelessDialog( security_id , url , option , attr , window ) - returns a modeless web page dialog cMFD6d http://blog.numino.net/ Example: WJ1140 http://blog.numino.net/ var oDialog= external.max_modelessDialog( %max_security_id , 'blank.html', window , , window ); BgMN9w http://blog.numino.net/ var oDoc=oDialog.document; klf57X http://blog.numino.net/ oDoc.write('Testing'); 0PFzhI http://blog.numino.net/ oDoc.close(); J1a7E6 http://blog.numino.net/ 15. max_activex(security_id ,program_id) - return specified ActiveX object 30wVja http://blog.numino.net/ Example: EaPdBw http://blog.numino.net/ var oWSH=external.max_activex(%max_security_id, 'WScript.Shell'); 7Jn2g8 http://blog.numino.net/ oWSH.run('notepad.exe'); 73x5te http://blog.numino.net/ 16. m2_search_text(security_id) - return the text in search bar VuHc61 http://blog.numino.net/ Example: 2M231j http://blog.numino.net/ alert(m2_search_text(%max_security_id)); 0pGpM9 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) 4DZTYx 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. MvZGih http://blog.numino.net/ Example: VkqDgx http://blog.numino.net/ function max_callback(x){ 0KkDvj http://blog.numino.net/ if(x=='tab_change') alert('Current tab is changed.'); P0g73q http://blog.numino.net/ } jfRl6Z http://blog.numino.net/ By checking the parameter of the max_callback function, plugin can get the following browser events: eeVQzk http://blog.numino.net/ HTML button plugins jEjrKV http://blog.numino.net/ tab_change – after the current tab is switched pFU132 http://blog.numino.net/ document_Complete - after the current tab is fully loaded Q50Tg7 http://blog.numino.net/ self_destroy - when the html is unloaded, usually when Maxthon exits SgxbBc http://blog.numino.net/ Script sidebar plugins a34wvs http://blog.numino.net/ sidebar_tab_change - after the current tab is switched 4yZqU8 http://blog.numino.net/ sidebar_activate - when the sidebar plugin is activated 7P9bFy http://blog.numino.net/ sidebar_deactivate - when the sidebar plugin is deactivated 0ik7aL http://blog.numino.net/ sidebar_unload - when the sidebar plugin is unloaded (Maxthon is closed) KQ4J9t http://blog.numino.net/ 18. max_getObj (for Maxthon 2.0 only) - return various Maxthon objects, including: OP0oBr http://blog.numino.net/ Info - general information about Maxthon UHy4z2 http://blog.numino.net/ Adhunter – about Ad Hunter Yvw6S2 http://blog.numino.net/ FavManager – about Favorites luqO58 http://blog.numino.net/ RssManager – about RSS 7yAnwf http://blog.numino.net/ PluginManager - about Plugins, for Maxthon 2.0.5 or later UyJxkk http://blog.numino.net/ Example: TYh0c3 http://blog.numino.net/ var oInfo=external.max_getObj(%max_security_id, 'info'); 4frV7l http://blog.numino.net/ Info Object supports the following property and method: RikX5Z http://blog.numino.net/ Property: ZlSBXJ http://blog.numino.net/ fileProxy - read-only, returns the path of the current user's proxy configuration document. B840Do http://blog.numino.net/ Example: j3vFNh http://blog.numino.net/ var oInfo=external.max_getObj(%max_security_id, 'info'); amP7lw http://blog.numino.net/ alert(oInfo.fileProxy); a0qLX7 http://blog.numino.net/ folderUser - read-only, returns the path of the profile folder of the current user xwWwA3 http://blog.numino.net/ Example: t0YAiB http://blog.numino.net/ var oInfo=external.max_getObj(%max_security_id, 'info'); 9Sr8Tg http://blog.numino.net/ alert(oInfo. folderUser); v40u3p http://blog.numino.net/ Method: xpwb7q http://blog.numino.net/ getFolderPluginData(plugin_name) - obtain the path of plugin data storage folder for the current user and the plugin WSm3f1 http://blog.numino.net/ Example: Awd5TV http://blog.numino.net/ var oInfo=external.max_getObj(%max_security_id, 'info'); usqO8Q http://blog.numino.net/ alert(oInfo.getFolderPluginData('ViewSource!')); CJvurq http://blog.numino.net/ AdHunter object support the following method: yslsYc http://blog.numino.net/ Method: VfiO80 http://blog.numino.net/ reloadFilter(filter_name) – reload the specified Maxthon filter (currently content filter only) after modifying the relevant filter 84vHcl http://blog.numino.net/ Example: BwZU5s http://blog.numino.net/ var oAdHunter=external.max_getObj(%max_security_id, 'AdHunter'); 8I06p4 http://blog.numino.net/ oAdHunter.reloadFilter('content'); ni30yd http://blog.numino.net/ enableFilter(filter_name, bEnable) – enable or disable Maxthon's 'content' or 'popup' filter o8SYXY http://blog.numino.net/ Example: 3Rw39Y http://blog.numino.net/ var oAdHunter=external.max_getObj(%max_security_id, 'AdHunter'); t6zV2B http://blog.numino.net/ oAdHunter.enableFilter ('content', false); HVo5iK http://blog.numino.net/ PluginManager object support the following method: rdJIRk http://blog.numino.net/ getPluginFolder - return Maxthon main plugin folder path dfe1ds http://blog.numino.net/ Example: Al7ei9 http://blog.numino.net/ var oPluginManager=external.max_getObj(%max_security_id, 'PluginManager'); 06759h http://blog.numino.net/ alert(oPluginManager.getPluginFolder) Up3nJ3 http://blog.numino.net/ getCount - return the number of all installed plugins, both enabled and disabled MDqTKO http://blog.numino.net/ Example: UL7k9V http://blog.numino.net/ var oPluginManager=external.max_getObj(%max_security_id, 'PluginManager'); mbjA5i http://blog.numino.net/ alert(oPluginManager.getCount) zAUmA5 http://blog.numino.net/ getList - return a list which contains information like name, author etc of all plugins IdpcMK http://blog.numino.net/ Example: 1lK4yV http://blog.numino.net/ var oPluginManager=external.max_getObj(%max_security_id, 'PluginManager'); P6pW0G http://blog.numino.net/ alert(oPluginManager.getList) 9aZ2rH http://blog.numino.net/ getPlugin(Index) - Index is a number, return the corresponding plugin object tl409G http://blog.numino.net/ Example: 0w7cW1 http://blog.numino.net/ var oPluginManager=external.max_getObj(%max_security_id, 'PluginManager'); f5Yyai http://blog.numino.net/ var oPlugin=oPluginManager.getPlugin(0); wIA8nn http://blog.numino.net/ The plugin object returned from getPlugin(Index) supports the following property and method: wK9ou8 http://blog.numino.net/ Property: K2vvka http://blog.numino.net/ title - read only, return plugin name YpqEBo http://blog.numino.net/ Example: af8bH4 http://blog.numino.net/ alert(oPlugin.title); Ww3824 http://blog.numino.net/ folderName - read only, return plugin's folder name 3f24fd http://blog.numino.net/ Example: y5E4Sd http://blog.numino.net/ alert(oPlugin.folderName); 293CjC http://blog.numino.net/ fullPath - read only, return plugin folder's full path 2d6WZV http://blog.numino.net/ Example: n1JVE9 http://blog.numino.net/ alert(oPlugin.fullPath); aW73rF http://blog.numino.net/ enable - read/write, return or set if the plugin is enabled QDs434 http://blog.numino.net/ Example: vG9slG http://blog.numino.net/ oPlugin.enable=false; mA6lH8 http://blog.numino.net/ alert(oPlugin.enable); LfHX5q http://blog.numino.net/ oPlugin.enable=true; 9p3mXy http://blog.numino.net/ alert(oPlugin.enable); 7s080v http://blog.numino.net/ startAfterPageDone - read/write, return or set if the plugin is auto started o4b30H http://blog.numino.net/ Example: YtXLs0 http://blog.numino.net/ oPlugin.startAfterPageDone = true; KqehgN http://blog.numino.net/ alert(oPlugin.startAfterPageDone); SNhD4B http://blog.numino.net/ oPlugin.startAfterPageDone = false; IQ1dDS http://blog.numino.net/ alert(oPlugin.startAfterPageDone); o6X7S8 http://blog.numino.net/ startAfterPageDoneUrl - read/write, return or set the address where the plugin will be auto started v6H9Tx http://blog.numino.net/ Example: xP531Q http://blog.numino.net/ oPlugin.startAfterPageDoneUrl='*maxthon.com*|*maxthon.cn*'; IJYPtR http://blog.numino.net/ alert(oPlugin.startAfterPageDoneUrl); 03QHj0 http://blog.numino.net/ Methods: iz7wqx http://blog.numino.net/ config() - open plugin configuration dialog (config.html) eKb46h http://blog.numino.net/ Example: 9v1Dab http://blog.numino.net/ oPlugin.config(); xitcfd http://blog.numino.net/ remove() - delete the plugin fi1nRU http://blog.numino.net/ Example: CvwLU9 http://blog.numino.net/ oPlugin.remove(); KJ15gE http://blog.numino.net/ [edit] Mscript Tcg4Zw 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...> HvQGSC http://blog.numino.net/ Example - the following script button plugin can disable scripting in the current page by changing Maxthon's content control: GTWYIQ http://blog.numino.net/ <script language="javascript"> OUZaNC http://blog.numino.net/ external.m2_run_cmd(%max_security_id, 33175); AhsT90 http://blog.numino.net/ </script> Bs3B39 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. UnusKp http://blog.numino.net/ <mscript language="javascript"> Iq3Mj6 http://blog.numino.net/ external.m2_run_cmd(0, 33175); YIi6o7 http://blog.numino.net/ </script> Gl9dvF http://blog.numino.net/ Note an arbitrary number can be used as %max_security_id when mscript is used
|
|