Firefox 实用小众扩展、脚本及小书签推荐(4)

by noz

本篇推荐一些小书签(Bookmarklet),虽然小书签在各个浏览器中均可使用,但在 Firefox 中多了一条途径,那就是配合 Flagfox。小书签在使用上非常方便,且无副作用,是居家必备之良品。

顺便推荐一个 Bookmarklet 网站:marklets,在里面可以搜到你想要的小书签。

小书签

1 站内 Google 搜索

在当前网页打开一个对话框,确认后搜索当前域名下网站内容。

1
javascript:q = window.getSelection().toString(); if (!q) q = window.prompt("Google", ""); if (q) window.open("http://www.google.com/search?q=site:" + encodeURIComponent(location.hostname + " " + q.replace(/\"/g,"")).replace(/ /g, "+"));

2 Readability

以 Readability 方式改善阅读界面,让阅读更加舒适。

1
javascript:(function(){window.baseUrl='http://www.readability.com';window.readabilityToken='t6xLHNJLthFMu89NEWpUV76a5wHeNtM2TvVDQSPC';var s=document.createElement('script');s.setAttribute('type','text/javascript');s.setAttribute('charset','UTF-8');s.setAttribute('src',baseUrl+'/bookmarklet/read.js');document.documentElement.appendChild(s);})()

3 网页文字繁体转化为简体

有时候看繁体(正体)网页有些累,可以用这个小书签转化为简体。

1
javascript:(function(){var s=document.getElementById("tongwenlet_cn");if(s!=null){document.body.removeChild(s);}var s=document.createElement("script");s.language="javascript";s.type="text/javascript";s.src="http://tongwen.openfoundry.org/NewTongWen/tools/bookmarklet_cn.js";s.id="tongwenlet_cn";document.body.appendChild(s); })();

4 启用搜狗云输入法

1
javascript:void((function(){var%20n=navigator.userAgent.toLowerCase();ie=n.indexOf('msie')!=-1?1:0;if(document.documentMode)ie=0;charset='';if(ie)charset=document.charset;src=ie&&charset=='utf-8'?'http://web.pinyin.sogou.com/web_ime/init2_utf8.php':'http://web.pinyin.sogou.com/web_ime/init2.php';element=document.createElement('script');element.setAttribute('src',src);document.body.appendChild(element);})())

5 WhatFont

启用后,可以显示鼠标处的网页文字字体。不过显示的字体是 CSS 中的定义字体,不代表实际字体,具体情况还需自行判断。

1
javascript:(function(){var%20d=document,s=d.createElement('scr'+'ipt'),b=d.body,l=d.location;s.setAttribute('src','http://chengyinliu.com/wf.js?o='+encodeURIComponent(l.href)+'&t='+(new%20Date().getTime()));b.appendChild(s)})();

6 Google 翻译为中文

1
javascript:var%20t=((window.getSelection&&window.getSelection())||(document.getSelection&&document.getSelection())||(document.selection&&document.selection.createRange&&document.selection.createRange().text));var%20e=(document.charset||document.characterSet);if(t!=''){location.href='http://translate.google.com/translate_t?text='+t+'&hl=en&langpair=auto|zh-CN&tbb=1&ie='+e;}else{location.href='http://translate.google.com/translate?u='+escape(location.href)+'&hl=en&langpair=auto|zh-CN&tbb=1&ie='+e;};

7 Share to Google+

目前一键分享到 Google Plus 工具中的佼佼者。

1
javascript:(function(){var%20w=480;var%20h=380;var%20x=Number((window.screen.width-w)/2);var%20y=Number((window.screen.height-h)/2);window.open('https://plusone.google.com/_/+1/confirm?hl=en&url='+encodeURIComponent(location.href)+'&title='+encodeURIComponent(document.title),'','width='+w+',height='+h+',left='+x+',top='+y+',scrollbars=no');})();

8 高亮显示选定网页区域

非常酷,值得一试!

1
javascript:function%20LightBox(){this.bindFn=function(c,d,e){if(typeof%20c!="string"||typeof%20d!="function"){return}var%20b=d.bind(this);e=e?true:false;var%20a={type:c,fn:b,userCapture:e};if(Object.prototype.toString.apply(this._fns)!=="[object%20Array]"){this._fns=[]}this._fns.push(a)};this.toBind=function(a){if(this._fns){this._fns.forEach(function(c,b,d){a.addEventListener(c.type,c.fn,c.userCapture)})}};this.init=function(b){var%20f=document.createElementNS("http://www.w3.org/1999/xhtml","div");if(!f){return}var%20e=Math.max(document.documentElement.scrollWidth,document.documentElement.clientWidth);var%20a=Math.max(document.documentElement.scrollHeight,document.documentElement.clientHeight);f.style.cssText="position:%20fixed;%20border:%200px%20solid%20rgba(0,%200,%200,%200.5);%20top:%200;%20right:%200;%20bottom:%200;%20left:%200;%20margin:%200;%20padding:%200;%20z-index:%2099999;%20border-left-width:%20"+e+"px;%20border-top-width:%20"+a+"px;%20";var%20d=document.body||document.documentElement;var%20c=document.createElementNS("http://www.w3.org/1999/xhtml","div");if(c){c.style.cssText="width:%20100%;%20height:%20100%;%20margin:%200;%20padding:%200;%20-moz-box-sizing:%20border-box;%20box-sizing:%20border-box;%20";this._subBox=f.appendChild(c)}this.box=d.appendChild(f);this.width=e;this.height=a;this.later=b;b||this.toBind(f);f.addEventListener("mousedown",this,false);this.rect={x:0,y:0,w:0,h:0}};this.handleEvent=function(g){g.preventDefault();g.stopPropagation();var%20f=g.currentTarget;switch(g.type){case"mousedown":this.x=g.clientX;this.y=g.clientY;f.style.borderLeftWidth=this.x+"px";f.style.borderTopWidth=this.y+"px";f.style.borderRightWidth=this.width-this.x+"px";f.style.borderBottomWidth=this.height-this.y+"px";f.style.width="0px";f.style.height="0px";this._subBox.style.border="none";var%20c=this;this._tid=setTimeout(function(){c._tid=0;f.addEventListener("mousemove",c,false)},100);f.addEventListener("mouseup",this,false);break;case"mousemove":var%20a=g.clientX,i=g.clientY;f.setCapture(true);f.style.borderLeftWidth=Math.min(a,this.x)+"px";f.style.borderTopWidth=Math.min(i,this.y)+"px";f.style.borderRightWidth=this.width-Math.max(a,this.x)+"px";f.style.borderBottomWidth=this.height-Math.max(i,this.y)+"px";f.style.width=Math.abs(a-this.x)+"px";f.style.height=Math.abs(i-this.y)+"px";this._subBox.style.border="1px%20dashed%20rgba(0,%200,%200,%200.6)";break;case"mouseup":if(this._tid){clearTimeout(this._tid);this._tid=0}else{f.removeEventListener("mousemove",this,false);document.releaseCapture();var%20a=parseFloat(f.style.borderLeftWidth),i=parseFloat(f.style.borderTopWidth),b=parseFloat(f.style.width),d=parseFloat(f.style.height);this.rect={x:a,y:i,w:b,h:d};this.later&&this.toBind(f)}f.removeEventListener("mouseup",this,false);break}};this.uninit=function(){if(this.box){this.box.removeEventListener("mousedown",this,false);if(this._fns){this._fns.forEach(function(b,a,c){this.box.removeEventListener(b.type,b.fn,b.userCapture)},this);delete%20this._fns}this.box.parentNode.removeChild(this.box);delete%20this.box;if(this._subBox){delete%20this._subBox}}}}var%20hbox=new%20LightBox();if(typeof%20hbox.temp!="object"){hbox.temp={}}hbox.temp.flag=0;hbox.bindFn("mouseup",function(a){this.temp.flag=0;this.box.removeEventListener("mousedown",this,false);this.box.removeEventListener("mouseup",arguments.callee,false)},false);hbox.temp.reselect=function(a){if(a.keyCode==a.DOM_VK_ESCAPE){++hbox.temp.flag;if(hbox.temp.flag==2){hbox.uninit();window.removeEventListener("keydown",arguments.callee,false)}else{hbox.box.style.borderLeftWidth=hbox.width+"px";hbox.box.style.borderTopWidth=hbox.height+"px";hbox.box.style.width="0px";hbox.box.style.height="0px";hbox.box.addEventListener("mousedown",hbox,false)}}};window.addEventListener("keydown",hbox.temp.reselect,false);hbox.init();void%200;