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. vc6FNR http://blog.numino.net/ How to obtain the Security ID Pkz9Ts http://blog.numino.net/ 1. Script button plugins can use "%max_security_id" for the Security ID tvIqDs 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。 j6FqrE http://blog.numino.net/ <script src=max.src></script> nfkjsQ http://blog.numino.net/ Reference for Maxthon Plugin Commands t412uy http://blog.numino.net/ Unless specified otherwise, the following plugin commands are applicable for both Maxthon 2.0 and Maxthon 1.X。 8P9qW7 http://blog.numino.net/ 1. max_version - return Maxthon's version number pzioH5 http://blog.numino.net/ Example: 9LuorU http://blog.numino.net/ alert(external.max_version); CHxz50 http://blog.numino.net/ 2. max_language_id - return Maxthon's language ID pTh3Hy http://blog.numino.net/ Example: 4wd1l8 http://blog.numino.net/ alert(external.max_language_id); JwOUkR http://blog.numino.net/ Note: Maxthon 2.0 and Maxthon 1.X have different language ID format TgrgL3 http://blog.numino.net/ 3. tab_count - return the number of tabs opened by Maxthon dnCs9l http://blog.numino.net/ Example: 7kkfe7 http://blog.numino.net/ alert(external.tab_count); mrmQb2 http://blog.numino.net/ 4. cur_sel - return the index of Maxthon's current tab 1MByV3 http://blog.numino.net/ Example: Xw02y4 http://blog.numino.net/ alert(external.cur_sel); vR3h05 http://blog.numino.net/ 5. m2_plugin_folder( security_id , plugin_name ) - return the folder path of the specified plugin 6Ln79M http://blog.numino.net/ Example: gK6K4X http://blog.numino.net/ alert(external.m2_plugin_folder( %max_security_id , 'ViewSource!')); pesz45 http://blog.numino.net/ 6. m2_run_cmd( security_id , command_id ) - run the specified command ID HlFnLN http://blog.numino.net/ Example: WJnZOu http://blog.numino.net/ external. m2_run_cmd( %max_security_id , 32772 )); n7V3f0 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. 5xF7cE http://blog.numino.net/ 7. get_tab( security_id , tab_index ) - return the window object of the specifed tab 2k3MpD http://blog.numino.net/ Example: PGF73l http://blog.numino.net/ var oWin=external.get_tab(%max_security_id, 0); U36a36 http://blog.numino.net/ alert(oWin.document.URL); BSq551 http://blog.numino.net/ 8. activate_tab( security_id , tab_index ) - activate the specified tab k32W15 http://blog.numino.net/ Example: o5Ug9p http://blog.numino.net/ external.activate_tab(%max_security_id, 0); NY4fwr http://blog.numino.net/ 9. close_tab( security_id , tab_index ) - close the specified tab TF8nVV http://blog.numino.net/ Example: vFQl8H http://blog.numino.net/ external.close_tab(%max_security_id, 0); V1a6l4 http://blog.numino.net/ 10. readFile( security_id, plugin_name, file_name) - read the content of specified text file RAxhk1 http://blog.numino.net/ Example: t8Ha0G http://blog.numino.net/ var sText=external.readFile(%max_security_id, 'ViewPage', 'readme.txt'); sw0zs1 http://blog.numino.net/ alert(sText); TQCMV7 http://blog.numino.net/ 11. writeFile( security_id, plugin_name, file_name, content ) - write content to the specific text file T7rVkN http://blog.numino.net/ Example: fIsc9w http://blog.numino.net/ external.writeFile(%max_security_id, 'ViewPage', 'test.txt', 'This is the file content'); wyc66O http://blog.numino.net/ 12. m2_readIni( security_id, plugin_name , file_name , section_name , key , default_value) - read data from specific INI file 4F5eBZ http://blog.numino.net/ Example: AcUCeM http://blog.numino.net/ var sDownloadTool=external.m2_readIni(%max_security_id, 'ViewPage', 'plugin.ini', 'Settings', 'Tool', ); y1OSC4 http://blog.numino.net/ alert(sDownloadTool); 9cesB6 http://blog.numino.net/ 13. m2_writeIni( security_id , plugin_name , file_name , section_name , key , value ) - write data to specific INI file ban7VK http://blog.numino.net/ Example: D44Q22 http://blog.numino.net/ external.m2_writeIni(%max_security_id, 'ViewPage', 'test.ini', 'Config', 'height', '100px'); io5NmO http://blog.numino.net/ 14. max_modelessDialog( security_id , url , option , attr , window ) - returns a modeless web page dialog J3PqSq http://blog.numino.net/ Example: BVd375 http://blog.numino.net/ var oDialog= external.max_modelessDialog( %max_security_id , 'blank.html', window , , window ); 4J3kFI http://blog.numino.net/ var oDoc=oDialog.document; EVnytT http://blog.numino.net/ oDoc.write('Testing'); euAkmo http://blog.numino.net/ oDoc.close(); 1YThkh http://blog.numino.net/ 15. max_activex(security_id ,program_id) - return specified ActiveX object S31WyI http://blog.numino.net/ Example: 7bKid2 http://blog.numino.net/ var oWSH=external.max_activex(%max_security_id, 'WScript.Shell'); CVYw5o http://blog.numino.net/ oWSH.run('notepad.exe'); DaeB91 http://blog.numino.net/ 16. m2_search_text(security_id) - return the text in search bar WEiL9u http://blog.numino.net/ Example: I2uKqC http://blog.numino.net/ alert(m2_search_text(%max_security_id)); auy1dC 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) PmP0eK 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. rNjTwy http://blog.numino.net/ Example: eLCm4a http://blog.numino.net/ function max_callback(x){ ybkrRZ http://blog.numino.net/ if(x=='tab_change') alert('Current tab is changed.'); 2Kcn2F http://blog.numino.net/ } SgxbTX http://blog.numino.net/ By checking the parameter of the max_callback function, plugin can get the following browser events: Gr9qfq http://blog.numino.net/ HTML button plugins gG60l0 http://blog.numino.net/ tab_change – after the current tab is switched P5cRL7 http://blog.numino.net/ document_Complete - after the current tab is fully loaded AObk9c http://blog.numino.net/ self_destroy - when the html is unloaded, usually when Maxthon exits 7d6e8o http://blog.numino.net/ Script sidebar plugins 0iN6mE http://blog.numino.net/ sidebar_tab_change - after the current tab is switched 50oysE http://blog.numino.net/ sidebar_activate - when the sidebar plugin is activated cR4R5R http://blog.numino.net/ sidebar_deactivate - when the sidebar plugin is deactivated 4KYeC1 http://blog.numino.net/ sidebar_unload - when the sidebar plugin is unloaded (Maxthon is closed) kS68eI http://blog.numino.net/ 18. max_getObj (for Maxthon 2.0 only) - return various Maxthon objects, including: SO2olz http://blog.numino.net/ Info - general information about Maxthon 23PTsw http://blog.numino.net/ Adhunter – about Ad Hunter F859m1 http://blog.numino.net/ FavManager – about Favorites 2P1xb9 http://blog.numino.net/ RssManager – about RSS 8l48GL http://blog.numino.net/ PluginManager - about Plugins, for Maxthon 2.0.5 or later pWV6HL http://blog.numino.net/ Example: 18eqPy http://blog.numino.net/ var oInfo=external.max_getObj(%max_security_id, 'info'); 1tZrNE http://blog.numino.net/ Info Object supports the following property and method: wbO6Ug http://blog.numino.net/ Property: iQq87V http://blog.numino.net/ fileProxy - read-only, returns the path of the current user's proxy configuration document. atse75 http://blog.numino.net/ Example: KYHh3u http://blog.numino.net/ var oInfo=external.max_getObj(%max_security_id, 'info'); po9rk7 http://blog.numino.net/ alert(oInfo.fileProxy); 7K0FY7 http://blog.numino.net/ folderUser - read-only, returns the path of the profile folder of the current user 7ri9aa http://blog.numino.net/ Example: Z34djG http://blog.numino.net/ var oInfo=external.max_getObj(%max_security_id, 'info'); RPX4Bh http://blog.numino.net/ alert(oInfo. folderUser); xLi56d http://blog.numino.net/ Method: 28qgWo http://blog.numino.net/ getFolderPluginData(plugin_name) - obtain the path of plugin data storage folder for the current user and the plugin NMtgCY http://blog.numino.net/ Example: lkQHFy http://blog.numino.net/ var oInfo=external.max_getObj(%max_security_id, 'info'); 5STu6x http://blog.numino.net/ alert(oInfo.getFolderPluginData('ViewSource!')); 9eGevl http://blog.numino.net/ AdHunter object support the following method: uwWUZ5 http://blog.numino.net/ Method: Ba93a4 http://blog.numino.net/ reloadFilter(filter_name) – reload the specified Maxthon filter (currently content filter only) after modifying the relevant filter R24O31 http://blog.numino.net/ Example: i2jyhD http://blog.numino.net/ var oAdHunter=external.max_getObj(%max_security_id, 'AdHunter'); CwMS24 http://blog.numino.net/ oAdHunter.reloadFilter('content'); 6Xa694 http://blog.numino.net/ enableFilter(filter_name, bEnable) – enable or disable Maxthon's 'content' or 'popup' filter eHTN01 http://blog.numino.net/ Example: SJNSHN http://blog.numino.net/ var oAdHunter=external.max_getObj(%max_security_id, 'AdHunter'); 2Ekh04 http://blog.numino.net/ oAdHunter.enableFilter ('content', false); mA5qSL http://blog.numino.net/ PluginManager object support the following method: LAJ44F http://blog.numino.net/ getPluginFolder - return Maxthon main plugin folder path QlBp10 http://blog.numino.net/ Example: obwFWs http://blog.numino.net/ var oPluginManager=external.max_getObj(%max_security_id, 'PluginManager'); ofIFuW http://blog.numino.net/ alert(oPluginManager.getPluginFolder) nIO5rG http://blog.numino.net/ getCount - return the number of all installed plugins, both enabled and disabled 7BTUy4 http://blog.numino.net/ Example: fLrE5U http://blog.numino.net/ var oPluginManager=external.max_getObj(%max_security_id, 'PluginManager'); u8j5On http://blog.numino.net/ alert(oPluginManager.getCount) 0PpEfc http://blog.numino.net/ getList - return a list which contains information like name, author etc of all plugins 0v2A4N http://blog.numino.net/ Example: RiurP2 http://blog.numino.net/ var oPluginManager=external.max_getObj(%max_security_id, 'PluginManager'); KWoKV0 http://blog.numino.net/ alert(oPluginManager.getList) 1PQG4k http://blog.numino.net/ getPlugin(Index) - Index is a number, return the corresponding plugin object Wer9T8 http://blog.numino.net/ Example: WhXMLF http://blog.numino.net/ var oPluginManager=external.max_getObj(%max_security_id, 'PluginManager'); 81881W http://blog.numino.net/ var oPlugin=oPluginManager.getPlugin(0); KPx6mC http://blog.numino.net/ The plugin object returned from getPlugin(Index) supports the following property and method: N3EkhA http://blog.numino.net/ Property: 1Y3yeE http://blog.numino.net/ title - read only, return plugin name c66gp8 http://blog.numino.net/ Example: b9o53q http://blog.numino.net/ alert(oPlugin.title); e3FtUS http://blog.numino.net/ folderName - read only, return plugin's folder name c0maC7 http://blog.numino.net/ Example: ca9t4d http://blog.numino.net/ alert(oPlugin.folderName); ICfXWR http://blog.numino.net/ fullPath - read only, return plugin folder's full path T02erV http://blog.numino.net/ Example: M3nwKF http://blog.numino.net/ alert(oPlugin.fullPath); 20FD1J http://blog.numino.net/ enable - read/write, return or set if the plugin is enabled qzZfPJ http://blog.numino.net/ Example: ELwXqp http://blog.numino.net/ oPlugin.enable=false; 4IeoHw http://blog.numino.net/ alert(oPlugin.enable); hLG8RG http://blog.numino.net/ oPlugin.enable=true; iW1yb6 http://blog.numino.net/ alert(oPlugin.enable); pNGPYg http://blog.numino.net/ startAfterPageDone - read/write, return or set if the plugin is auto started 66oU8k http://blog.numino.net/ Example: MVK354 http://blog.numino.net/ oPlugin.startAfterPageDone = true; tZWTB1 http://blog.numino.net/ alert(oPlugin.startAfterPageDone); YQGzoS http://blog.numino.net/ oPlugin.startAfterPageDone = false; 59hMn3 http://blog.numino.net/ alert(oPlugin.startAfterPageDone); t61G5N http://blog.numino.net/ startAfterPageDoneUrl - read/write, return or set the address where the plugin will be auto started 756fAM http://blog.numino.net/ Example: FqitJO http://blog.numino.net/ oPlugin.startAfterPageDoneUrl='*maxthon.com*|*maxthon.cn*'; Ui1qZP http://blog.numino.net/ alert(oPlugin.startAfterPageDoneUrl); 43m15C http://blog.numino.net/ Methods: QhK03X http://blog.numino.net/ config() - open plugin configuration dialog (config.html) cz1d12 http://blog.numino.net/ Example: xZ33Q4 http://blog.numino.net/ oPlugin.config(); ka6mf5 http://blog.numino.net/ remove() - delete the plugin n2mCSN http://blog.numino.net/ Example: r9HyT7 http://blog.numino.net/ oPlugin.remove(); lErU3E http://blog.numino.net/ [edit] Mscript ovzvSN 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...> Oaq15s http://blog.numino.net/ Example - the following script button plugin can disable scripting in the current page by changing Maxthon's content control: Rge0Xt http://blog.numino.net/ <script language="javascript"> 96L82p http://blog.numino.net/ external.m2_run_cmd(%max_security_id, 33175); 5odHqC http://blog.numino.net/ </script> oSS2Em 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. doU43J http://blog.numino.net/ <mscript language="javascript"> Y8qgJW http://blog.numino.net/ external.m2_run_cmd(0, 33175); wv7B0S http://blog.numino.net/ </script> NVddB9 http://blog.numino.net/ Note an arbitrary number can be used as %max_security_id when mscript is used
|
|