반응형


    댓글 작성자의 아이콘을 불러오는 스크립트입니다.


    티스토리에서는 대표이미지를 불러오는 치환자조차 제공하지 않고있기때문에 블로거의 아이콘 불러오는 치환자 역시 있을리가 없습니다.


    이 스크립트는 해당글 주소에서 댓글 작성자의 프로필 이미지를 추출해 최근 댓글 사이드바에 뿌려줍니다.


    ajax요청을 최소화하기위해 첫번째 링크부터 모든 댓글작성자의 아이콘을 추출하며 두번째부터는 목록에 댓글작성자가 없는경우에만 다음 ajax요청을 수행합니다.


    MaterialT mark3에서 바로 사용할 수 있습니다.


    .


    적용하기

    여타 스크립트와 마찬가지로 </body>위에 붙여넣으면 됩니다.

    <script>

    /*

    getCommentorIcon by 뭐하라(http://nubiz.tistory.com/615)

    */

    var recentComments=$("#recentComments li a");var commentors={};function getCommentorIcon(){var f,b,d,c,a;f=$(recentComments).parent().children("a:not('.iconGot')").first();if(f.length===0){return false}b=$(f).attr("href");d=$(f).find(".name").text().trim();if(commentors[d]){a=commentors[d];$(f).find("[alt='thumbnail']").attr("src",a);$(f).addClass("iconGot")}if(!a){$.ajax({url:b,success:function(e){c=$(e);$(c).find(".name a").each(function(g,h){commentors[$(h).text().trim()]=$(h).parent().find("[alt='BlogIcon']").attr("src")});a=commentors[d];$(f).find("[alt='thumbnail']").attr("src",a);$(f).addClass("iconGot");getCommentorIcon()},error:function(){$(f).addClass("iconGot");getCommentorIcon()}})}else{getCommentorIcon()}}getCommentorIcon();

    </script>


    이 스크립트 역시 주석을 첨가한 소스코드를 공개하니 수정하실분들은 수정해서 사용하시면됩니다.


    반응형
    Posted by 뭐하라

    문제가 있나요?(?)

    내용상 오류가 있음 업데이트 필요 화면이 깨짐 기타 수정이 필요함