如何制作傲游插件?
二、方法
(一)、一般方法
1. addFavorite
该方法将询问用户是否添加 url 到收藏夹, 可以使用 title 给该链接命名.
addFavorite(url [, title])
参数
Parameters
url
必选项。字符串, 页面地址
Required. string, The url to add.
title 网络工具箱
可选项。字符串, 页面标题
Optional. string, The title of the url.
示例
Example
例II-2-(1)_1.1 添加网址到收藏夹
例II-2-(1)_1.2 添加网址和标题到收藏夹 常用软件教程wlgjx.com
2. addProxy
添加代理到 Maxthon 的代理服务器列表中
(1). 1.x 版本
addProxy(name, address, speed, type)
参数
Parameters
name
必选项。代理名称
Required. The display name of proxy.
address
必选项。代理地址: <地址>:<端口>
Required. The IP address or Domain name of proxy.
speed
必选项。代理速度: 0 无效, 1 很慢,2 较慢,3 一般,4 较快,5 很快
Required.
type
必选项。代理类型: 1 HTTP 和 FTP 代理,0 其他代理类型
Required.
示例
Example
例II-2-(1)_2.1 添加代理到 Maxthon 1.x
(2). 2.x 版本
addProxy(name, address, type) 网络工具箱
参数
Parameters
name
必选项。代理名称
Required. The display name of proxy.
address
必选项。代理地址: <地址>:<端口>
Required. The IP address or Domain name of proxy.
type
必选项。代理类型: 0 = HTTP 代理, 1 = Socks 4a 代理, 2 = Socks 5 代理
Required. A number indicates the speed rating of proxy. 0 = HTTP Proxy, 1 = Socks 4a Proxy, 2 = Socks 5 Proxy
示例
Example
例II-2-(1)_2.2 添加代理到 Maxthon 2.x
3. addFilter
添加过滤规则到 Maxthon 的过滤列表中。
addFilter(url_mask [, type]) 软件帮助wlgjx.com
参数
Parameters
url_mask
必选项。字符串或正则表达式。过滤地址匹配规则
Required. String. Address mask to match blocked addresses. Supports Regular Expression.
type
可选项。整数。过滤类型
Optional. Integer. A number indicates which Filter list to add.
(a). 1.x 版本
0 = 网页内容过滤,1 = 弹出窗口过滤
0 = Content Filter, 1 = Popup Filter
(b). 2.x 版本
0 = 弹出窗口过滤,1 = 网页内容过滤
0 = Popup Filter, 1 = Content Filter
示例
Example
例II-2-(1)_3 添加过滤到 Maxthon
4. m2_run_cmd
该函数将调用一个 Maxthon 命令.
This function will call a Maxthon's command with the ID.
m2_run_cmd( security_id, command_id)
参数
Parameters
security_id
必选项。傲游安全ID
Required. Maxthon's Security ID.
command_id
必选项。整数。傲游命令编号
Required. Integer. The internal command ID of Maxthon.
说明
Remarks
这些命令的编号可以在语言文件 language.ini 里面找到. wlgjx
The id of every command could be found in the language file.
示例
Example
例II-2-(1)_4 新建一个空白页
Open a Blank Page
5. m2_search_text
返回 Maxthon 搜索栏中的文本.
This function will return the text in Maxthon's Search Box as a string.
m2_search_text(security_id)
参数
Parameters
security_id
必选项。傲游安全ID
Required. Maxthon's Security ID.
示例
Example
例II-2-(1)_5 获取搜索关键词
6. m2_plugin_folder
该函数将返回插件文件夹的本地路径.
This function will return the local path of the plugin.
m2_plugin_folder(security_id, plugin_name)
参数
Parameters
security_id
必选项。傲游安全ID
Required. Maxthon's Security ID.
plugin_name
必选项。插件名称,即 plugin.ini 中 General 部分的 Name 值。
Required. The name of the plugin as defined in plugin.ini.
要求
Requirements 复制于wlgjx.com
Maxthon Version 1.2+
示例
Example
例II-2-(1)_6 获取 ViewPage 的文件夹路径
(一)、一般方法
1. addFavorite
该方法将询问用户是否添加 url 到收藏夹, 可以使用 title 给该链接命名.
addFavorite(url [, title])
参数
Parameters
url
必选项。字符串, 页面地址
Required. string, The url to add.
title 网络工具箱
可选项。字符串, 页面标题
Optional. string, The title of the url.
示例
Example
例II-2-(1)_1.1 添加网址到收藏夹
引用
external.addFavorite("http://www.maxthon.com");
例II-2-(1)_1.2 添加网址和标题到收藏夹 常用软件教程wlgjx.com
引用
external.addFavorite( "http://www.maxthon.com","Maxthon Official Site" );
2. addProxy
添加代理到 Maxthon 的代理服务器列表中
(1). 1.x 版本
addProxy(name, address, speed, type)
参数
工具箱wlgjx.com
Parameters
name
必选项。代理名称
Required. The display name of proxy.
address
必选项。代理地址: <地址>:<端口>
Required. The IP address or Domain name of proxy.
speed
必选项。代理速度: 0 无效, 1 很慢,2 较慢,3 一般,4 较快,5 很快
Required.
type
必选项。代理类型: 1 HTTP 和 FTP 代理,0 其他代理类型
Required.
示例
Example
网络工具箱
例II-2-(1)_2.1 添加代理到 Maxthon 1.x
引用
external.addProxy("My proxy", "192.168.1.0:8080", 3, 0);
(2). 2.x 版本
addProxy(name, address, type) 网络工具箱
参数
Parameters
name
必选项。代理名称
Required. The display name of proxy.
address
必选项。代理地址: <地址>:<端口>
Required. The IP address or Domain name of proxy.
type
必选项。代理类型: 0 = HTTP 代理, 1 = Socks 4a 代理, 2 = Socks 5 代理
Required. A number indicates the speed rating of proxy. 0 = HTTP Proxy, 1 = Socks 4a Proxy, 2 = Socks 5 Proxy
示例
Example
网络工具箱
例II-2-(1)_2.2 添加代理到 Maxthon 2.x
引用
external.addProxy("My proxy", "192.168.1.0:8080", 0);
3. addFilter
添加过滤规则到 Maxthon 的过滤列表中。
addFilter(url_mask [, type]) 软件帮助wlgjx.com
参数
Parameters
url_mask
必选项。字符串或正则表达式。过滤地址匹配规则
Required. String. Address mask to match blocked addresses. Supports Regular Expression.
type
可选项。整数。过滤类型
Optional. Integer. A number indicates which Filter list to add.
(a). 1.x 版本
0 = 网页内容过滤,1 = 弹出窗口过滤
0 = Content Filter, 1 = Popup Filter
(b). 2.x 版本
0 = 弹出窗口过滤,1 = 网页内容过滤
软件帮助wlgjx.com
0 = Popup Filter, 1 = Content Filter
示例
Example
例II-2-(1)_3 添加过滤到 Maxthon
引用
external.addFilter("*/ad/*", 0);
4. m2_run_cmd
软件帮助wlgjx.com
该函数将调用一个 Maxthon 命令.
This function will call a Maxthon's command with the ID.
m2_run_cmd( security_id, command_id)
参数
Parameters
security_id
必选项。傲游安全ID
Required. Maxthon's Security ID.
command_id
必选项。整数。傲游命令编号
Required. Integer. The internal command ID of Maxthon.
说明
Remarks
这些命令的编号可以在语言文件 language.ini 里面找到. wlgjx
The id of every command could be found in the language file.
示例
Example
例II-2-(1)_4 新建一个空白页
Open a Blank Page
引用
external.m2_run_cmd(%max_security_id, 32772);
5. m2_search_text
返回 Maxthon 搜索栏中的文本.
复制于wlgjx.com
This function will return the text in Maxthon's Search Box as a string.
m2_search_text(security_id)
参数
Parameters
security_id
必选项。傲游安全ID
Required. Maxthon's Security ID.
示例
Example
例II-2-(1)_5 获取搜索关键词
引用
alert('Search Text =' + external.m2_search_text(%max_security_id));
软件帮助wlgjx.com 6. m2_plugin_folder
该函数将返回插件文件夹的本地路径.
This function will return the local path of the plugin.
m2_plugin_folder(security_id, plugin_name)
参数
Parameters
security_id
必选项。傲游安全ID
Required. Maxthon's Security ID.
plugin_name
必选项。插件名称,即 plugin.ini 中 General 部分的 Name 值。
Required. The name of the plugin as defined in plugin.ini.
要求
Requirements 复制于wlgjx.com
Maxthon Version 1.2+
示例
Example
例II-2-(1)_6 获取 ViewPage 的文件夹路径
引用
alert( "Plugin Path = " + external.m2_plugin_folder(%max_security_id, "ViewPage") );
0

