2011-11-10 16 views
5

Ho un paio di blog collegati al mio account Tumblr, ma il bookmarklet seleziona sempre il mio blog "primario" (il primo della lista).Come posso modificare il bookmarklet tumblr per postare su un blog tumblr specifico?

Come posso modificare il bookmarklet in modo che selezioni automaticamente un blog specifico? Mi piacerebbe avere più collegamenti bookmarklet, ad es. . "Condividi su blog1", "Condividi su blog2" in modo che io non devo selezionare manualmente i blog per creare il post in

predefinito Tumblr bookmarklet assomiglia a questo:

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

Ottima domanda. Mi piacerebbe sapere la risposta. – jnthnclrk

+0

Sareste aperti all'utilizzo di script GreaseMonkey in congiunzione? –

+0

Greasemonkey funziona sui browser mobili? – jnthnclrk

risposta

1

Dare il bookmarklet un parametro 'channel_id' messaggio che è 'example_blog_name' in 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

Non riuscivo a farlo funzionare. – jnthnclrk

+0

@trnsfrmr Qual è stato l'errore? Qual è stata la stringa di query che hai superato con la tua richiesta? "Non riuscivo a farlo funzionare per niente" non è molto costruttivo se in realtà stai provando, in realtà, a farlo funzionare. – KyleWpppd

+0

Ricevo la richiesta negata, vedere la foto: http://imgur.com/TgwtD. @KyleWppd, funziona per te? – jnthnclrk

1

Usando una combinazione di uno script utente, e un piccolo ritocco per il bookmarklet, ecco la soluzione:

01.235.

Installare questo come un 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)); 
    } 
}; 

Salva questo come bookmarklet dopo la modifica della variabile BLOG_NAME. Digitarlo esattamente come nel menu a discesa. Inoltre, probabilmente dovrai eseguirlo tramite UglifyJS per trasformarlo in un bookmarklet.

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); 
Problemi correlati