| 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. 8k6Ymw http://blog.numino.net/ How to obtain the Security ID Kt4dE1 http://blog.numino.net/ 1. Script button plugins can use "%max_security_id" for the Security ID Y23yy9 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。 E7Jna2 http://blog.numino.net/ <script src=max.src></script> b2Bhb3 http://blog.numino.net/ Reference for Maxthon Plugin Commands uOFlfq http://blog.numino.net/ Unless specified otherwise, the following plugin commands are applicable for both Maxthon 2.0 and Maxthon 1.X。 4XsLe5 http://blog.numino.net/ 1. max_version - return Maxthon's version number 79cnFy http://blog.numino.net/ Example: 3GJAS6 http://blog.numino.net/ alert(external.max_version); miI34M http://blog.numino.net/ 2. max_language_id - return Maxthon's language ID aLy7rz http://blog.numino.net/ Example: ekc95F http://blog.numino.net/ alert(external.max_language_id); 17oXOk http://blog.numino.net/ Note: Maxthon 2.0 and Maxthon 1.X have different language ID format pX3GWK http://blog.numino.net/ 3. tab_count - return the number of tabs opened by Maxthon uPr66i http://blog.numino.net/ Example: O25S8D http://blog.numino.net/ alert(external.tab_count); 1tLbN0 http://blog.numino.net/ 4. cur_sel - return the index of Maxthon's current tab Wpx3v1 http://blog.numino.net/ Example: 7MG6yl http://blog.numino.net/ alert(external.cur_sel); xW8Vs9 http://blog.numino.net/ 5. m2_plugin_folder( security_id , plugin_name ) - return the folder path of the specified plugin 0A7eko http://blog.numino.net/ Example: f7MDo6 http://blog.numino.net/ alert(external.m2_plugin_folder( %max_security_id , 'ViewSource!')); oS4zBF http://blog.numino.net/ 6. m2_run_cmd( security_id , command_id ) - run the specified command ID JcNgdB http://blog.numino.net/ Example: e39fOG http://blog.numino.net/ external. m2_run_cmd( %max_security_id , 32772 )); 1Q3G50 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. 0KeiG0 http://blog.numino.net/ 7. get_tab( security_id , tab_index ) - return the window object of the specifed tab A1Ebvv http://blog.numino.net/ Example: 1MfU1q http://blog.numino.net/ var oWin=external.get_tab(%max_security_id, 0); C2kK7P http://blog.numino.net/ alert(oWin.document.URL); WI7y3v http://blog.numino.net/ 8. activate_tab( security_id , tab_index ) - activate the specified tab 2sa9hL http://blog.numino.net/ Example: iews8Z http://blog.numino.net/ external.activate_tab(%max_security_id, 0); eo4t1m http://blog.numino.net/ 9. close_tab( security_id , tab_index ) - close the specified tab 6j9TeA http://blog.numino.net/ Example: j9hb6m http://blog.numino.net/ external.close_tab(%max_security_id, 0); 4yt2C1 http://blog.numino.net/ 10. readFile( security_id, plugin_name, file_name) - read the content of specified text file mf77jm http://blog.numino.net/ Example: 3i287X http://blog.numino.net/ var sText=external.readFile(%max_security_id, 'ViewPage', 'readme.txt'); TY32mH http://blog.numino.net/ alert(sText); OMKymm http://blog.numino.net/ 11. writeFile( security_id, plugin_name, file_name, content ) - write content to the specific text file 3HdrJX http://blog.numino.net/ Example: ej5Oto http://blog.numino.net/ external.writeFile(%max_security_id, 'ViewPage', 'test.txt', 'This is the file content'); Ot3wH2 http://blog.numino.net/ 12. m2_readIni( security_id, plugin_name , file_name , section_name , key , default_value) - read data from specific INI file nuAC60 http://blog.numino.net/ Example: 8NZ1Yo http://blog.numino.net/ var sDownloadTool=external.m2_readIni(%max_security_id, 'ViewPage', 'plugin.ini', 'Settings', 'Tool', ); b5R164 http://blog.numino.net/ alert(sDownloadTool); 675w8l http://blog.numino.net/ 13. m2_writeIni( security_id , plugin_name , file_name , section_name , key , value ) - write data to specific INI file 4QT5ot http://blog.numino.net/ Example: 2fuT2Q http://blog.numino.net/ external.m2_writeIni(%max_security_id, 'ViewPage', 'test.ini', 'Config', 'height', '100px'); 6wzwSo http://blog.numino.net/ 14. max_modelessDialog( security_id , url , option , attr , window ) - returns a modeless web page dialog 74lFSr http://blog.numino.net/ Example: 7jlDSL http://blog.numino.net/ var oDialog= external.max_modelessDialog( %max_security_id , 'blank.html', window , , window ); Evn472 http://blog.numino.net/ var oDoc=oDialog.document; EiL1Dc http://blog.numino.net/ oDoc.write('Testing'); IsLS4z http://blog.numino.net/ oDoc.close(); X61VT2 http://blog.numino.net/ 15. max_activex(security_id ,program_id) - return specified ActiveX object 0iHjV7 http://blog.numino.net/ Example: 84KT57 http://blog.numino.net/ var oWSH=external.max_activex(%max_security_id, 'WScript.Shell'); rOcL7n http://blog.numino.net/ oWSH.run('notepad.exe'); U21tka http://blog.numino.net/ 16. m2_search_text(security_id) - return the text in search bar VxP85S http://blog.numino.net/ Example: Y1k2I7 http://blog.numino.net/ alert(m2_search_text(%max_security_id)); 6zNqwn 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) KjzuUX 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. lKXQ97 http://blog.numino.net/ Example: deoFgK http://blog.numino.net/ function max_callback(x){ U2h0AH http://blog.numino.net/ if(x=='tab_change') alert('Current tab is changed.'); 4b13mE http://blog.numino.net/ } oV7gg2 http://blog.numino.net/ By checking the parameter of the max_callback function, plugin can get the following browser events: y5v6hs http://blog.numino.net/ HTML button plugins 31TRFQ http://blog.numino.net/ tab_change – after the current tab is switched lKqY0u http://blog.numino.net/ document_Complete - after the current tab is fully loaded 0YoS9l http://blog.numino.net/ self_destroy - when the html is unloaded, usually when Maxthon exits EalKax http://blog.numino.net/ Script sidebar plugins pYFiI3 http://blog.numino.net/ sidebar_tab_change - after the current tab is switched Th4jv5 http://blog.numino.net/ sidebar_activate - when the sidebar plugin is activated f7TAX5 http://blog.numino.net/ sidebar_deactivate - when the sidebar plugin is deactivated zeuZWp http://blog.numino.net/ sidebar_unload - when the sidebar plugin is unloaded (Maxthon is closed) W0VQl0 http://blog.numino.net/ 18. max_getObj (for Maxthon 2.0 only) - return various Maxthon objects, including: 50l5no http://blog.numino.net/ Info - general information about Maxthon 4u3cfK http://blog.numino.net/ Adhunter – about Ad Hunter gzpx15 http://blog.numino.net/ FavManager – about Favorites fbfD9u http://blog.numino.net/ RssManager – about RSS 6y89OY http://blog.numino.net/ PluginManager - about Plugins, for Maxthon 2.0.5 or later 5VDSNQ http://blog.numino.net/ Example: 81o07N http://blog.numino.net/ var oInfo=external.max_getObj(%max_security_id, 'info'); k1du5X http://blog.numino.net/ Info Object supports the following property and method: JxqXXx http://blog.numino.net/ Property: jB64Ze http://blog.numino.net/ fileProxy - read-only, returns the path of the current user's proxy configuration document. BsnE2w http://blog.numino.net/ Example: 6Mm29s http://blog.numino.net/ var oInfo=external.max_getObj(%max_security_id, 'info'); 3PpHLz http://blog.numino.net/ alert(oInfo.fileProxy); t3RPxm http://blog.numino.net/ folderUser - read-only, returns the path of the profile folder of the current user NGFdFd http://blog.numino.net/ Example: WlOWo9 http://blog.numino.net/ var oInfo=external.max_getObj(%max_security_id, 'info'); 6d3tT0 http://blog.numino.net/ alert(oInfo. folderUser); MoBmM8 http://blog.numino.net/ Method: s08k0M http://blog.numino.net/ getFolderPluginData(plugin_name) - obtain the path of plugin data storage folder for the current user and the plugin F5djpW http://blog.numino.net/ Example: xt5Tzj http://blog.numino.net/ var oInfo=external.max_getObj(%max_security_id, 'info'); hjH1jb http://blog.numino.net/ alert(oInfo.getFolderPluginData('ViewSource!')); 76o91W http://blog.numino.net/ AdHunter object support the following method: 5k7Xg2 http://blog.numino.net/ Method: 2n8kO0 http://blog.numino.net/ reloadFilter(filter_name) – reload the specified Maxthon filter (currently content filter only) after modifying the relevant filter HNV8mQ http://blog.numino.net/ Example: CsotYc http://blog.numino.net/ var oAdHunter=external.max_getObj(%max_security_id, 'AdHunter'); J15i27 http://blog.numino.net/ oAdHunter.reloadFilter('content'); 1R7fm0 http://blog.numino.net/ enableFilter(filter_name, bEnable) – enable or disable Maxthon's 'content' or 'popup' filter 9Jb9lZ http://blog.numino.net/ Example: 7R91Gu http://blog.numino.net/ var oAdHunter=external.max_getObj(%max_security_id, 'AdHunter'); Vf4uEH http://blog.numino.net/ oAdHunter.enableFilter ('content', false); 7PWa61 http://blog.numino.net/ PluginManager object support the following method: 2g5rtP http://blog.numino.net/ getPluginFolder - return Maxthon main plugin folder path 9HPcZB http://blog.numino.net/ Example: hW6w80 http://blog.numino.net/ var oPluginManager=external.max_getObj(%max_security_id, 'PluginManager'); q9NlJB http://blog.numino.net/ alert(oPluginManager.getPluginFolder) 3Jf5X4 http://blog.numino.net/ getCount - return the number of all installed plugins, both enabled and disabled XE4Fr4 http://blog.numino.net/ Example: 4WvlIw http://blog.numino.net/ var oPluginManager=external.max_getObj(%max_security_id, 'PluginManager'); 1W3WX5 http://blog.numino.net/ alert(oPluginManager.getCount) JeX4V3 http://blog.numino.net/ getList - return a list which contains information like name, author etc of all plugins 8hG70C http://blog.numino.net/ Example: j07fKP http://blog.numino.net/ var oPluginManager=external.max_getObj(%max_security_id, 'PluginManager'); RBzP7S http://blog.numino.net/ alert(oPluginManager.getList) 0H4Q9K http://blog.numino.net/ getPlugin(Index) - Index is a number, return the corresponding plugin object NMa2I1 http://blog.numino.net/ Example: i9LUMO http://blog.numino.net/ var oPluginManager=external.max_getObj(%max_security_id, 'PluginManager'); 6T7Ukj http://blog.numino.net/ var oPlugin=oPluginManager.getPlugin(0); Lx0LU4 http://blog.numino.net/ The plugin object returned from getPlugin(Index) supports the following property and method: h5VjP5 http://blog.numino.net/ Property: FpIwWN http://blog.numino.net/ title - read only, return plugin name nz78lQ http://blog.numino.net/ Example: ocw5OY http://blog.numino.net/ alert(oPlugin.title); 8VRP5q http://blog.numino.net/ folderName - read only, return plugin's folder name WkKtoR http://blog.numino.net/ Example: oOe2fN http://blog.numino.net/ alert(oPlugin.folderName); op5wqe http://blog.numino.net/ fullPath - read only, return plugin folder's full path P7N36q http://blog.numino.net/ Example: Tg1g29 http://blog.numino.net/ alert(oPlugin.fullPath); nI0AYV http://blog.numino.net/ enable - read/write, return or set if the plugin is enabled QQMVAL http://blog.numino.net/ Example: 9LeCS4 http://blog.numino.net/ oPlugin.enable=false; cfYpyT http://blog.numino.net/ alert(oPlugin.enable); XCbYw9 http://blog.numino.net/ oPlugin.enable=true; vkxDih http://blog.numino.net/ alert(oPlugin.enable); e9Na24 http://blog.numino.net/ startAfterPageDone - read/write, return or set if the plugin is auto started 0hyjHX http://blog.numino.net/ Example: 44lv6x http://blog.numino.net/ oPlugin.startAfterPageDone = true; wD5hR3 http://blog.numino.net/ alert(oPlugin.startAfterPageDone); 8YvYx1 http://blog.numino.net/ oPlugin.startAfterPageDone = false; 10teCn http://blog.numino.net/ alert(oPlugin.startAfterPageDone); Ccp8WM http://blog.numino.net/ startAfterPageDoneUrl - read/write, return or set the address where the plugin will be auto started 1cIwkX http://blog.numino.net/ Example: 3q8gHK http://blog.numino.net/ oPlugin.startAfterPageDoneUrl='*maxthon.com*|*maxthon.cn*'; xULn9G http://blog.numino.net/ alert(oPlugin.startAfterPageDoneUrl); QooP3G http://blog.numino.net/ Methods: Bnj7ei http://blog.numino.net/ config() - open plugin configuration dialog (config.html) Qea50M http://blog.numino.net/ Example: R00e5z http://blog.numino.net/ oPlugin.config(); Xwx4G8 http://blog.numino.net/ remove() - delete the plugin 3GV2oH http://blog.numino.net/ Example: UFKGcr http://blog.numino.net/ oPlugin.remove(); gAd671 http://blog.numino.net/ [edit] Mscript IR24cE 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...> VlwRU6 http://blog.numino.net/ Example - the following script button plugin can disable scripting in the current page by changing Maxthon's content control: rr1uJX http://blog.numino.net/ <script language="javascript"> WAP8tp http://blog.numino.net/ external.m2_run_cmd(%max_security_id, 33175); 13xbT6 http://blog.numino.net/ </script> 8hdug5 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. 0W03y3 http://blog.numino.net/ <mscript language="javascript"> f27Fny http://blog.numino.net/ external.m2_run_cmd(0, 33175); JhgFf8 http://blog.numino.net/ </script> T2W6H3 http://blog.numino.net/ Note an arbitrary number can be used as %max_security_id when mscript is used
|
|