[笔记] 用javascript为浏览器写写小插件

在人人上拖了个书签到chrome的书签栏,只要下次在某个页面点击下就能轻松分享当前页面。

怎么实现的呢?编辑书签,有:

javascript:void(
  (function(s,d,e) {
    if(/renren/.com/.test(d.location))return;
    var f='http://share.renren.com/share/buttonshare.do?link=',
        u=d.location,
        l=d.title,
        p=[e(u),'&title=',e(l)].join('');
    function a() {
       if(!window.open([f,p].join(''),'xnshare',['toolbar=0,status=0,resizable=1,width=626,height=436,left=',(s.width-626)/2,',top=',(s.height-436)/2].join('')))
           u.href=[f,p].join('');
    };
    if(/Firefox/.test(navigator.userAgent))
       setTimeout(a,0);else a();
  })(screen,document,encodeURIComponent));


取出基本框架:

javascript:void ((
 function(s,d,e)
{
    // TODO: do something here
}
)(screen,document,encodeURIComponent));


下面就靠大家驰骋啦~~
举个小例子,让div里的文字变红:

javascript:void ((
 function(s,d,e)
 {
    var i=0,t=d.getElementsByTagName('div');
    for(i=0;i<t.length;i++) t[i].style.color='#ff0000';
 }
)(screen,document,encodeURIComponent));


然后把它编成一行,添加到书签里。
打开一个网页,然后点刚才的书签~
文字变红啦~
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值