Bookmarklet

Bookmarklet 我不曉得該怎麼翻譯,它是一種書籤,但肯定不叫做「我的最愛」。叫做我的最愛很奇怪,也許我只想將網站資訊蒐集起來,但不見得這個網站是我喜愛的。

Bookmarklet 是在書籤上套用 javascript 的功能,讓瀏覽器可以運用 javascript 來執行一些動作。幾乎是javascript 可以作得到的,就能製作成 Bookmarklet。Bookmarklet 提供這些功能,我們只要按下去,很自動的處理好常用的網頁功能。它可以在 Safari 及 Firefox 上使用,但我不曉得 ie 能不能作用?

只要將 javascript 的語法貼進去書籤中的「網址」上,使用方法如同點書籤的動作一樣,完全不需要什麼特別的方式。

例如我新增一個書籤,名稱自由取名,網址的部份輸入底下的語法:
javascript:var%20t=((window.getSelection&&window.getSelection())||(document.getSelection&&document.getSelection())||(document.selection%20&&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=zh-TW&langpair=en|zh-CN&tbb=1&ie='+e;}else{location.href='http://translate.google.com/translate?u='+escape(location.href)+'&hl=zh-TW&langpair=en|zh-CN&tbb=1&ie='+e;};
當我瀏覽英文網頁時,然後點一下這個 Bookmarklet,便會開始執行動作,利用 Google 的翻譯功能將原本的英文內容翻譯成中文。

這個 Bookmarklet 則是將目前瀏覽的網頁加入到 Google Bookmark 書籤去,你不需要另外剪貼網址,也不需要額外開啟 Google Bookmark 網頁,一次搞定。
javascript:location.href='http://www.google.com/bookmarks/mark?op=add&bkmk='+encodeURIComponent(location.href)+'&title='+encodeURIComponent(document.title)

其他像是列出網頁中的圖檔:
javascript:(function(d){function%20f(p,i,c,t,u,r,e,s){r=i.location.href;if(typeof%20r=='string'){t=i.document.images;u=t.length;e='URL:%20%3Ca%20href='+r+'%3E'+r+'%3C/a%3E%3Cbr%3E%3Cbr%3Eimages:%20'+u;for(c=0;c%3Cu;c++){s=t[c];r=s.src;e+=’%3Cbr%3E%3Cbr%3E’+c+’:%3Cbr%3E%3Cimg%20src=’+r+’%3E%3Cbr%3E%3Ca%20href=’+r+’%3E’+r+’%3C/a%3E%3Cbr%3E’+s.width+’x'+s.height}}else{e=’undefined%3Cbr%3E’}d.write(e+’%3Cbr%3E’);t=i.frames;u=t.length;if(u%3E0){for(c=0;c%3Cu;c++){d.write(’%3Chr%3E%3Ch4%3Elevel%20′+p+’,%20frames['+c+']%3C/h4%3E’);f(p+1,t[c])}}};d.write(’%3Ch4%3Etop%3C/h4%3E’);f(0,top)})(open().document)

還有直接取得下載 YouTube 上的 flv 影片:
javascript:(function(){window.open('http://kej.tw/flvretriever/bookmarklet.php?videoUrl='+encodeURIComponent(location.href)+'&autostart=yes','gootube',%20'toolbar=0,%20%20location=0,%20%20directories=0,%20%20status=0,%20%20menubar=0,%20%20scrollbars=0,%20%20resizable=1,%20%20width=650,%20%20height=320')})();

都只需要建立好 Bookmarklet 書籤按鈕,點一下即可。有非常多的應用,你可以搜尋 Bookmarklet 這個關鍵字找找看。


No Responses to “Bookmarklet”  

  1. No Comments

Leave a Reply