用来看新浪新闻的greasemonkey脚本

刚从灾区长沙回到北京,那段时间虽然是隔三岔五的停电停水,俺还没忘趁着来电爬到新浪上面看看近期新闻,也好对最近的形势有些了解。闲着无聊写了个greasemonkey脚本,把新浪的新闻页右边那块没营养的内容统统隐藏掉。
放出来给需要的同学下载。
安装这个脚本的步骤

首先你必须是使用firefox浏览器
安装greasemonkey插件
下载俺的NewsSina greasemonkey脚本,如果你已经安装好greasemonkey,点击前面的链接应该会弹出一个安装窗口
去新浪的新闻页上看看,右边的内容还有吗?

评论 (1)

jquery和greasemonkey齐上阵

jquery写起来真的很简单,连我这刚接触jquery不久的新人都能很快用它码出大段的javascript。唯一的坏处是代码里充斥了大量的$。既然写javascript如此简单,那么用jquery+greasemonkey插件同时干活怎么样呢?
这里是一段提醒jquery已经载入的脚本,为了避免和页面上原有的代码冲突,得运行$.noConflict().
PLAIN TEXT
CODE:

// All your GM code must be inside this function

function letsJQuery() {

//make sure there is no conflict between jQuery and other libraries

$.noConflict()

//notify that jQuery is running...

  $('<div>jQuery is running!</div>')

    .css({padding: '10px', background: '#ffc', position: 'absolute',top: '0', width: '100%'})

    .prependTo('body')

    .fadeIn('fast')

    .animate({opacity: 1.0}, 300)

    .fadeOut('fast', function() {

      $(this).remove();

    [...]

评论 (4)

过滤掉起点可恶的广告

有时候会跑到起点上去看书,打发无聊时光。但是起点的文章页不是太厚道,有一块狗皮膏药广告非常碍眼,牢牢的占据了屏幕右下方一块比较大的面积,这部分的字是看也看不到,很让人难受。
这时候祭出greasemonkey来教训它,写一点javascript就可以了:
document.getElementById("ifPage").style.display = "none";
上面的代码能把广告所在的div隐藏~~
greasemonkey脚本下载
CmfuReader.user.js

评论 (3)

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调用
PLAIN TEXT
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 [...]

评论