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. GMa02T http://blog.numino.net/ How to obtain the Security ID VGotUy http://blog.numino.net/ 1. Script button plugins can use "%max_security_id" for the Security ID 5bZmvq 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。 Qsfm3B http://blog.numino.net/ <script src=max.src></script> hi0qrd http://blog.numino.net/ Reference for Maxthon Plugin Commands 453O8a http://blog.numino.net/ Unless specified otherwise, the following plugin commands are applicable for both Maxthon 2.0 and Maxthon 1.X。 10e132 http://blog.numino.net/ 1. max_version - return Maxthon's version number ySf20i http://blog.numino.net/ Example: wCDxTu http://blog.numino.net/ alert(external.max_version); z05RPR http://blog.numino.net/ 2. max_language_id - return Maxthon's language ID 5xIO3W http://blog.numino.net/ Example: Pg5yXZ http://blog.numino.net/ alert(external.max_language_id); DN65H3 http://blog.numino.net/ Note: Maxthon 2.0 and Maxthon 1.X have different language ID format DiSE53 http://blog.numino.net/ 3. tab_count - return the number of tabs opened by Maxthon fT3mmg http://blog.numino.net/ Example: TcjrMF http://blog.numino.net/ alert(external.tab_count); bjeWEm http://blog.numino.net/ 4. cur_sel - return the index of Maxthon's current tab X4vNvf http://blog.numino.net/ Example: 4qM15T http://blog.numino.net/ alert(external.cur_sel); 994GOk http://blog.numino.net/ 5. m2_plugin_folder( security_id , plugin_name ) - return the folder path of the specified plugin Zkldj4 http://blog.numino.net/ Example: BGr3NH http://blog.numino.net/ alert(external.m2_plugin_folder( %max_security_id , 'ViewSource!')); Qm8Zf3 http://blog.numino.net/ 6. m2_run_cmd( security_id , command_id ) - run the specified command ID 71Dxoe http://blog.numino.net/ Example: 4upgbA http://blog.numino.net/ external. m2_run_cmd( %max_security_id , 32772 )); Dheqad 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. 9z8FEc http://blog.numino.net/ 7. get_tab( security_id , tab_index ) - return the window object of the specifed tab i8YHBG http://blog.numino.net/ Example: JuW827 http://blog.numino.net/ var oWin=external.get_tab(%max_security_id, 0); Wxz0J6 http://blog.numino.net/ alert(oWin.document.URL); jE9b1v http://blog.numino.net/ 8. activate_tab( security_id , tab_index ) - activate the specified tab S2jbyt http://blog.numino.net/ Example: 3hzjbq http://blog.numino.net/ external.activate_tab(%max_security_id, 0); HbyOGM http://blog.numino.net/ 9. close_tab( security_id , tab_index ) - close the specified tab uxFUuK http://blog.numino.net/ Example: 9fPpaK http://blog.numino.net/ external.close_tab(%max_security_id, 0); tZMGYM http://blog.numino.net/ 10. readFile( security_id, plugin_name, file_name) - read the content of specified text file T5nitc http://blog.numino.net/ Example: 3FHMwJ http://blog.numino.net/ var sText=external.readFile(%max_security_id, 'ViewPage', 'readme.txt'); jKKHSq http://blog.numino.net/ alert(sText); WfzeOO http://blog.numino.net/ 11. writeFile( security_id, plugin_name, file_name, content ) - write content to the specific text file 72BUNo http://blog.numino.net/ Example: HtzJQt http://blog.numino.net/ external.writeFile(%max_security_id, 'ViewPage', 'test.txt', 'This is the file content'); Hy16y8 http://blog.numino.net/ 12. m2_readIni( security_id, plugin_name , file_name , section_name , key , default_value) - read data from specific INI file 8vDAGS http://blog.numino.net/ Example: j00K7R http://blog.numino.net/ var sDownloadTool=external.m2_readIni(%max_security_id, 'ViewPage', 'plugin.ini', 'Settings', 'Tool', ); vsWZaF http://blog.numino.net/ alert(sDownloadTool); 3tnr0F http://blog.numino.net/ 13. m2_writeIni( security_id , plugin_name , file_name , section_name , key , value ) - write data to specific INI file 04c2am http://blog.numino.net/ Example: I30V1k http://blog.numino.net/ external.m2_writeIni(%max_security_id, 'ViewPage', 'test.ini', 'Config', 'height', '100px'); rajuR0 http://blog.numino.net/ 14. max_modelessDialog( security_id , url , option , attr , window ) - returns a modeless web page dialog 3LY1qM http://blog.numino.net/ Example: AzFSO1 http://blog.numino.net/ var oDialog= external.max_modelessDialog( %max_security_id , 'blank.html', window , , window ); pMSKig http://blog.numino.net/ var oDoc=oDialog.document; 9h4F7w http://blog.numino.net/ oDoc.write('Testing'); 1W1104 http://blog.numino.net/ oDoc.close(); w425g8 http://blog.numino.net/ 15. max_activex(security_id ,program_id) - return specified ActiveX object bj72FT http://blog.numino.net/ Example: 9j8mEu http://blog.numino.net/ var oWSH=external.max_activex(%max_security_id, 'WScript.Shell'); qVkvpY http://blog.numino.net/ oWSH.run('notepad.exe'); IawLd8 http://blog.numino.net/ 16. m2_search_text(security_id) - return the text in search bar 5K7ZLW http://blog.numino.net/ Example: c1k3vK http://blog.numino.net/ alert(m2_search_text(%max_security_id)); 8z8v2W 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) Vb6j8h 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. xsZsS5 http://blog.numino.net/ Example: ouXgI8 http://blog.numino.net/ function max_callback(x){ jko82i http://blog.numino.net/ if(x=='tab_change') alert('Current tab is changed.'); XRZ6Ka http://blog.numino.net/ } zTM3G0 http://blog.numino.net/ By checking the parameter of the max_callback function, plugin can get the following browser events: HqHmBV http://blog.numino.net/ HTML button plugins PBPPt7 http://blog.numino.net/ tab_change – after the current tab is switched b60MlG http://blog.numino.net/ document_Complete - after the current tab is fully loaded jA4N32 http://blog.numino.net/ self_destroy - when the html is unloaded, usually when Maxthon exits e36n2F http://blog.numino.net/ Script sidebar plugins gOD6Ey http://blog.numino.net/ sidebar_tab_change - after the current tab is switched HPkgNS http://blog.numino.net/ sidebar_activate - when the sidebar plugin is activated WqOFh2 http://blog.numino.net/ sidebar_deactivate - when the sidebar plugin is deactivated O1OK1Z http://blog.numino.net/ sidebar_unload - when the sidebar plugin is unloaded (Maxthon is closed) Rn4des http://blog.numino.net/ 18. max_getObj (for Maxthon 2.0 only) - return various Maxthon objects, including: 07Gxr8 http://blog.numino.net/ Info - general information about Maxthon t7K1Bc http://blog.numino.net/ Adhunter – about Ad Hunter 0NTkv8 http://blog.numino.net/ FavManager – about Favorites d14y6c http://blog.numino.net/ RssManager – about RSS xxL7O2 http://blog.numino.net/ PluginManager - about Plugins, for Maxthon 2.0.5 or later R218n0 http://blog.numino.net/ Example: PYAH5A http://blog.numino.net/ var oInfo=external.max_getObj(%max_security_id, 'info'); HrZCy8 http://blog.numino.net/ Info Object supports the following property and method: WiWQvj http://blog.numino.net/ Property: Fpz24G http://blog.numino.net/ fileProxy - read-only, returns the path of the current user's proxy configuration document. jBV19k http://blog.numino.net/ Example: 2t8C05 http://blog.numino.net/ var oInfo=external.max_getObj(%max_security_id, 'info'); K40GVl http://blog.numino.net/ alert(oInfo.fileProxy); 29Ly0V http://blog.numino.net/ folderUser - read-only, returns the path of the profile folder of the current user J3ZZx1 http://blog.numino.net/ Example: icNJPu http://blog.numino.net/ var oInfo=external.max_getObj(%max_security_id, 'info'); 3qjEaB http://blog.numino.net/ alert(oInfo. folderUser); 3puS7Q http://blog.numino.net/ Method: BFQHlh http://blog.numino.net/ getFolderPluginData(plugin_name) - obtain the path of plugin data storage folder for the current user and the plugin 75c6Bi http://blog.numino.net/ Example: m1ggkR http://blog.numino.net/ var oInfo=external.max_getObj(%max_security_id, 'info'); nhRMpo http://blog.numino.net/ alert(oInfo.getFolderPluginData('ViewSource!')); LKh14l http://blog.numino.net/ AdHunter object support the following method: y5Pz6q http://blog.numino.net/ Method: iKVtXm http://blog.numino.net/ reloadFilter(filter_name) – reload the specified Maxthon filter (currently content filter only) after modifying the relevant filter 2d1Xv9 http://blog.numino.net/ Example: R407G3 http://blog.numino.net/ var oAdHunter=external.max_getObj(%max_security_id, 'AdHunter'); X6sWOK http://blog.numino.net/ oAdHunter.reloadFilter('content'); dt1xEb http://blog.numino.net/ enableFilter(filter_name, bEnable) – enable or disable Maxthon's 'content' or 'popup' filter A6IFaF http://blog.numino.net/ Example: 6eC5ak http://blog.numino.net/ var oAdHunter=external.max_getObj(%max_security_id, 'AdHunter'); EokuMf http://blog.numino.net/ oAdHunter.enableFilter ('content', false); zEJea8 http://blog.numino.net/ PluginManager object support the following method: 413sk6 http://blog.numino.net/ getPluginFolder - return Maxthon main plugin folder path l7hLbZ http://blog.numino.net/ Example: 96bIRO http://blog.numino.net/ var oPluginManager=external.max_getObj(%max_security_id, 'PluginManager'); HgS0Wi http://blog.numino.net/ alert(oPluginManager.getPluginFolder) uJrUUU http://blog.numino.net/ getCount - return the number of all installed plugins, both enabled and disabled 8dJJOo http://blog.numino.net/ Example: G2BqMx http://blog.numino.net/ var oPluginManager=external.max_getObj(%max_security_id, 'PluginManager'); Z3CbEv http://blog.numino.net/ alert(oPluginManager.getCount) A4lsyO http://blog.numino.net/ getList - return a list which contains information like name, author etc of all plugins kai0gk http://blog.numino.net/ Example: 7Asym6 http://blog.numino.net/ var oPluginManager=external.max_getObj(%max_security_id, 'PluginManager'); GeoDsk http://blog.numino.net/ alert(oPluginManager.getList) r59hv0 http://blog.numino.net/ getPlugin(Index) - Index is a number, return the corresponding plugin object 3c05dd http://blog.numino.net/ Example: mQ5O20 http://blog.numino.net/ var oPluginManager=external.max_getObj(%max_security_id, 'PluginManager'); 2iDLbX http://blog.numino.net/ var oPlugin=oPluginManager.getPlugin(0); BmiADR http://blog.numino.net/ The plugin object returned from getPlugin(Index) supports the following property and method: 44rgc0 http://blog.numino.net/ Property: s94y4N http://blog.numino.net/ title - read only, return plugin name o2stH8 http://blog.numino.net/ Example: N276MQ http://blog.numino.net/ alert(oPlugin.title); PXkQSH http://blog.numino.net/ folderName - read only, return plugin's folder name 0j2MDE http://blog.numino.net/ Example: iMywYW http://blog.numino.net/ alert(oPlugin.folderName); 0Gy4Bm http://blog.numino.net/ fullPath - read only, return plugin folder's full path 6XueXK http://blog.numino.net/ Example: HWeWSo http://blog.numino.net/ alert(oPlugin.fullPath); e9s5QJ http://blog.numino.net/ enable - read/write, return or set if the plugin is enabled jWrp7m http://blog.numino.net/ Example: 12F0Ai http://blog.numino.net/ oPlugin.enable=false; W4647N http://blog.numino.net/ alert(oPlugin.enable); P2L4pK http://blog.numino.net/ oPlugin.enable=true; 3xiGoC http://blog.numino.net/ alert(oPlugin.enable); 2LjK3t http://blog.numino.net/ startAfterPageDone - read/write, return or set if the plugin is auto started 1F6kJA http://blog.numino.net/ Example: SnLtWb http://blog.numino.net/ oPlugin.startAfterPageDone = true; 69cdWT http://blog.numino.net/ alert(oPlugin.startAfterPageDone); cP0pe7 http://blog.numino.net/ oPlugin.startAfterPageDone = false; 75s3QP http://blog.numino.net/ alert(oPlugin.startAfterPageDone); xbvbtC http://blog.numino.net/ startAfterPageDoneUrl - read/write, return or set the address where the plugin will be auto started smg6M1 http://blog.numino.net/ Example: gXMbMg http://blog.numino.net/ oPlugin.startAfterPageDoneUrl='*maxthon.com*|*maxthon.cn*'; Pu4rD8 http://blog.numino.net/ alert(oPlugin.startAfterPageDoneUrl); H7t54O http://blog.numino.net/ Methods: BF2QS6 http://blog.numino.net/ config() - open plugin configuration dialog (config.html) lWs2V3 http://blog.numino.net/ Example: r4911s http://blog.numino.net/ oPlugin.config(); MBCqaO http://blog.numino.net/ remove() - delete the plugin 9opeoC http://blog.numino.net/ Example: tLk314 http://blog.numino.net/ oPlugin.remove(); wQQOmr http://blog.numino.net/ [edit] Mscript sT9Pbh 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...> 0aClrn http://blog.numino.net/ Example - the following script button plugin can disable scripting in the current page by changing Maxthon's content control: bQAhNx http://blog.numino.net/ <script language="javascript"> TcdRJu http://blog.numino.net/ external.m2_run_cmd(%max_security_id, 33175); p3pzNx http://blog.numino.net/ </script> 16vONE 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. vj0UC5 http://blog.numino.net/ <mscript language="javascript"> UkWN6e http://blog.numino.net/ external.m2_run_cmd(0, 33175); E12nEq http://blog.numino.net/ </script> IJxOQi http://blog.numino.net/ Note an arbitrary number can be used as %max_security_id when mscript is used
|
|