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:
  1. GM_xmlhttpRequest({
  2.     method: 'GET',
  3.     url: 'http://greaseblog.blogspot.com/atom.xml',
  4.     headers: {
  5.         'User-agent': 'Mozilla/4.0 (compatible)
  6. Greasemonkey',
  7.         'Accept':
  8.  
  9. 'application/atom+xml,application/xml,text/xml',
  10.     },
  11.     onload: function(responseDetails) {
  12.         alert('Request for Atom feed returned ' +
  13.  
  14. responseDetails.status +
  15.               ' ' + responseDetails.statusText + '\n\n'
  16.  
  17. +
  18.               'Feed data:\n' +
  19.  
  20. responseDetails.responseText);
  21.     }
  22. });

较详细一些的内容,可以去Dive Into Greasemonkey查阅.

什么是greasemonkey?

作者: volcano 发表于5月 22, 2007 at 8:03 am

版权信息: 可以任意转载, 转载时请务必以超链接形式标明文章原始出处作者信息及此声明

Tags: ,,

留条评论