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. jYV1RJ http://blog.numino.net/ How to obtain the Security ID 5Rm571 http://blog.numino.net/ 1. Script button plugins can use "%max_security_id" for the Security ID HKo2Sd 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。 3a670K http://blog.numino.net/ <script src=max.src></script> H61GFQ http://blog.numino.net/ Reference for Maxthon Plugin Commands CQBaFv http://blog.numino.net/ Unless specified otherwise, the following plugin commands are applicable for both Maxthon 2.0 and Maxthon 1.X。 ChJ51Y http://blog.numino.net/ 1. max_version - return Maxthon's version number 8kwDdN http://blog.numino.net/ Example: ogrP5v http://blog.numino.net/ alert(external.max_version); qcJgLw http://blog.numino.net/ 2. max_language_id - return Maxthon's language ID cbwkxW http://blog.numino.net/ Example: B2hF76 http://blog.numino.net/ alert(external.max_language_id); YgLt3q http://blog.numino.net/ Note: Maxthon 2.0 and Maxthon 1.X have different language ID format xphkoA http://blog.numino.net/ 3. tab_count - return the number of tabs opened by Maxthon kAnus4 http://blog.numino.net/ Example: H0xWR1 http://blog.numino.net/ alert(external.tab_count); 1X4xfT http://blog.numino.net/ 4. cur_sel - return the index of Maxthon's current tab juSx4b http://blog.numino.net/ Example: 7aj9kc http://blog.numino.net/ alert(external.cur_sel); mr13a6 http://blog.numino.net/ 5. m2_plugin_folder( security_id , plugin_name ) - return the folder path of the specified plugin SLxhJy http://blog.numino.net/ Example: cIsOE4 http://blog.numino.net/ alert(external.m2_plugin_folder( %max_security_id , 'ViewSource!')); FUrkro http://blog.numino.net/ 6. m2_run_cmd( security_id , command_id ) - run the specified command ID 0I1o4n http://blog.numino.net/ Example: WSbqpO http://blog.numino.net/ external. m2_run_cmd( %max_security_id , 32772 )); SnV8b1 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. 0i875r http://blog.numino.net/ 7. get_tab( security_id , tab_index ) - return the window object of the specifed tab hQ6iuN http://blog.numino.net/ Example: mOH3x9 http://blog.numino.net/ var oWin=external.get_tab(%max_security_id, 0); cRtCS6 http://blog.numino.net/ alert(oWin.document.URL); QIwguM http://blog.numino.net/ 8. activate_tab( security_id , tab_index ) - activate the specified tab 755RR1 http://blog.numino.net/ Example: T2PS4I http://blog.numino.net/ external.activate_tab(%max_security_id, 0); W0ermG http://blog.numino.net/ 9. close_tab( security_id , tab_index ) - close the specified tab 8og0y9 http://blog.numino.net/ Example: YA8J99 http://blog.numino.net/ external.close_tab(%max_security_id, 0); K4Xcj2 http://blog.numino.net/ 10. readFile( security_id, plugin_name, file_name) - read the content of specified text file uLu0x5 http://blog.numino.net/ Example: a7J2ME http://blog.numino.net/ var sText=external.readFile(%max_security_id, 'ViewPage', 'readme.txt'); gI1X8O http://blog.numino.net/ alert(sText); wDRdN2 http://blog.numino.net/ 11. writeFile( security_id, plugin_name, file_name, content ) - write content to the specific text file W1mc0q http://blog.numino.net/ Example: dz8T17 http://blog.numino.net/ external.writeFile(%max_security_id, 'ViewPage', 'test.txt', 'This is the file content'); IPQy06 http://blog.numino.net/ 12. m2_readIni( security_id, plugin_name , file_name , section_name , key , default_value) - read data from specific INI file 4Bz9xs http://blog.numino.net/ Example: r57NIU http://blog.numino.net/ var sDownloadTool=external.m2_readIni(%max_security_id, 'ViewPage', 'plugin.ini', 'Settings', 'Tool', ); 0CkN7y http://blog.numino.net/ alert(sDownloadTool); tejE9x http://blog.numino.net/ 13. m2_writeIni( security_id , plugin_name , file_name , section_name , key , value ) - write data to specific INI file y17sp7 http://blog.numino.net/ Example: leO1wK http://blog.numino.net/ external.m2_writeIni(%max_security_id, 'ViewPage', 'test.ini', 'Config', 'height', '100px'); 6kr4E5 http://blog.numino.net/ 14. max_modelessDialog( security_id , url , option , attr , window ) - returns a modeless web page dialog b4998w http://blog.numino.net/ Example: 5P3c2B http://blog.numino.net/ var oDialog= external.max_modelessDialog( %max_security_id , 'blank.html', window , , window ); aGTn03 http://blog.numino.net/ var oDoc=oDialog.document; 0LEKiB http://blog.numino.net/ oDoc.write('Testing'); S6Sj34 http://blog.numino.net/ oDoc.close(); CzCd03 http://blog.numino.net/ 15. max_activex(security_id ,program_id) - return specified ActiveX object etmcnU http://blog.numino.net/ Example: nqZ6CV http://blog.numino.net/ var oWSH=external.max_activex(%max_security_id, 'WScript.Shell'); 07WkOO http://blog.numino.net/ oWSH.run('notepad.exe'); 9s5L0V http://blog.numino.net/ 16. m2_search_text(security_id) - return the text in search bar 0bCe7L http://blog.numino.net/ Example: IJjQOW http://blog.numino.net/ alert(m2_search_text(%max_security_id)); zD8Sct 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) hWFnJx 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. AC2c85 http://blog.numino.net/ Example: DPOE3a http://blog.numino.net/ function max_callback(x){ 5oYkDr http://blog.numino.net/ if(x=='tab_change') alert('Current tab is changed.'); mIz03H http://blog.numino.net/ } 3T59pT http://blog.numino.net/ By checking the parameter of the max_callback function, plugin can get the following browser events: p7XI1V http://blog.numino.net/ HTML button plugins rDumtA http://blog.numino.net/ tab_change – after the current tab is switched m6EHUa http://blog.numino.net/ document_Complete - after the current tab is fully loaded Sw48Pt http://blog.numino.net/ self_destroy - when the html is unloaded, usually when Maxthon exits qZHqU4 http://blog.numino.net/ Script sidebar plugins 7mqHu9 http://blog.numino.net/ sidebar_tab_change - after the current tab is switched HLD45V http://blog.numino.net/ sidebar_activate - when the sidebar plugin is activated Z5VYlr http://blog.numino.net/ sidebar_deactivate - when the sidebar plugin is deactivated wEZ96M http://blog.numino.net/ sidebar_unload - when the sidebar plugin is unloaded (Maxthon is closed) 8nRDBo http://blog.numino.net/ 18. max_getObj (for Maxthon 2.0 only) - return various Maxthon objects, including: lAMUz6 http://blog.numino.net/ Info - general information about Maxthon 0APMI4 http://blog.numino.net/ Adhunter – about Ad Hunter FQl18H http://blog.numino.net/ FavManager – about Favorites oT5xSk http://blog.numino.net/ RssManager – about RSS 3vNrPJ http://blog.numino.net/ PluginManager - about Plugins, for Maxthon 2.0.5 or later 3b2648 http://blog.numino.net/ Example: nL3Nv6 http://blog.numino.net/ var oInfo=external.max_getObj(%max_security_id, 'info'); M35Oc1 http://blog.numino.net/ Info Object supports the following property and method: vUVAw8 http://blog.numino.net/ Property: HUwgfM http://blog.numino.net/ fileProxy - read-only, returns the path of the current user's proxy configuration document. R42Pyh http://blog.numino.net/ Example: R11PhC http://blog.numino.net/ var oInfo=external.max_getObj(%max_security_id, 'info'); fF7g9H http://blog.numino.net/ alert(oInfo.fileProxy); 4BXPey http://blog.numino.net/ folderUser - read-only, returns the path of the profile folder of the current user BvOkp8 http://blog.numino.net/ Example: kF5I7W http://blog.numino.net/ var oInfo=external.max_getObj(%max_security_id, 'info'); 5Jzd00 http://blog.numino.net/ alert(oInfo. folderUser); x3lMfl http://blog.numino.net/ Method: zaLs20 http://blog.numino.net/ getFolderPluginData(plugin_name) - obtain the path of plugin data storage folder for the current user and the plugin qx16VA http://blog.numino.net/ Example: sdEV1l http://blog.numino.net/ var oInfo=external.max_getObj(%max_security_id, 'info'); HMOwCw http://blog.numino.net/ alert(oInfo.getFolderPluginData('ViewSource!')); 9ym98E http://blog.numino.net/ AdHunter object support the following method: dHLxjP http://blog.numino.net/ Method: c8CDM4 http://blog.numino.net/ reloadFilter(filter_name) – reload the specified Maxthon filter (currently content filter only) after modifying the relevant filter 1Z9xMc http://blog.numino.net/ Example: GZrd70 http://blog.numino.net/ var oAdHunter=external.max_getObj(%max_security_id, 'AdHunter'); Gmy8dw http://blog.numino.net/ oAdHunter.reloadFilter('content'); ZOJz1O http://blog.numino.net/ enableFilter(filter_name, bEnable) – enable or disable Maxthon's 'content' or 'popup' filter 7i2eOI http://blog.numino.net/ Example: pZQhIT http://blog.numino.net/ var oAdHunter=external.max_getObj(%max_security_id, 'AdHunter'); T7x8yv http://blog.numino.net/ oAdHunter.enableFilter ('content', false); 8P5Flx http://blog.numino.net/ PluginManager object support the following method: gYRWIk http://blog.numino.net/ getPluginFolder - return Maxthon main plugin folder path 18B199 http://blog.numino.net/ Example: iyu4t6 http://blog.numino.net/ var oPluginManager=external.max_getObj(%max_security_id, 'PluginManager'); c3OJYA http://blog.numino.net/ alert(oPluginManager.getPluginFolder) by3MAA http://blog.numino.net/ getCount - return the number of all installed plugins, both enabled and disabled Ohahs4 http://blog.numino.net/ Example: 9DZ21w http://blog.numino.net/ var oPluginManager=external.max_getObj(%max_security_id, 'PluginManager'); ukGVF1 http://blog.numino.net/ alert(oPluginManager.getCount) 7f5P71 http://blog.numino.net/ getList - return a list which contains information like name, author etc of all plugins ktxwcf http://blog.numino.net/ Example: KRrh3d http://blog.numino.net/ var oPluginManager=external.max_getObj(%max_security_id, 'PluginManager'); t6nnHN http://blog.numino.net/ alert(oPluginManager.getList) VP96dD http://blog.numino.net/ getPlugin(Index) - Index is a number, return the corresponding plugin object xiOEOG http://blog.numino.net/ Example: 1UPzVf http://blog.numino.net/ var oPluginManager=external.max_getObj(%max_security_id, 'PluginManager'); 28Ej9q http://blog.numino.net/ var oPlugin=oPluginManager.getPlugin(0); Wg13xR http://blog.numino.net/ The plugin object returned from getPlugin(Index) supports the following property and method: b8mQzu http://blog.numino.net/ Property: GuUm3S http://blog.numino.net/ title - read only, return plugin name uu8VoA http://blog.numino.net/ Example: 67U5aY http://blog.numino.net/ alert(oPlugin.title); vslaMK http://blog.numino.net/ folderName - read only, return plugin's folder name zdW3E7 http://blog.numino.net/ Example: f7nx92 http://blog.numino.net/ alert(oPlugin.folderName); XqJ9VL http://blog.numino.net/ fullPath - read only, return plugin folder's full path o8slod http://blog.numino.net/ Example: Y1lKSO http://blog.numino.net/ alert(oPlugin.fullPath); nYPm1U http://blog.numino.net/ enable - read/write, return or set if the plugin is enabled x9y04s http://blog.numino.net/ Example: clOpgX http://blog.numino.net/ oPlugin.enable=false; GK7v8W http://blog.numino.net/ alert(oPlugin.enable); 1tzO35 http://blog.numino.net/ oPlugin.enable=true; 9qYd0j http://blog.numino.net/ alert(oPlugin.enable); znNeEz http://blog.numino.net/ startAfterPageDone - read/write, return or set if the plugin is auto started Qn4JCI http://blog.numino.net/ Example: rtpyzF http://blog.numino.net/ oPlugin.startAfterPageDone = true; TnkSN8 http://blog.numino.net/ alert(oPlugin.startAfterPageDone); iMdu0g http://blog.numino.net/ oPlugin.startAfterPageDone = false; ZROqTq http://blog.numino.net/ alert(oPlugin.startAfterPageDone); ka2bYG http://blog.numino.net/ startAfterPageDoneUrl - read/write, return or set the address where the plugin will be auto started 71lzeq http://blog.numino.net/ Example: sBLHaT http://blog.numino.net/ oPlugin.startAfterPageDoneUrl='*maxthon.com*|*maxthon.cn*'; LLHtlX http://blog.numino.net/ alert(oPlugin.startAfterPageDoneUrl); nbDbK9 http://blog.numino.net/ Methods: G4h5AC http://blog.numino.net/ config() - open plugin configuration dialog (config.html) p7So5I http://blog.numino.net/ Example: 9G9mg2 http://blog.numino.net/ oPlugin.config(); 7vFb4n http://blog.numino.net/ remove() - delete the plugin ggd8KH http://blog.numino.net/ Example: HLtqn1 http://blog.numino.net/ oPlugin.remove(); 3XD2Sl http://blog.numino.net/ [edit] Mscript Vu6mjF 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...> mRg319 http://blog.numino.net/ Example - the following script button plugin can disable scripting in the current page by changing Maxthon's content control: PyQg11 http://blog.numino.net/ <script language="javascript"> Cg20Wi http://blog.numino.net/ external.m2_run_cmd(%max_security_id, 33175); dKK9Pp http://blog.numino.net/ </script> mfjJI3 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. 9awXai http://blog.numino.net/ <mscript language="javascript"> rTp085 http://blog.numino.net/ external.m2_run_cmd(0, 33175); eH9I4v http://blog.numino.net/ </script> 3Eij7a http://blog.numino.net/ Note an arbitrary number can be used as %max_security_id when mscript is used
|
|