| 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. D6W6Tg http://blog.numino.net/ How to obtain the Security ID 1pKucT http://blog.numino.net/ 1. Script button plugins can use "%max_security_id" for the Security ID HnlDHw 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。 5gwp2N http://blog.numino.net/ <script src=max.src></script> SByESS http://blog.numino.net/ Reference for Maxthon Plugin Commands FGb5LH http://blog.numino.net/ Unless specified otherwise, the following plugin commands are applicable for both Maxthon 2.0 and Maxthon 1.X。 2B5Hlk http://blog.numino.net/ 1. max_version - return Maxthon's version number MY45uw http://blog.numino.net/ Example: 4Vbx3X http://blog.numino.net/ alert(external.max_version); h64LN9 http://blog.numino.net/ 2. max_language_id - return Maxthon's language ID s5usWH http://blog.numino.net/ Example: qF0PrY http://blog.numino.net/ alert(external.max_language_id); aYWUku http://blog.numino.net/ Note: Maxthon 2.0 and Maxthon 1.X have different language ID format 41yu1L http://blog.numino.net/ 3. tab_count - return the number of tabs opened by Maxthon 3k6jtS http://blog.numino.net/ Example: g5FPl6 http://blog.numino.net/ alert(external.tab_count); YT24qq http://blog.numino.net/ 4. cur_sel - return the index of Maxthon's current tab zKN0t3 http://blog.numino.net/ Example: j31VF3 http://blog.numino.net/ alert(external.cur_sel); Z7XYYW http://blog.numino.net/ 5. m2_plugin_folder( security_id , plugin_name ) - return the folder path of the specified plugin xP5Iq0 http://blog.numino.net/ Example: 87u4xj http://blog.numino.net/ alert(external.m2_plugin_folder( %max_security_id , 'ViewSource!')); 47KmBC http://blog.numino.net/ 6. m2_run_cmd( security_id , command_id ) - run the specified command ID 23Nc8D http://blog.numino.net/ Example: e3SW80 http://blog.numino.net/ external. m2_run_cmd( %max_security_id , 32772 )); 3jE4C8 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. w22UAY http://blog.numino.net/ 7. get_tab( security_id , tab_index ) - return the window object of the specifed tab 8BtVVn http://blog.numino.net/ Example: A3qbcF http://blog.numino.net/ var oWin=external.get_tab(%max_security_id, 0); sKKoRF http://blog.numino.net/ alert(oWin.document.URL); V2hmH0 http://blog.numino.net/ 8. activate_tab( security_id , tab_index ) - activate the specified tab N6ULHj http://blog.numino.net/ Example: 5JcCF7 http://blog.numino.net/ external.activate_tab(%max_security_id, 0); s83sAg http://blog.numino.net/ 9. close_tab( security_id , tab_index ) - close the specified tab 5ylsBT http://blog.numino.net/ Example: 3hBKzs http://blog.numino.net/ external.close_tab(%max_security_id, 0); N5tRo2 http://blog.numino.net/ 10. readFile( security_id, plugin_name, file_name) - read the content of specified text file 6arkyH http://blog.numino.net/ Example: kckBtN http://blog.numino.net/ var sText=external.readFile(%max_security_id, 'ViewPage', 'readme.txt'); vjr53I http://blog.numino.net/ alert(sText); 2U21XH http://blog.numino.net/ 11. writeFile( security_id, plugin_name, file_name, content ) - write content to the specific text file yYCKHb http://blog.numino.net/ Example: Qi2WV5 http://blog.numino.net/ external.writeFile(%max_security_id, 'ViewPage', 'test.txt', 'This is the file content'); 2j1oqX http://blog.numino.net/ 12. m2_readIni( security_id, plugin_name , file_name , section_name , key , default_value) - read data from specific INI file wOqFsp http://blog.numino.net/ Example: 4H1KlQ http://blog.numino.net/ var sDownloadTool=external.m2_readIni(%max_security_id, 'ViewPage', 'plugin.ini', 'Settings', 'Tool', ); sex0LM http://blog.numino.net/ alert(sDownloadTool); haLP8g http://blog.numino.net/ 13. m2_writeIni( security_id , plugin_name , file_name , section_name , key , value ) - write data to specific INI file QT5rR0 http://blog.numino.net/ Example: iW991p http://blog.numino.net/ external.m2_writeIni(%max_security_id, 'ViewPage', 'test.ini', 'Config', 'height', '100px'); JJ1VNP http://blog.numino.net/ 14. max_modelessDialog( security_id , url , option , attr , window ) - returns a modeless web page dialog bbPJZV http://blog.numino.net/ Example: zfI2xN http://blog.numino.net/ var oDialog= external.max_modelessDialog( %max_security_id , 'blank.html', window , , window ); IU1cda http://blog.numino.net/ var oDoc=oDialog.document; bTS33o http://blog.numino.net/ oDoc.write('Testing'); chdusQ http://blog.numino.net/ oDoc.close(); s1e34b http://blog.numino.net/ 15. max_activex(security_id ,program_id) - return specified ActiveX object um0n9N http://blog.numino.net/ Example: y737mB http://blog.numino.net/ var oWSH=external.max_activex(%max_security_id, 'WScript.Shell'); 1Qxn5e http://blog.numino.net/ oWSH.run('notepad.exe'); vEgbdF http://blog.numino.net/ 16. m2_search_text(security_id) - return the text in search bar 5HbEXV http://blog.numino.net/ Example: gV7AkG http://blog.numino.net/ alert(m2_search_text(%max_security_id)); Dec4JG 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) sTG0Wc 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. F3uh1I http://blog.numino.net/ Example: 1iVIsn http://blog.numino.net/ function max_callback(x){ sP831k http://blog.numino.net/ if(x=='tab_change') alert('Current tab is changed.'); dAnIvf http://blog.numino.net/ } r6SLmq http://blog.numino.net/ By checking the parameter of the max_callback function, plugin can get the following browser events: xg7S33 http://blog.numino.net/ HTML button plugins nkM4fT http://blog.numino.net/ tab_change – after the current tab is switched xPxec1 http://blog.numino.net/ document_Complete - after the current tab is fully loaded gftwzf http://blog.numino.net/ self_destroy - when the html is unloaded, usually when Maxthon exits 26AI45 http://blog.numino.net/ Script sidebar plugins gwb9Ok http://blog.numino.net/ sidebar_tab_change - after the current tab is switched k1HtwY http://blog.numino.net/ sidebar_activate - when the sidebar plugin is activated T2s9FS http://blog.numino.net/ sidebar_deactivate - when the sidebar plugin is deactivated Lw980f http://blog.numino.net/ sidebar_unload - when the sidebar plugin is unloaded (Maxthon is closed) H2gr77 http://blog.numino.net/ 18. max_getObj (for Maxthon 2.0 only) - return various Maxthon objects, including: 6Tvm7f http://blog.numino.net/ Info - general information about Maxthon o2A9Iz http://blog.numino.net/ Adhunter – about Ad Hunter M480wB http://blog.numino.net/ FavManager – about Favorites iagyeX http://blog.numino.net/ RssManager – about RSS rOqxnh http://blog.numino.net/ PluginManager - about Plugins, for Maxthon 2.0.5 or later kn10N5 http://blog.numino.net/ Example: z422H2 http://blog.numino.net/ var oInfo=external.max_getObj(%max_security_id, 'info'); 5kx87M http://blog.numino.net/ Info Object supports the following property and method: bC9cos http://blog.numino.net/ Property: g89DVg http://blog.numino.net/ fileProxy - read-only, returns the path of the current user's proxy configuration document. 5klcnb http://blog.numino.net/ Example: 8d14U6 http://blog.numino.net/ var oInfo=external.max_getObj(%max_security_id, 'info'); b864Ro http://blog.numino.net/ alert(oInfo.fileProxy); RTsYQK http://blog.numino.net/ folderUser - read-only, returns the path of the profile folder of the current user MQNH4B http://blog.numino.net/ Example: VKIDe4 http://blog.numino.net/ var oInfo=external.max_getObj(%max_security_id, 'info'); 7Xp4BZ http://blog.numino.net/ alert(oInfo. folderUser); D6e9U1 http://blog.numino.net/ Method: Xl8xiP http://blog.numino.net/ getFolderPluginData(plugin_name) - obtain the path of plugin data storage folder for the current user and the plugin aolhkg http://blog.numino.net/ Example: Tr8hRc http://blog.numino.net/ var oInfo=external.max_getObj(%max_security_id, 'info'); 3bAv6a http://blog.numino.net/ alert(oInfo.getFolderPluginData('ViewSource!')); EltbDs http://blog.numino.net/ AdHunter object support the following method: b37kZ3 http://blog.numino.net/ Method: fAE9id http://blog.numino.net/ reloadFilter(filter_name) – reload the specified Maxthon filter (currently content filter only) after modifying the relevant filter zyLOnI http://blog.numino.net/ Example: hv26ho http://blog.numino.net/ var oAdHunter=external.max_getObj(%max_security_id, 'AdHunter'); v4BC8e http://blog.numino.net/ oAdHunter.reloadFilter('content'); kFyJNI http://blog.numino.net/ enableFilter(filter_name, bEnable) – enable or disable Maxthon's 'content' or 'popup' filter oL9ope http://blog.numino.net/ Example: zxzQfo http://blog.numino.net/ var oAdHunter=external.max_getObj(%max_security_id, 'AdHunter'); LVZMaN http://blog.numino.net/ oAdHunter.enableFilter ('content', false); 1HCtz5 http://blog.numino.net/ PluginManager object support the following method: gsb313 http://blog.numino.net/ getPluginFolder - return Maxthon main plugin folder path j9L3I1 http://blog.numino.net/ Example: UEa6ze http://blog.numino.net/ var oPluginManager=external.max_getObj(%max_security_id, 'PluginManager'); WWO39H http://blog.numino.net/ alert(oPluginManager.getPluginFolder) yz6swZ http://blog.numino.net/ getCount - return the number of all installed plugins, both enabled and disabled Ui5QbS http://blog.numino.net/ Example: 6F0k6b http://blog.numino.net/ var oPluginManager=external.max_getObj(%max_security_id, 'PluginManager'); NqcR22 http://blog.numino.net/ alert(oPluginManager.getCount) m6iI6r http://blog.numino.net/ getList - return a list which contains information like name, author etc of all plugins pV008a http://blog.numino.net/ Example: 2nHZ74 http://blog.numino.net/ var oPluginManager=external.max_getObj(%max_security_id, 'PluginManager'); 0R5A1D http://blog.numino.net/ alert(oPluginManager.getList) 6Zq9J1 http://blog.numino.net/ getPlugin(Index) - Index is a number, return the corresponding plugin object m7Jddn http://blog.numino.net/ Example: Kscyva http://blog.numino.net/ var oPluginManager=external.max_getObj(%max_security_id, 'PluginManager'); rDBANn http://blog.numino.net/ var oPlugin=oPluginManager.getPlugin(0); xhl44L http://blog.numino.net/ The plugin object returned from getPlugin(Index) supports the following property and method: 43A8XO http://blog.numino.net/ Property: U2Qwwj http://blog.numino.net/ title - read only, return plugin name wyHKAF http://blog.numino.net/ Example: tigtj3 http://blog.numino.net/ alert(oPlugin.title); 8ykx88 http://blog.numino.net/ folderName - read only, return plugin's folder name J9R7mg http://blog.numino.net/ Example: 73svI2 http://blog.numino.net/ alert(oPlugin.folderName); 2GE81w http://blog.numino.net/ fullPath - read only, return plugin folder's full path JErFBZ http://blog.numino.net/ Example: O6KpnY http://blog.numino.net/ alert(oPlugin.fullPath); ZW2lH4 http://blog.numino.net/ enable - read/write, return or set if the plugin is enabled AHqwIQ http://blog.numino.net/ Example: 2DbijF http://blog.numino.net/ oPlugin.enable=false; TqA84c http://blog.numino.net/ alert(oPlugin.enable); 59ubyP http://blog.numino.net/ oPlugin.enable=true; y66Q6F http://blog.numino.net/ alert(oPlugin.enable); C816c2 http://blog.numino.net/ startAfterPageDone - read/write, return or set if the plugin is auto started TO23dn http://blog.numino.net/ Example: 1f232h http://blog.numino.net/ oPlugin.startAfterPageDone = true; h6fD65 http://blog.numino.net/ alert(oPlugin.startAfterPageDone); wjpGMZ http://blog.numino.net/ oPlugin.startAfterPageDone = false; 7tiVak http://blog.numino.net/ alert(oPlugin.startAfterPageDone); gQwbEy http://blog.numino.net/ startAfterPageDoneUrl - read/write, return or set the address where the plugin will be auto started 7DXHZo http://blog.numino.net/ Example: svEXiU http://blog.numino.net/ oPlugin.startAfterPageDoneUrl='*maxthon.com*|*maxthon.cn*'; POp4Z7 http://blog.numino.net/ alert(oPlugin.startAfterPageDoneUrl); EtYMDm http://blog.numino.net/ Methods: 17ijc7 http://blog.numino.net/ config() - open plugin configuration dialog (config.html) 4cXhC0 http://blog.numino.net/ Example: QgnVO1 http://blog.numino.net/ oPlugin.config(); pNV05M http://blog.numino.net/ remove() - delete the plugin 7oBHiE http://blog.numino.net/ Example: Wb2hZA http://blog.numino.net/ oPlugin.remove(); F42eSv http://blog.numino.net/ [edit] Mscript BwBACy 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...> Nx2676 http://blog.numino.net/ Example - the following script button plugin can disable scripting in the current page by changing Maxthon's content control: t3lQZl http://blog.numino.net/ <script language="javascript"> K4Us9I http://blog.numino.net/ external.m2_run_cmd(%max_security_id, 33175); Nf4ToV http://blog.numino.net/ </script> RXfd8n 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. 1XLgl1 http://blog.numino.net/ <mscript language="javascript"> Aux4Mf http://blog.numino.net/ external.m2_run_cmd(0, 33175); 9X4rx5 http://blog.numino.net/ </script> ku077Q http://blog.numino.net/ Note an arbitrary number can be used as %max_security_id when mscript is used
|
|