我有几个博客链接到我的Tumblr帐户,但bookmarklet总是选择我的“主要”博客(列表中的第一个)。
如何修改书签以便自动选择特定博客?我想有多个bookmarklet链接,例如“分享到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)
答案 0 :(得分: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 :(得分: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);