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. Kn9ZVI http://blog.numino.net/ How to obtain the Security ID C00pb1 http://blog.numino.net/ 1. Script button plugins can use "%max_security_id" for the Security ID Kht2Vu 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。 944WE3 http://blog.numino.net/ <script src=max.src></script> xh1g83 http://blog.numino.net/ Reference for Maxthon Plugin Commands lejpad http://blog.numino.net/ Unless specified otherwise, the following plugin commands are applicable for both Maxthon 2.0 and Maxthon 1.X。 vZ0dcC http://blog.numino.net/ 1. max_version - return Maxthon's version number 964rFm http://blog.numino.net/ Example: 7gpV5H http://blog.numino.net/ alert(external.max_version); H0Ou6o http://blog.numino.net/ 2. max_language_id - return Maxthon's language ID 97T3a5 http://blog.numino.net/ Example: 52aD8L http://blog.numino.net/ alert(external.max_language_id); Zn3iMM http://blog.numino.net/ Note: Maxthon 2.0 and Maxthon 1.X have different language ID format E0Yzlp http://blog.numino.net/ 3. tab_count - return the number of tabs opened by Maxthon jgfBb2 http://blog.numino.net/ Example: UOEvR7 http://blog.numino.net/ alert(external.tab_count); puDxbx http://blog.numino.net/ 4. cur_sel - return the index of Maxthon's current tab P4ETcM http://blog.numino.net/ Example: O8nl0i http://blog.numino.net/ alert(external.cur_sel); Ts7022 http://blog.numino.net/ 5. m2_plugin_folder( security_id , plugin_name ) - return the folder path of the specified plugin AeDj9R http://blog.numino.net/ Example: C0qN1D http://blog.numino.net/ alert(external.m2_plugin_folder( %max_security_id , 'ViewSource!')); CEhX1z http://blog.numino.net/ 6. m2_run_cmd( security_id , command_id ) - run the specified command ID 94K28W http://blog.numino.net/ Example: CKoi4w http://blog.numino.net/ external. m2_run_cmd( %max_security_id , 32772 )); X3gkX5 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. k8H3N9 http://blog.numino.net/ 7. get_tab( security_id , tab_index ) - return the window object of the specifed tab c9Y30M http://blog.numino.net/ Example: oxzmFR http://blog.numino.net/ var oWin=external.get_tab(%max_security_id, 0); plJ97h http://blog.numino.net/ alert(oWin.document.URL); 4YLe6I http://blog.numino.net/ 8. activate_tab( security_id , tab_index ) - activate the specified tab MlPjQ5 http://blog.numino.net/ Example: H1SFRV http://blog.numino.net/ external.activate_tab(%max_security_id, 0); pF5pJN http://blog.numino.net/ 9. close_tab( security_id , tab_index ) - close the specified tab akCfb1 http://blog.numino.net/ Example: MjGLIt http://blog.numino.net/ external.close_tab(%max_security_id, 0); 6u4NlH http://blog.numino.net/ 10. readFile( security_id, plugin_name, file_name) - read the content of specified text file IEcTyh http://blog.numino.net/ Example: Ql57gq http://blog.numino.net/ var sText=external.readFile(%max_security_id, 'ViewPage', 'readme.txt'); BWcL1T http://blog.numino.net/ alert(sText); H7KObq http://blog.numino.net/ 11. writeFile( security_id, plugin_name, file_name, content ) - write content to the specific text file QABr9K http://blog.numino.net/ Example: S6dr0v http://blog.numino.net/ external.writeFile(%max_security_id, 'ViewPage', 'test.txt', 'This is the file content'); 5GXL1b http://blog.numino.net/ 12. m2_readIni( security_id, plugin_name , file_name , section_name , key , default_value) - read data from specific INI file HSfByp http://blog.numino.net/ Example: kIxWzP http://blog.numino.net/ var sDownloadTool=external.m2_readIni(%max_security_id, 'ViewPage', 'plugin.ini', 'Settings', 'Tool', ); X64j8q http://blog.numino.net/ alert(sDownloadTool); 1Xhhl4 http://blog.numino.net/ 13. m2_writeIni( security_id , plugin_name , file_name , section_name , key , value ) - write data to specific INI file Lx9bBV http://blog.numino.net/ Example: r8n0K9 http://blog.numino.net/ external.m2_writeIni(%max_security_id, 'ViewPage', 'test.ini', 'Config', 'height', '100px'); M1I4tc http://blog.numino.net/ 14. max_modelessDialog( security_id , url , option , attr , window ) - returns a modeless web page dialog 5aUSGs http://blog.numino.net/ Example: 4mU6ed http://blog.numino.net/ var oDialog= external.max_modelessDialog( %max_security_id , 'blank.html', window , , window ); g828dl http://blog.numino.net/ var oDoc=oDialog.document; H5WNsT http://blog.numino.net/ oDoc.write('Testing'); 0k95A7 http://blog.numino.net/ oDoc.close(); 36dyUn http://blog.numino.net/ 15. max_activex(security_id ,program_id) - return specified ActiveX object N71NlL http://blog.numino.net/ Example: l2RrEA http://blog.numino.net/ var oWSH=external.max_activex(%max_security_id, 'WScript.Shell'); mbHxR5 http://blog.numino.net/ oWSH.run('notepad.exe'); V43B7F http://blog.numino.net/ 16. m2_search_text(security_id) - return the text in search bar jgfc03 http://blog.numino.net/ Example: mp36Wk http://blog.numino.net/ alert(m2_search_text(%max_security_id)); 2NGNUg 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) EQ5MVU 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. 7RxQ0l http://blog.numino.net/ Example: wQQ3vz http://blog.numino.net/ function max_callback(x){ 7NnJ80 http://blog.numino.net/ if(x=='tab_change') alert('Current tab is changed.'); G08JFE http://blog.numino.net/ } cxPH1o http://blog.numino.net/ By checking the parameter of the max_callback function, plugin can get the following browser events: 4cSBj5 http://blog.numino.net/ HTML button plugins io86o0 http://blog.numino.net/ tab_change – after the current tab is switched 1Kc87R http://blog.numino.net/ document_Complete - after the current tab is fully loaded 164TVW http://blog.numino.net/ self_destroy - when the html is unloaded, usually when Maxthon exits SFnoVK http://blog.numino.net/ Script sidebar plugins MjWf88 http://blog.numino.net/ sidebar_tab_change - after the current tab is switched 00ZAEu http://blog.numino.net/ sidebar_activate - when the sidebar plugin is activated ky2kTn http://blog.numino.net/ sidebar_deactivate - when the sidebar plugin is deactivated KLsHl7 http://blog.numino.net/ sidebar_unload - when the sidebar plugin is unloaded (Maxthon is closed) RB6895 http://blog.numino.net/ 18. max_getObj (for Maxthon 2.0 only) - return various Maxthon objects, including: iVUdz6 http://blog.numino.net/ Info - general information about Maxthon g2wlYP http://blog.numino.net/ Adhunter – about Ad Hunter 3sEwuN http://blog.numino.net/ FavManager – about Favorites 6YXt70 http://blog.numino.net/ RssManager – about RSS qm6XDP http://blog.numino.net/ PluginManager - about Plugins, for Maxthon 2.0.5 or later YXKsyg http://blog.numino.net/ Example: 3aTahM http://blog.numino.net/ var oInfo=external.max_getObj(%max_security_id, 'info'); j3K7Re http://blog.numino.net/ Info Object supports the following property and method: tUL608 http://blog.numino.net/ Property: Tx8pej http://blog.numino.net/ fileProxy - read-only, returns the path of the current user's proxy configuration document. gvxx2S http://blog.numino.net/ Example: 0Ip671 http://blog.numino.net/ var oInfo=external.max_getObj(%max_security_id, 'info'); S08t82 http://blog.numino.net/ alert(oInfo.fileProxy); VB0Wru http://blog.numino.net/ folderUser - read-only, returns the path of the profile folder of the current user X17hZ7 http://blog.numino.net/ Example: RIB4hy http://blog.numino.net/ var oInfo=external.max_getObj(%max_security_id, 'info'); Gz37vs http://blog.numino.net/ alert(oInfo. folderUser); Yrojon http://blog.numino.net/ Method: qKCcln http://blog.numino.net/ getFolderPluginData(plugin_name) - obtain the path of plugin data storage folder for the current user and the plugin w2BScO http://blog.numino.net/ Example: AhuGK9 http://blog.numino.net/ var oInfo=external.max_getObj(%max_security_id, 'info'); V947t2 http://blog.numino.net/ alert(oInfo.getFolderPluginData('ViewSource!')); D2cMDJ http://blog.numino.net/ AdHunter object support the following method: kqEtpj http://blog.numino.net/ Method: NYm06T http://blog.numino.net/ reloadFilter(filter_name) – reload the specified Maxthon filter (currently content filter only) after modifying the relevant filter S4bCMw http://blog.numino.net/ Example: Anf0zI http://blog.numino.net/ var oAdHunter=external.max_getObj(%max_security_id, 'AdHunter'); 4H532i http://blog.numino.net/ oAdHunter.reloadFilter('content'); ybIG3M http://blog.numino.net/ enableFilter(filter_name, bEnable) – enable or disable Maxthon's 'content' or 'popup' filter hhzN68 http://blog.numino.net/ Example: 3DUG7C http://blog.numino.net/ var oAdHunter=external.max_getObj(%max_security_id, 'AdHunter'); 8M25dW http://blog.numino.net/ oAdHunter.enableFilter ('content', false); PNki0G http://blog.numino.net/ PluginManager object support the following method: GEZ8z6 http://blog.numino.net/ getPluginFolder - return Maxthon main plugin folder path 3meB74 http://blog.numino.net/ Example: kZLZuS http://blog.numino.net/ var oPluginManager=external.max_getObj(%max_security_id, 'PluginManager'); 2I9k2N http://blog.numino.net/ alert(oPluginManager.getPluginFolder) PoeHdz http://blog.numino.net/ getCount - return the number of all installed plugins, both enabled and disabled RM7R8c http://blog.numino.net/ Example: dkIVN4 http://blog.numino.net/ var oPluginManager=external.max_getObj(%max_security_id, 'PluginManager'); jZt8Jp http://blog.numino.net/ alert(oPluginManager.getCount) ThY2Y7 http://blog.numino.net/ getList - return a list which contains information like name, author etc of all plugins 0Oc3jU http://blog.numino.net/ Example: R0CqQz http://blog.numino.net/ var oPluginManager=external.max_getObj(%max_security_id, 'PluginManager'); edhbK2 http://blog.numino.net/ alert(oPluginManager.getList) w4CrIp http://blog.numino.net/ getPlugin(Index) - Index is a number, return the corresponding plugin object eq1uI1 http://blog.numino.net/ Example: vkai6y http://blog.numino.net/ var oPluginManager=external.max_getObj(%max_security_id, 'PluginManager'); 3P6ELC http://blog.numino.net/ var oPlugin=oPluginManager.getPlugin(0); Fg4Ux8 http://blog.numino.net/ The plugin object returned from getPlugin(Index) supports the following property and method: VwX9NS http://blog.numino.net/ Property: 0vX58b http://blog.numino.net/ title - read only, return plugin name rX1KjT http://blog.numino.net/ Example: 4n414r http://blog.numino.net/ alert(oPlugin.title); SSXGY6 http://blog.numino.net/ folderName - read only, return plugin's folder name o1VM5h http://blog.numino.net/ Example: mo1B23 http://blog.numino.net/ alert(oPlugin.folderName); rB9K5g http://blog.numino.net/ fullPath - read only, return plugin folder's full path vzrFoy http://blog.numino.net/ Example: E4TTTQ http://blog.numino.net/ alert(oPlugin.fullPath); D4DOpS http://blog.numino.net/ enable - read/write, return or set if the plugin is enabled OoO7kE http://blog.numino.net/ Example: qJ3zWk http://blog.numino.net/ oPlugin.enable=false; 5P0o1i http://blog.numino.net/ alert(oPlugin.enable); 895OB8 http://blog.numino.net/ oPlugin.enable=true; CoJ48o http://blog.numino.net/ alert(oPlugin.enable); p0WSQA http://blog.numino.net/ startAfterPageDone - read/write, return or set if the plugin is auto started KWMbbe http://blog.numino.net/ Example: cTcc66 http://blog.numino.net/ oPlugin.startAfterPageDone = true; g2I2dY http://blog.numino.net/ alert(oPlugin.startAfterPageDone); hQdMiu http://blog.numino.net/ oPlugin.startAfterPageDone = false; 59AR5e http://blog.numino.net/ alert(oPlugin.startAfterPageDone); jjJMD5 http://blog.numino.net/ startAfterPageDoneUrl - read/write, return or set the address where the plugin will be auto started F9dOb5 http://blog.numino.net/ Example: c4Bpx2 http://blog.numino.net/ oPlugin.startAfterPageDoneUrl='*maxthon.com*|*maxthon.cn*'; ymESnf http://blog.numino.net/ alert(oPlugin.startAfterPageDoneUrl); HQNDJq http://blog.numino.net/ Methods: q4Eimi http://blog.numino.net/ config() - open plugin configuration dialog (config.html) 2a30Xt http://blog.numino.net/ Example: HaXz5C http://blog.numino.net/ oPlugin.config(); 07psJd http://blog.numino.net/ remove() - delete the plugin 8718Gt http://blog.numino.net/ Example: Eeqdrm http://blog.numino.net/ oPlugin.remove(); bBZM99 http://blog.numino.net/ [edit] Mscript N0oUj4 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...> Gzyzp0 http://blog.numino.net/ Example - the following script button plugin can disable scripting in the current page by changing Maxthon's content control: ogGjsn http://blog.numino.net/ <script language="javascript"> sfXmH4 http://blog.numino.net/ external.m2_run_cmd(%max_security_id, 33175); yL4RVw http://blog.numino.net/ </script> 5G6Bpy 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. 2BJmE4 http://blog.numino.net/ <mscript language="javascript"> dB0GC7 http://blog.numino.net/ external.m2_run_cmd(0, 33175); Vcl523 http://blog.numino.net/ </script> A1R1kn http://blog.numino.net/ Note an arbitrary number can be used as %max_security_id when mscript is used
|
|