“Unnesting” Nested Blockquotes Using jQuery (to fit tumblr's September 2015 update)

后端 未结 2 792
不知归路
不知归路 2021-01-22 06:05

I\'m working on a new tumblr theme for a very reblog-heavy blog. Per tumblr\'s latest update to the comment-chains, some posts get very lengthy. While it looks fine on my dashbo

2条回答
  •  生来不讨喜
    2021-01-22 06:43

    There doesn't seem to be an official way to do it. However it is possible to achieve the effect using JS. The following script will flatten the nested blockquotes and also remove the ":" after the blog names and instead prepend them with "- ". Just put it in a new script tag under the body tag.

    $(function() {
        // flatten reblogs
        $("div.cont blockquote").each(function() {
            $(this).parent().prepend($(this).children());
            $(this).remove();
        });
    
        // remove : and add -
        $("div.cont a.tumblr_blog").each(function() {
            var authorPTag = $(this).parent();
            authorPTag.html($(this));
            authorPTag.prepend("- ");
        });
    });
    

    It looks like this on the default theme:

    Note however that this may break the next time Tumblr updates the way reblogs are rendered. It will also not work with endless scrolling.

提交回复
热议问题