Chrome的一些实用脚本(牛逼)

转载自:http://www.guao.hk/posts/some-javascript-for-chrome.html

Chrome的扩展目前还全部属于实验阶段,只有极少的示范性扩展,并且只有dev channel的Chrome才提供扩展支持,好在我们还有Script,下面我们来介绍一些实用的Chrome脚本。

使用方法为,右键点击书签栏,选择Add Page

之后在弹出窗口中填写内容,Name可以随便写,只有显示一个作用。URL中输入本文提供的脚本,最后点ok即可。

1,Note in GoogleReader,通过Note方式Share任何网站到Google Reader

javascript:var%20b=document.body;var%20GR________bookmarklet_domain='http://www.google.com';if(b&&!document.xmlVersion){void(z=document.createElement('script'));void(z.src='http://www.google.com/reader/ui/link-bookmarklet.js');void(b.appendChild(z));}else{}

2,Translate Selection(or URL) to English,将所选部分(或者URL)翻译为英文

javascript:var t=((window.getSelection&&window.getSelection())||(document.getSelection&&document.getSelection())||(document.selection&&document.selection.createRange&&document.selection.createRange().text));var e=(document.charset||document.characterSet);if(t!=''){window.open('http://translate.google.com/translate_t#auto|en|'+encodeURIComponent(t),'Translate Selection(or URL) to English','scrollbars=yes,width=680,height=510,top=175,left=75,status=no,resizable=yes');}else{var translate_words=prompt('Translate Words',''); if ( translate_words ) { window.open('http://translate.google.com/translate_t#auto|en|'+encodeURIComponent(translate_words),'Translate Selection(or URL) to English','scrollbars=yes,width=680,height=510,top=175,left=75,status=no,resizable=yes');}else{window.open('http://translate.google.com/translate?u='+escape(location.href)+'&hl=en&langpair=auto|en');}};

3,Translate Selection(or URL) to Chinese,将所选部分(或者URL)翻译为中文

javascript:var t=((window.getSelection&&window.getSelection())||(document.getSelection&&document.getSelection())||(document.selection&&document.selection.createRange&&document.selection.createRange().text));var e=(document.charset||document.characterSet);if(t!=''){window.open('http://translate.google.com/translate_t?text='+t+'&hl=en&langpair=auto|zh-CN&tbb=1&ie='+e,'Translate Selection(or URL) to Chinese','scrollbars=yes,width=680,height=510,top=175,left=75,status=no,resizable=yes');}else{var translate_words=prompt('Translate Words',''); if ( translate_words ) {window.open('http://translate.google.com/translate_t?text='+encodeURIComponent(translate_words)+'&hl=en&langpair=auto|zh-CN','Translate Selection(or URL) to Chinese','scrollbars=yes,width=680,height=510,top=175,left=75,status=no,resizable=yes');}else{window.open('http://translate.google.com/translate?u='+escape(location.href)+'&hl=en&langpair=auto|zh-CN');}};

4,Bookmark To Google,添加到GoogleBookmark

javascript:(function(){var a=window,b=document,c=encodeURIComponent,d=a.open("http://www.google.com/bookmarks/mark?op=edit&output=popup&bkmk="+c(b.location)+"&title="+c(b.title),"bkmk_popup","left="+((a.screenX||a.screenLeft)+10)+",top="+((a.screenY||a.screenTop)+10)+",height=420px,width=550px,resizable=1,alwaysRaised=1");a.setTimeout(function(){d.focus()},300)})();

5,Send Selection To Gmail,将所选部分通过Gmail发送

javascript:popw='';Q='';x=document;y=window;if(x.selection) {Q=x.selection.createRange().text;} else if (y.getSelection) {Q=y.getSelection();} else if (x.getSelection) {Q=x.getSelection();}if(Q!=''){popw = y.open('https://mail.google.com/mail/?view=cm&fs=1&tf=1&to=&su=' + encodeURIComponent(document.title) + '&body=' + encodeURIComponent(Q) + encodeURIComponent('\n\n\n') + encodeURIComponent('From URL:'+location.href) + '&zx=RANDOMCRAP&shva=1&disablechatbrowsercheck=1&ui=1','gmailForm','scrollbars=yes,width=680,height=510,top=175,left=75,status=no,resizable=yes');}else{popw = y.open('https://mail.google.com/mail/?view=cm&fs=1&tf=1&to=&zx=RANDOMCRAP&shva=1&disablechatbrowsercheck=1&ui=1','gmailForm','scrollbars=yes,width=680,height=510,top=175,left=75,status=no,resizable=yes');}if (!document.all) T = setTimeout('popw.focus()',50);void(0);

6,Subscribe as you surf to Google Reader,用Google Reader订阅当前页面内的Feed

