2011-11-10 41 views
5

我有幾個博客鏈接到我的Tumblr帳戶,但bookmarklet總是選擇我的「主要」博客(列表中的第一個)。如何修改tumblr小書籤發佈到特定的tumblr博客?

如何修改書籤以便自動選擇特定博客?我想要有多個書籤鏈接,例如「分享到blog1」,「分享到blog2」這樣我就不必手動選擇要創建的帖子裏面博客

默認的tumblr bookmarklet看起來是這樣的:

javascript: var d = document, 
    w = window, 
    e = w.getSelection, 
    k = d.getSelection, 
    x = d.selection, 
    s = (e ? e() : (k) ? k() : (x ? x.createRange().text : 0)), 
    f = 'http://www.tumblr.com/share', 
    l = d.location, 
    e = encodeURIComponent, 
    p = '?v=3&u=' + e(l.href) + '&t=' + e(d.title) + '&s=' + e(s), 
    u = f + p; 
try { 
    if (!/^(.*\.)?tumblr[^.]*$/.test(l.host)) throw (0); 
    tstbklt(); 
} catch (z) { 
    a = function() { 
     if (!w.open(u, 't', 'toolbar=0,resizable=0,status=1,width=450,height=430')) l.href = u; 
    }; 
    if (/Firefox/.test(navigator.userAgent)) setTimeout(a, 0); 
    else a(); 
} 
void(0) 
+1

偉大的問題。很想知道答案。 – jnthnclrk

+0

您是否願意結合使用GreaseMonkey腳本? –

+0

Greasemonkey是否適用於移動瀏覽器? – jnthnclrk

回答

1

提供的書籤一個'channel_id'之後的參數是'example_blog_name'example_blog_name.tumblr.com

javascript: var d = document, 
    w = window, 
    e = w.getSelection, 
    k = d.getSelection, 
    x = d.selection, 
    s = (e ? e() : (k) ? k() : (x ? x.createRange().text : 0)), 
    f = 'http://www.tumblr.com/share', 
    l = d.location, 
    e = encodeURIComponent, 
    c = 'example_blog_name', 
    p = '?v=3&u=' + e(l.href) + '&t=' + e(d.title) + '&s=' + e(s) + '&channel_id=' + e(c), 
    u = f + p; 
+1

我根本無法完成這項工作。 – jnthnclrk

+0

@trnsfrmr錯誤是什麼?您的請求通過的查詢字符串是什麼? 「如果你真的在努力讓它發揮作用,」我根本無法得到這個工作「並不是非常有建設性。 – KyleWpppd

+0

我收到請求被拒絕,請參閱圖片:http://imgur.com/TgwtD。 @KyleWppd,它適合你嗎? – jnthnclrk

1

使用用戶腳本的組合,和一個小調整到書籤,這裏是你的解決方案:

安裝此作爲UserScript

var selectOption = function (elem, value) { 
    var options = elem.options; 
    for(var i = 0; i < options.length; i++){ 
     if(options[i].innerHTML === value){ 
      elem.selectedIndex = i; 
     } 
    } 
}; 

window.onload = function(){ 
    if(location.href.indexOf('tumblr.com/share') !== -1){ 
     selectOption(document.getElementById('channel_id'), location.hash.slice(1)); 
    } 
}; 

保存爲編輯BLOG_NAME變量後您的書籤。完全按照下拉菜單中的方式輸入。另外,你可能需要通過UglifyJS來運行它,使它成爲一個小書籤。

javascript: var BLOG_NAME = 'Test', 
    d = document, 
    w = window, 
    e = w.getSelection, 
    k = d.getSelection, 
    x = d.selection, 
    s = (e ? e() : (k) ? k() : (x ? x.createRange().text : 0)), 
    f = 'http://www.tumblr.com/share', 
    l = d.location, 
    e = encodeURIComponent, 
    p = '?v=3&u=' + e(l.href) + '&t=' + e(d.title) + '&s=' + e(s), 
    u = f + p; 
try { 
    if (!/^(.*\.)?tumblr[^.]*$/.test(l.host)) throw (0); 
    tstbklt(); 
} catch (z) { 
    a = function() { 
     if (!w.open(u + '#' + BLOG_NAME, 't', 'toolbar=0,resizable=0,status=1,width=450,height=430')) l.href = u; 
    }; 
    if (/Firefox/.test(navigator.userAgent)) setTimeout(a, 0); 
    else a(); 
} 
void(0);