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. OUVmf4 http://blog.numino.net/ How to obtain the Security ID OzdXVg http://blog.numino.net/ 1. Script button plugins can use "%max_security_id" for the Security ID Ix8N25 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。 byzjsM http://blog.numino.net/ <script src=max.src></script> 4xhRfB http://blog.numino.net/ Reference for Maxthon Plugin Commands QOpk24 http://blog.numino.net/ Unless specified otherwise, the following plugin commands are applicable for both Maxthon 2.0 and Maxthon 1.X。 JCy53R http://blog.numino.net/ 1. max_version - return Maxthon's version number Q8r53T http://blog.numino.net/ Example: MxD4sL http://blog.numino.net/ alert(external.max_version); Gt5Q43 http://blog.numino.net/ 2. max_language_id - return Maxthon's language ID wJ6xOV http://blog.numino.net/ Example: j2tb62 http://blog.numino.net/ alert(external.max_language_id); O7513c http://blog.numino.net/ Note: Maxthon 2.0 and Maxthon 1.X have different language ID format kb2gKr http://blog.numino.net/ 3. tab_count - return the number of tabs opened by Maxthon 4WHk8L http://blog.numino.net/ Example: RFq0Ju http://blog.numino.net/ alert(external.tab_count); 2U8Khx http://blog.numino.net/ 4. cur_sel - return the index of Maxthon's current tab B22tW4 http://blog.numino.net/ Example: dWrlOL http://blog.numino.net/ alert(external.cur_sel); yBuBXD http://blog.numino.net/ 5. m2_plugin_folder( security_id , plugin_name ) - return the folder path of the specified plugin k23Ye1 http://blog.numino.net/ Example: 793se7 http://blog.numino.net/ alert(external.m2_plugin_folder( %max_security_id , 'ViewSource!')); d9GdBy http://blog.numino.net/ 6. m2_run_cmd( security_id , command_id ) - run the specified command ID Ufe9cb http://blog.numino.net/ Example: 7YrCy8 http://blog.numino.net/ external. m2_run_cmd( %max_security_id , 32772 )); lIoYiQ 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. C9RcK6 http://blog.numino.net/ 7. get_tab( security_id , tab_index ) - return the window object of the specifed tab y6m2ky http://blog.numino.net/ Example: Fah4fV http://blog.numino.net/ var oWin=external.get_tab(%max_security_id, 0); KTGuuP http://blog.numino.net/ alert(oWin.document.URL); RAywsa http://blog.numino.net/ 8. activate_tab( security_id , tab_index ) - activate the specified tab 88WWP3 http://blog.numino.net/ Example: 5Dks5Z http://blog.numino.net/ external.activate_tab(%max_security_id, 0); FC2NGR http://blog.numino.net/ 9. close_tab( security_id , tab_index ) - close the specified tab t2l5By http://blog.numino.net/ Example: ZR7yia http://blog.numino.net/ external.close_tab(%max_security_id, 0); jf8o5a http://blog.numino.net/ 10. readFile( security_id, plugin_name, file_name) - read the content of specified text file jZNfxi http://blog.numino.net/ Example: 45KLN8 http://blog.numino.net/ var sText=external.readFile(%max_security_id, 'ViewPage', 'readme.txt'); BmdIu1 http://blog.numino.net/ alert(sText); VQb0E0 http://blog.numino.net/ 11. writeFile( security_id, plugin_name, file_name, content ) - write content to the specific text file YIjcUM http://blog.numino.net/ Example: AjpOO5 http://blog.numino.net/ external.writeFile(%max_security_id, 'ViewPage', 'test.txt', 'This is the file content'); Fu3wUt http://blog.numino.net/ 12. m2_readIni( security_id, plugin_name , file_name , section_name , key , default_value) - read data from specific INI file af1ZMn http://blog.numino.net/ Example: 2IBHT0 http://blog.numino.net/ var sDownloadTool=external.m2_readIni(%max_security_id, 'ViewPage', 'plugin.ini', 'Settings', 'Tool', ); Ndr4SB http://blog.numino.net/ alert(sDownloadTool); 0l628z http://blog.numino.net/ 13. m2_writeIni( security_id , plugin_name , file_name , section_name , key , value ) - write data to specific INI file 26z76S http://blog.numino.net/ Example: Prjs4F http://blog.numino.net/ external.m2_writeIni(%max_security_id, 'ViewPage', 'test.ini', 'Config', 'height', '100px'); 6dauyc http://blog.numino.net/ 14. max_modelessDialog( security_id , url , option , attr , window ) - returns a modeless web page dialog n0k1BL http://blog.numino.net/ Example: 6S5Djc http://blog.numino.net/ var oDialog= external.max_modelessDialog( %max_security_id , 'blank.html', window , , window ); 2jIP3z http://blog.numino.net/ var oDoc=oDialog.document; 8Yvlzy http://blog.numino.net/ oDoc.write('Testing'); t1gC5g http://blog.numino.net/ oDoc.close(); rRqdQ5 http://blog.numino.net/ 15. max_activex(security_id ,program_id) - return specified ActiveX object IZLcZ9 http://blog.numino.net/ Example: 8KSRZT http://blog.numino.net/ var oWSH=external.max_activex(%max_security_id, 'WScript.Shell'); cdQ9s6 http://blog.numino.net/ oWSH.run('notepad.exe'); 2TTjd1 http://blog.numino.net/ 16. m2_search_text(security_id) - return the text in search bar XcGVeV http://blog.numino.net/ Example: CPmCoN http://blog.numino.net/ alert(m2_search_text(%max_security_id)); llgtUj 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) 5brnrm 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. 9XmWUj http://blog.numino.net/ Example: CRgrU9 http://blog.numino.net/ function max_callback(x){ jmC30A http://blog.numino.net/ if(x=='tab_change') alert('Current tab is changed.'); KM3Ypa http://blog.numino.net/ } gs7AK3 http://blog.numino.net/ By checking the parameter of the max_callback function, plugin can get the following browser events: hH06pc http://blog.numino.net/ HTML button plugins 8E0NKx http://blog.numino.net/ tab_change – after the current tab is switched 3zBui9 http://blog.numino.net/ document_Complete - after the current tab is fully loaded PXGQiB http://blog.numino.net/ self_destroy - when the html is unloaded, usually when Maxthon exits 3oOx97 http://blog.numino.net/ Script sidebar plugins 53Ua3D http://blog.numino.net/ sidebar_tab_change - after the current tab is switched pu9A5Q http://blog.numino.net/ sidebar_activate - when the sidebar plugin is activated Bnd74x http://blog.numino.net/ sidebar_deactivate - when the sidebar plugin is deactivated c1GSHr http://blog.numino.net/ sidebar_unload - when the sidebar plugin is unloaded (Maxthon is closed) CHLA2O http://blog.numino.net/ 18. max_getObj (for Maxthon 2.0 only) - return various Maxthon objects, including: My1Q1E http://blog.numino.net/ Info - general information about Maxthon XrkKYX http://blog.numino.net/ Adhunter – about Ad Hunter 9b659z http://blog.numino.net/ FavManager – about Favorites vLiPsO http://blog.numino.net/ RssManager – about RSS 7TrrLX http://blog.numino.net/ PluginManager - about Plugins, for Maxthon 2.0.5 or later o4LZLg http://blog.numino.net/ Example: 9rohWJ http://blog.numino.net/ var oInfo=external.max_getObj(%max_security_id, 'info'); t7OYxJ http://blog.numino.net/ Info Object supports the following property and method: 09f6PR http://blog.numino.net/ Property: 6pen7K http://blog.numino.net/ fileProxy - read-only, returns the path of the current user's proxy configuration document. WH48L5 http://blog.numino.net/ Example: AhR8eD http://blog.numino.net/ var oInfo=external.max_getObj(%max_security_id, 'info'); J3x7bM http://blog.numino.net/ alert(oInfo.fileProxy); 39q05e http://blog.numino.net/ folderUser - read-only, returns the path of the profile folder of the current user UNyQYv http://blog.numino.net/ Example: kv9L7d http://blog.numino.net/ var oInfo=external.max_getObj(%max_security_id, 'info'); u3EV1F http://blog.numino.net/ alert(oInfo. folderUser); 1gVY0U http://blog.numino.net/ Method: KlR3f8 http://blog.numino.net/ getFolderPluginData(plugin_name) - obtain the path of plugin data storage folder for the current user and the plugin xyU5ER http://blog.numino.net/ Example: kd3tEg http://blog.numino.net/ var oInfo=external.max_getObj(%max_security_id, 'info'); zwNpsF http://blog.numino.net/ alert(oInfo.getFolderPluginData('ViewSource!')); rilx5X http://blog.numino.net/ AdHunter object support the following method: 8YHZm0 http://blog.numino.net/ Method: R9rht2 http://blog.numino.net/ reloadFilter(filter_name) – reload the specified Maxthon filter (currently content filter only) after modifying the relevant filter JDfudI http://blog.numino.net/ Example: ld8aQO http://blog.numino.net/ var oAdHunter=external.max_getObj(%max_security_id, 'AdHunter'); iHQnL8 http://blog.numino.net/ oAdHunter.reloadFilter('content'); B3Xy31 http://blog.numino.net/ enableFilter(filter_name, bEnable) – enable or disable Maxthon's 'content' or 'popup' filter yNjo4u http://blog.numino.net/ Example: AUPdC7 http://blog.numino.net/ var oAdHunter=external.max_getObj(%max_security_id, 'AdHunter'); a1vs8x http://blog.numino.net/ oAdHunter.enableFilter ('content', false); pSQLk6 http://blog.numino.net/ PluginManager object support the following method: 041V4x http://blog.numino.net/ getPluginFolder - return Maxthon main plugin folder path rbbeoz http://blog.numino.net/ Example: q3Wyc0 http://blog.numino.net/ var oPluginManager=external.max_getObj(%max_security_id, 'PluginManager'); c0O4q3 http://blog.numino.net/ alert(oPluginManager.getPluginFolder) 9cw03S http://blog.numino.net/ getCount - return the number of all installed plugins, both enabled and disabled 683gz3 http://blog.numino.net/ Example: UYLvFv http://blog.numino.net/ var oPluginManager=external.max_getObj(%max_security_id, 'PluginManager'); 11X991 http://blog.numino.net/ alert(oPluginManager.getCount) RMyH7v http://blog.numino.net/ getList - return a list which contains information like name, author etc of all plugins 0GmNgG http://blog.numino.net/ Example: LMxbyR http://blog.numino.net/ var oPluginManager=external.max_getObj(%max_security_id, 'PluginManager'); cZH596 http://blog.numino.net/ alert(oPluginManager.getList) 4PdI5I http://blog.numino.net/ getPlugin(Index) - Index is a number, return the corresponding plugin object e02i6J http://blog.numino.net/ Example: KJ89MD http://blog.numino.net/ var oPluginManager=external.max_getObj(%max_security_id, 'PluginManager'); 4Kn8PZ http://blog.numino.net/ var oPlugin=oPluginManager.getPlugin(0); 5OzbmK http://blog.numino.net/ The plugin object returned from getPlugin(Index) supports the following property and method: L7pUTw http://blog.numino.net/ Property: Kij7FW http://blog.numino.net/ title - read only, return plugin name XA7Byu http://blog.numino.net/ Example: HxeG8a http://blog.numino.net/ alert(oPlugin.title); 8tY3I3 http://blog.numino.net/ folderName - read only, return plugin's folder name zDxYa7 http://blog.numino.net/ Example: 30yg4o http://blog.numino.net/ alert(oPlugin.folderName); 713ls1 http://blog.numino.net/ fullPath - read only, return plugin folder's full path TcFJZD http://blog.numino.net/ Example: rcGx9r http://blog.numino.net/ alert(oPlugin.fullPath); 0ywZoJ http://blog.numino.net/ enable - read/write, return or set if the plugin is enabled 5RzzUx http://blog.numino.net/ Example: 1nKk9y http://blog.numino.net/ oPlugin.enable=false; 7Md2J4 http://blog.numino.net/ alert(oPlugin.enable); iyA1pl http://blog.numino.net/ oPlugin.enable=true; QV1lyG http://blog.numino.net/ alert(oPlugin.enable); 7yA0cn http://blog.numino.net/ startAfterPageDone - read/write, return or set if the plugin is auto started cCrGlx http://blog.numino.net/ Example: tH6W94 http://blog.numino.net/ oPlugin.startAfterPageDone = true; 7Q5957 http://blog.numino.net/ alert(oPlugin.startAfterPageDone); 3gcP5t http://blog.numino.net/ oPlugin.startAfterPageDone = false; 06tUVK http://blog.numino.net/ alert(oPlugin.startAfterPageDone); TFG691 http://blog.numino.net/ startAfterPageDoneUrl - read/write, return or set the address where the plugin will be auto started Ispe4f http://blog.numino.net/ Example: 5vI7Lc http://blog.numino.net/ oPlugin.startAfterPageDoneUrl='*maxthon.com*|*maxthon.cn*'; UtuX3a http://blog.numino.net/ alert(oPlugin.startAfterPageDoneUrl); j05Pm6 http://blog.numino.net/ Methods: lnOwM8 http://blog.numino.net/ config() - open plugin configuration dialog (config.html) LiT4Tu http://blog.numino.net/ Example: TRc20a http://blog.numino.net/ oPlugin.config(); X4s08r http://blog.numino.net/ remove() - delete the plugin BnjCoO http://blog.numino.net/ Example: y4FpJA http://blog.numino.net/ oPlugin.remove(); y8St66 http://blog.numino.net/ [edit] Mscript cDbggD 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...> oUr9UA http://blog.numino.net/ Example - the following script button plugin can disable scripting in the current page by changing Maxthon's content control: Da4969 http://blog.numino.net/ <script language="javascript"> hS1Tzc http://blog.numino.net/ external.m2_run_cmd(%max_security_id, 33175); yCSd1D http://blog.numino.net/ </script> MGstSr 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. nNhxWJ http://blog.numino.net/ <mscript language="javascript"> IpOkW4 http://blog.numino.net/ external.m2_run_cmd(0, 33175); 78IvYP http://blog.numino.net/ </script> VgAa8O http://blog.numino.net/ Note an arbitrary number can be used as %max_security_id when mscript is used
|
|