greasemonkey内置了ajax管理器
greasemonkey这工具,就好像web开发人员的作弊器一样,好玩。经常去的网站,若是看着不顺眼,就祭出greasemonkey对它页面元素的位置调整一番,把主题内容字体搞大,把广告隐藏不见,别人的网站我做主,倒也有一番小小乐趣(我可没有hack它的站点哦)。这些天看看文档,原来人家已经内置了xmlhttpRequest的api,不用费牛劲去外部导入一些js来搞这些基础工程了。
Description
GM_xmlhttpRequest makes an arbitrary HTTP request. The details argument is an object that can contain up to seven fields.
一个greasemonkey的ajax调用
CODE:
-
GM_xmlhttpRequest({
-
method: 'GET',
-
url: 'http://greaseblog.blogspot.com/atom.xml',
-
headers: {
-
'User-agent': 'Mozilla/4.0 (compatible)
-
Greasemonkey',
-
'Accept':
-
-
'application/atom+xml,application/xml,text/xml',
-
},
-
onload: function(responseDetails) {
-
alert('Request for Atom feed returned ' +
-
-
responseDetails.status +
-
' ' + responseDetails.statusText + '\n\n'
-
-
+
-
'Feed data:\n' +
-
-
responseDetails.responseText);
-
}
-
});
较详细一些的内容,可以去Dive Into Greasemonkey查阅.
作者: volcano 发表于5月 22, 2007 at 8:03 am