我怎样才能修改tumblr上的书签让它发布到一个特定的tumblr博客上呢?

时间:2022-01-09 08:18:50

I have a couple blogs linked to my Tumblr account, but the bookmarklet always selects my "primary" blog (the first one in the list).

我有几个博客链接到我的Tumblr账号,但是bookmarklet总是选择我的“主要”博客(列表中的第一个)。

How can I modify the bookmarklet so that it will auto-select a specific blog? I would like to have multiple bookmarklet links, e.g. "Share on blog1", "Share on blog2" so that I don't have to manually select which blog to create the post in.

如何修改bookmarklet,让它自动选择一个特定的博客?我想要有多个书签链接。“分享blog1”,“分享blog2”,这样我就不用手动选择哪个博客来创建帖子了。

Default Tumblr bookmarklet looks like this:

默认的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)

2 个解决方案

#1


1  

Give the bookmarklet a 'channel_id' post parameter which is 'example_blog_name' in example_blog_name.tumblr.com

给bookmarklet一个“channel_id”post参数,该参数是example_blog_name.tumblr。

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;

#2


1  

Using a combination of a user script, and a little tweaking to the bookmarklet, here's your solution:

使用用户脚本的组合,稍微调整一下书签,下面是您的解决方案:

Install this as a UserScript:

将其安装为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));
    }
};

Save this as your bookmarklet after editing the BLOG_NAME variable. Type it exactly as it is in the dropdown. Also, you'll probably have to run it through UglifyJS to make it a bookmarklet.

在编辑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);

#1


1  

Give the bookmarklet a 'channel_id' post parameter which is 'example_blog_name' in example_blog_name.tumblr.com

给bookmarklet一个“channel_id”post参数,该参数是example_blog_name.tumblr。

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;

#2


1  

Using a combination of a user script, and a little tweaking to the bookmarklet, here's your solution:

使用用户脚本的组合,稍微调整一下书签,下面是您的解决方案:

Install this as a UserScript:

将其安装为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));
    }
};

Save this as your bookmarklet after editing the BLOG_NAME variable. Type it exactly as it is in the dropdown. Also, you'll probably have to run it through UglifyJS to make it a bookmarklet.

在编辑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);