標籤

顯示具有 Bookmarklet 標籤的文章。 顯示所有文章
顯示具有 Bookmarklet 標籤的文章。 顯示所有文章

TaiTrain

嗯...不說明...就這樣

Youtube Popup Player

Youtube Popup Player Youtube Popup Player

Firefox如果無法彈出,請設定about:config
browser.link.open_newwindow.restriction
值:整數 (Integer)
新連結開啟於分頁或新視窗

解除禁止選取

javascript: (function () {
    function R(a) {
        ona = "on" + a;
        if (window.addEventListener) window.addEventListener(a, function (e) {
            for (var n = e.originalTarget; n; n = n.parentNode) n[ona] = null;
        }, true);
        window[ona] = null;
        document[ona] = null;
        if (document.body) document.body[ona] = null;
    }

    function userSelect() {
        var css = document.createElement("style");
        css.type = "text/css";
        document.getElementsByTagName("head")[0].appendChild(css);
        css.innerHTML = "*{-moz-user-select:text!important}";
    }
    R("contextmenu");
    R("click");
    R("mousedown");
    R("mouseup");
    R("selectstart");
    userSelect();
})()

Redirect to static HTML (Discuz!)

適用於Discuz!論壇,從動態網頁轉至靜態網頁,AutoPagerize才有作用
javascript:
(function(){
  var tid=/tid=(\d*)/.exec(location.search)[1];
  var page=(/page=(\d*)/.test(location.search)[1])?/page=(\d*)/.exec(location.search)[1]:1;
  location.assign('thread-'+tid+'-'+page+'-1.html');
}
)()

ReSize Imgs (AutoScale)

javascript:
(function(){
  var img=document.getElementsByTagName('img');
  var MaxWidth=window.outerWidth*0.75;
  var MaxHeight=800;
  for(i=0;i<img.length;i++){
    var HeightWidth=img[i].offsetHeight/img[i].offsetWidth;
    var WidthHeight=img[i].offsetWidth/img[i].offsetHeight;
    if(img[i].offsetWidth>MaxWidth){
      img[i].width=MaxWidth;
      img[i].height=MaxWidth*HeightWidth;
    }
    if(img[i].offsetHeight>MaxHeight){
      img[i].height=MaxHeight;
      img[i].width=MaxHeight*WidthHeight;
    }
  }
}
)()

ReSize Imgs (AutoScale)

FDZ Post Img(List)

開啟新頁,並列出文章裡所有外連圖片
點擊圖片即可重新讀取圖片

javascript: (function () {
    var img = document.querySelectorAll("div[id^=postmessage] img"),
        tmp = '';
    for (var i = 0; i < img.length; i++) {
        if (img[i].src.indexOf(location.host) == -1) tmp += '<img onclick=\"this.src=this.src + \'?\'+new Date().getTime();\" style=\"border:1pt solid #000;margin:5px 0;padding:5px\" src=\"' + img[i].src + '\"><br>';
    }
    var n = window.open('', '').document;
    n.open();
    n.write(tmp);
    n.close();
})()

FDZ Post Img(List)
Note:
img.src=img.src+'?'+new Date().getTime(); //強制重新載入圖片,略過cache
強制重新載入圖片 | CFSOHO BLOG

Google字典

在網頁中選取所要查詢的字串,再點擊本Bookmarklet
即可把所選取字串丟至Google字典查詢
P.S.連input、textarea都通吃了

javascript: (function () {
    function getInputText() {
        var it = document.getElementsByTagName('input');
        for (var i = 0; i < it.length; i++) {
            if (it[i].type == 'text') {
                var startPos = it[i].selectionStart;
                var endPos = it[i].selectionEnd;
                if (startPos == endPos) {
                    return 0;
                }
                return it[i].value.substring(startPos, endPos);
            }
        }
        return 0;
    }
    function getTextarea() {
        var ta = document.getElementsByTagName('textarea');
        for (var j = 0; j < ta.length; j++) {
            if (ta[j].selectionStart != ta[j].selectionEnd) return ta[j].value.substring(ta[j].selectionStart, ta[j].selectionEnd);
        }
        return 0;
    }
    var s = document.getSelection();
    if (s.length == 0) s = getInputText();
    if (s == 0) s = getTextarea();
    if (s == 0) s = prompt('Enter a vocabulary.', '');
    if (s.length != 0) window.open('http://www.google.com.tw/dictionary?aq=f&langpair=en|zh-TW&q=' + s + '&hl=zh-TW');
})()

Google字典

使用Bookmarklet開啟新視窗並寫入原始碼

  1. 把所要寫入的原始碼進行Compress HTML
  2. 壓縮後,把HTML屬性的雙引號(")取代成
    \"
  3. 接著,再把javascript裡的換行符號(\n)取代成
    \\n
  4. 補充,javascript裡的反斜線(\)取代成
    \\
  5. 置入here的部份
    var n = window.open("", "").document, c;
    c = "here";
    n.open();
    n.write(c);
    n.close();
  6. 取代完成後,把上述步驟所有程式碼使用Bookmarklet Builder製成Bookmarklet

Note:
  • HTML使用 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
        <head>
            <title></title>
            <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        </head>
        <body>
      
        </body>
    </html>
  • javascript撰寫部份使用單引號
  • 步驟2、3、4皆在處理跳脫字元,可寫成巨集

Google Docs Viewer

網頁中的超連結如有包含.doc、.pdf、.tiff、.ppt、.docx、.pptx、.xls、.xlsx、.svg
將自動上色且點擊後使用Google Docs Viewer開啟
javascript: (function () {
    var link = document.links;
    for (var i = 0; i < link.length; i++) {
        if (/\.(doc|pdf|tiff|ppt|docx|pptx|xls|xlsx|svg)$/i.test(link[i].href)) {
            link[i].href = 'http://docs.google.com/viewer?url=' + encodeURIComponent(link[i].href);
            link[i].target = '_blank';
            link[i].style.backgroundColor = '#00CC00';
            link[i].style.color = '#FFF';
            link[i].style.fontWeight = 'bold';
        }
    }
})()

Google Docs Viewer
範例網頁
RegExp Object可以直接引用
/\.(doc|pdf|tiff|ppt|docx|pptx|xls|xlsx|svg)$/i.test(link[i].href)
View PDFs With Google Docs Viewer Bookmarklet [Update: Greasemonkey Script]
Bookmarklet for "Google Docs Viewer"