javascript:var%20b=document.body;var%20GR________bookmarklet_domain='http://www.google.com';if(b&&!document.xmlVersion){void(z=document.createElement('script'));void(z.src='http://www.google.com/reader/ui/subscribe-bookmarklet.js');void(b.appendChild(z));}else{location='http://www.google.com/reader/view/feed/'+encodeURIComponent(location.href)}

7,Google MusicTime!,搜索谷歌音乐

javascript:var music_words=prompt('Search Google music',''); if ( music_words ) { window.open('http://www.google.cn/music/search?q=' + encodeURIComponent(music_words));}else{window.open('http://g.top100.cn/7872775/html/player.html?&autoplay=true#loaded','Google Music','scrollbars=yes,width=740,height=520,top=175,left=75,status=no,resizable=yes');}

8,Map This on Google,在Google Maps中查找

javascript:d=%22%22+(window.getSelection?window.getSelection():document.getSelection?document.getSelection():document.selection.createRange().text);d=d.replace(/%5Cr%5Cn%7C%5Cr%7C%5Cn/g,%22%20,%22);if(!d)d=prompt(%22Enter%20the%20address:%22,%20%22%22);if(d){window.open(%22http://ditu.google.com/?ie=UTF8&q=%22+encodeURIComponent(d).replace(/%20/g,%22+%22));}else(void(null))

9,Add Event To Calendar,在Calendar中添加事件(注意如果点出窗口后,要取消添加的话,请点击No,如果点击cancel的话会建立一个空的event)

javascript:var t=((window.getSelection&&window.getSelection())||(document.getSelection&&document.getSelection())||(document.selection&&document.selection.createRange&&document.selection.createRange().text));var today=new Date();month=today.getMonth()+1;day=today.getDate();hours=today.getHours();minutes=today.getMinutes();hours1=hours+1;getdate=today.getDate();if(hours<10){hours='0'+hours;}if(hours1<10){hours1='0'+hours1;}if(month<10){month='0'+month;}if(day<10){day='0'+day;}if(minutes<10){minutes='0'+minutes;}if(getdate<10){getdate='0'+getdate;}date=today.getFullYear()+''+month+''+getdate;window.open('http://www.google.com/calendar/event?action=TEMPLATE&dates='+date+'T'+hours+minutes+'00/'+date+'T'+hours1+minutes+'00&text='+encodeURIComponent(t),'Remind me with Google Calendar','scrollbars=yes,width=1050,height=445,top=180,left=75,status=no,resizable=yes');

10,Get Quotes On Google Finance,在Google财经中查询股价

javascript:search_words=prompt('Get Quotes',''); if ( search_words ) { window.open('http://www.google.cn/finance?q=' + encodeURIComponent(search_words));}else{void(null)}

11,Search Google Image,调用Google图像搜索

javascript:search_words=prompt('Search Google Image',''); if ( search_words ) {window.open('http://images.google.cn/images?q=' + encodeURIComponent(search_words));}else{void(null)}

12,Read your next subscriptions,阅读你的下个订阅

javascript:window.open('http://www.google.com/reader/next?go=nextauto&t=-1539437635047966106');

在我这里不起作用,弹出一个播放器窗口

13,Search Weather For City,查询城市天气预报

javascript:search_words=prompt('Search Weather For City',''); if ( search_words ) { window.open('http://www.google.cn/m?loc=' + encodeURIComponent(search_words)+'&mrestrict=xhtmlchtml&eosr=on&site=weather');}else{void(null)}

14,Search Train On Google,在Google查找火车票信息

javascript:search_words=prompt('From city','');search_words1=prompt('To city',''); if ( search_words && search_words1) { window.open('http://shenghuo.google.cn/shenghuo/search?a_y0=9&a_n0=火 车票&view=table&a_n1=始发站&a_y1=1&a_o1=0&a_v1='+ encodeURIComponent(search_words)+'&a_n2=到达站&a_y2=1&a_o2=0& amp;a_v2=' + encodeURIComponent(search_words1));}else{void(null)}

似乎到达城市参数没有传达过去

15,Search YouKu Video,搜索优酷视频

javascript:search_words=prompt('Search YouKu Video',''); if ( search_words ) { window.open('http://so.youku.com/search/video/q_' + encodeURIComponent(search_words));}else{void(null)}

16,实时编辑网页并且下载编辑结果到电脑

javascript:document.body.contentEditable='true'; document.designMode='on'; void 0

我这里这个没有实验成功,Chrome Dev 3.0.182.3

17,Search in wikipedia,搜索wikipedia

javascript:void((function(){var%20a=document.getSelection().toString();window.open("http://zh.wikipedia.org/wiki/"+a.replace('_',' '));})())

好像也有点问题,在我这里没有询问我关键字,只是直接打开了wikipedia的首页。

你可能感兴趣的:(Chrome的一些实用脚本(牛逼))