Widget Top Nhận Xét Nhiều Nhất Trong Tuần Cho Blogspot

Widget Top Comments, Top Nhận Xét, Blogspot, Top Week Comment, Widget Top Nhận Xét Nhiều Nhất Trong Tuần Cho Blogspot. Hôm nay mình vừa thi xong được vài môn, rãnh nên đăng bài thôi. Thì mình muốn chia sẻ cho mọi người một Widget của Blogspot. Giúp hiện thị những người nhận xét nhiều nhất của Blogspot. Để khỏi vòng vo thì mình vô thẳng vấn đề luôn.

Widget Top Comments, Top Nhận Xét, Blogspot, Top Week Comment, Widget Top Nhận Xét Nhiều Nhất Trong Tuần Cho Blogspot

Các bước hướng dẫn


Truy cập vào Blogspot rồi edit Template sau đó tìm thẻ <b:section> và đặt đoạn code sau vào trong <b:section> nhé.

<b:widget id='HTML2' locked='false' title='Nhận Xét Nhiều Nhất Trong Tuần' type='HTML' version='2' visible='true'>
<b:widget-settings>
<b:widget-setting name='content'/>
</b:widget-settings>
<b:includable id='main'>
<div class='widget-content'>
<b:if cond='data:title != &quot;&quot;'><h2><data:title/></h2></b:if>
<div id='tc'><ul>
<li><div class='item-thumbnail st'/><div class='clear'/></li>
<li><div class='item-thumbnail nd'/><div class='clear'/></li>
<li><div class='item-thumbnail rd'/><div class='clear'/></li>
<li><div class='item-thumbnail rd'/><div class='clear'/></li>
</ul></div>
</div>
<style>
#tc .item-thumbnail{float:left;margin-right:10px;border-radius:5px;width:36px;height:36px}
#tc .item-info{line-height: 1.2;float:left;width:200px;overflow:hidden;word-wrap:break-word}
#tc .item-info .item-name{font-weight: 500;font-size: 15px}
#tc .item-info .gray{font-size: 11px}
#tc .avatar{border-radius: 100%;margin:3px;width:30px;height:30px}
#tc li{border-top: 1px solid #f5f5f5;padding: 10px 0px}
#tc li:first-child{padding-top: 0px;}
#tc li:last-child{padding-bottom: 6px;}
.st,.nd,.rd{border-radius:50%!important}
.st{background:#dd6}
.nd{background:#ccc}
.rd{background:#d66}
</style>
</b:includable>
</b:widget>

Sau đó thêm đoạn Script sau lên trên thẻ đóng </body>
<script>
//<![CDATA[
//top comment
var lang_com = 'Nhận xét';
lang_coms = 'Nhận xét';
lang_ano = 'Anonymous';
pid = [];
tcapid = 'pid-888757957';
hr = document.getElementById('tc');
ntc = 4;
sa = '40';
noa = 'https://img1.blogblog.com/img/blank.gif';
ba = 'https://img1.blogblog.com/img/b16-rounded.gif';
noar = 'https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiGLqSinOFM1YkH58wB5_z9ndWY1AeVk5g1ZrOJUjunhUh2OLqGRsqx4yVsBBReraK6JLjzpSE08oiGaBOulbpZ3gYGNqJ1wZTeeBe_qD3reqxYg-QwgefpWZXSXxFw0xITo8VEt0dzNsOs/s/' + sa;
bar = 'https://lh3.googleusercontent.com/zFdxGE77vvD2w5xHy6jkVuElKv-U9_9qLkRYK8OnbDeJPtjSZ82UPq5w6hJ-SA=s' + sa;
rsa = '/s' + sa + '$1/';
rcpid = [];
rcn = [];
rca = [];
rcuri = [];
topn = 0;
tcpid = [];
tcpidhv = '';
tcn = [];
tcnhv = '';
tca = [];
tcahv = '';
uri = [];
urihv = '';
tccn = [];
tccnhv = 0;
function tc(gf) {
    var tcgm = 0;
    if (gf.feed.entry != undefined) {
        tcgm = gf.feed.entry.length;
        for (var i = 0; i < tcgm; i++) {
            var c = gf.feed.entry[i];
            rcpid[i] = c['gd$extendedProperty'][0].value;
            if (c.author[0].name.$t == 'Unknown') {
                rcn[i] = lang_ano
            } else {
                rcn[i] = c.author[0].name.$t.replace(/"/g, '&quot;')
            }
            if (c.author[0].gd$image.src == noa) {
                rca[i] = noar
            } else if (c.author[0].gd$image.src == ba) {
                rca[i] = bar
            } else {
                rca[i] = c.author[0].gd$image.src
            }
            if ('uri' in c.author[0]) {
                rcuri[i] = c.author[0].uri.$t
            } else {
                rcuri[i] = ''
            }
        }
        for (var i = 0; i < tcgm; i++) {
            if (i == 0) {
                tcpid[0] = rcpid[0];
                tcn[0] = rcn[0];
                tca[0] = rca[0];
                uri[0] = rcuri[0];
                tccn[0] = 1;
                topn = 1
            } else {
                for (var j = 0; j < topn; j++) {
                    if (rcpid[i] == tcpid[j]) {
                        tccn[j]++;
                        break
                    }
                }
                if (j >= topn) {
                    tcpid[topn] = rcpid[i];
                    tcn[topn] = rcn[i];
                    tca[topn] = rca[i];
                    uri[topn] = rcuri[i];
                    tccn[topn] = 1;
                    topn++
                }
            }
        }
        for (i = 0; i < topn; i++) {
            if ((tcpid[i] == tcapid) || (tcpid[i] == 'true')) {
                tccn[i] = 0
            }
        }
        for (i = 0; i < topn - 1; i++) {
            for (j = i + 1; j < topn; j++) {
                if (tccn[i] < tccn[j]) {
                    tcpidhv = tcpid[i];
                    tcpid[i] = tcpid[j];
                    tcpid[j] = tcpidhv;
                    tccnhv = tccn[i];
                    tccn[i] = tccn[j];
                    tccn[j] = tccnhv;
                    tcnhv = tcn[i];
                    tcn[i] = tcn[j];
                    tcn[j] = tcnhv;
                    tcahv = tca[i];
                    tca[i] = tca[j];
                    tca[j] = tcahv;
                    urihv = uri[i];
                    uri[i] = uri[j];
                    uri[j] = urihv
                }
            }
        }
        var dw = '';
        dw += '<ul>';
        i2 = 0;
        for (var i = 0;
            (i < ntc) && (i < topn); i++) {
            if (tccn[i] != 0) {
                var i2 = i2 + 1;
                tcol = [];
                tca[i] = tca[i].replace(/\/s[0-9]+(-*c*)\//, rsa);
                if (i == 0) {
                    tcol[i] = 'st'
                } else {
                    if (i == 1) {
                        tcol[i] = 'nd'
                    } else {
                        tcol[i] = 'rd'
                    }
                }
                dw += '<li';
                if (i == 0) {
                    dw += ' style="border-top:0"'
                }
                dw += '><div class="item-thumbnail ' + tcol[i] + '"><img alt="" class="avatar" src="' + tca[i] + '"/></div><div class="item-info"><div class="item-name">';
                if (uri[i] != '') {
                    dw += '<a href="' + uri[i] + '" rel="nofollow">' + tcn[i] + '</a>'
                } else {
                    dw += tcn[i]
                }
                dw += '</div><span class="gray">' + tccn[i] + ' ';
                if (tccn[i] == 1) {
                    dw += lang_com
                } else {
                    dw += lang_coms
                }
                dw += '</span></div><div class="clear"></div></li>'
            }
        }
        if (i2 != 0) {
            for (var i = i2; i < ntc; i++) {
                if (i == 1) {
                    tcol[i] = 'nd'
                } else {
                    tcol[i] = 'rd'
                }
                dw += '<li><div class="item-thumbnail ' + tcol[i] + '"></div><div class="clear"></div></li>'
            }
            dw += '</ul>';
            if (hr) {
                hr.innerHTML = dw
            }
        }
    }
}
var nc = 5;
tt = 0;
y = 0;
z = 0;
jl = 35;
ale = 30;
lk = [];
lk2 = [];
var urlPost;
var comID;
d = [];
p = [];
j2 = [];
tb = [];
a = [];
im = [];
pa = [];
pi = [];
function rc3(s) {
    var x = s.feed.author[0];
    if (x.name.$t == 'Unknown') {
        pa[y] = lang_ano
    } else {
        pa[y] = x.name.$t.replace(/"/g, '&quot;')
    }
    if (x.gd$image.src == noa) {
        pi[y] = noar
    } else {
        pi[y] = x.gd$image.src.replace(/\/s[0-9]+(-*c*)\//, rsa)
    }
    y++
}
function rc1(q) {
    var tcdate = q.feed.updated.$t;
    tt = q.feed.openSearch$totalResults.$t;
    tb = q.feed.title.$t;
    bid = q.feed.id.$t;
    bid = bid.substring(26, 45);
    tcmaxy = parseInt(tcdate.substring(0, 4));
    tcmaxm = parseInt(tcdate.substring(5, 7), 10);
    tcmaxd = parseInt(tcdate.substring(8, 10), 10);
    tctime = tcdate.substring(10, 19);
    tcgmt = encodeURIComponent(tcdate.substring(23, tcdate.length));
    if (tcmaxm == 1) {
        if (7 < tcmaxd) {
            tcminy = tcmaxy;
            tcminm = 1;
            tcmind = tcmaxd - 7
        } else {
            tcminy = tcmaxy - 1;
            tcminm = 12;
            tcmind = 24 + tcmaxd
        }
    } else {
        tcminy = tcmaxy;
        if (7 < tcmaxd) {
            tcminm = tcmaxm;
            tcmind = tcmaxd - 7
        } else {
            tcminm = tcmaxm - 1;
            if ((tcmaxm == 3) || (tcmaxm == 5) || (tcmaxm == 7) || (tcmaxm == 8) || (tcmaxm == 10) || (tcmaxm == 12)) {
                tcmind = 24 + tcmaxd
            } else {
                if (tcmaxm == 2) {
                    if ((tcminy % 400 == 0) || ((tcminy % 4 == 0) && (tcminy % 100 != 0))) {
                        tcmind = 22 + tcmaxd
                    } else {
                        tcmind = 21 + tcmaxd
                    }
                } else {
                    tcmind = 23 + tcmaxd
                }
            }
        }
    }
    tcminy += '';
    if (tcminm < 10) {
        tcminm = '0' + tcminm
    } else {
        tcminm += ''
    }
    if (tcmind < 10) {
        tcmind = '0' + tcmind
    } else {
        tcmind += ''
    }
    if (hr) {
        document.write('<script src="/feeds/comments/summary?alt=json-in-script&updated-min=' + tcminy + '-' + tcminm + '-' + tcmind + tctime + tcgmt + '&max-results=200&callback=tc"><\/script>')
    }
    for (var g = 0;
        (g < nc) && (g < tt); g++) {
        c = q.feed.entry[g];
        if (g == q.feed.entry.length) {
            break
        }
        lk = c.link[0].href;
        lk = lk.split('/');
        pid[g] = lk[5];
        cid = lk[8];
        lk2[g] = '';
        for (var h = 0; h < c.link.length; h++) {
            if (c.link[h].rel == 'related') {
                lk2[g] = c.link[h].href;
                lk2[g] = lk2[g].split('/');
                lk2[g] = lk2[g][8]
            }
        }
        if (lk2[g] != '') {
            document.write('<script src="/feeds/' + bid + '/' + pid[g] + '/comments/summary/' + lk2[g] + '?alt=json-in-script&callback=rc3"><\/script>')
        }
        var d2 = c['thr$in-reply-to'].href.split('/');
        d[g] = '/' + d2[3] + '/' + d2[4] + '/' + d2[5];
        p[g] = cid;
        var j = c.summary.$t.replace(/<.*?>/g, '');
        if (j.length < jl) {
            if (j.length == 0) {
                j = '&hellip;'
            }
            j2[g] = j
        } else {
            j2[g] = j.substring(0, jl) + '&hellip;'
        }
        if (c.author[0].name.$t == 'Unknown') {
            a[g] = lang_ano
        } else {
            a2 = c.author[0].name.$t;
            if (a2.length < ale) {
                a[g] = a2
            } else {
                a[g] = a2.substring(0, ale) + '&hellip;'
            }
            a[g] = a[g].replace(/"/g, '&quot;')
        }
        if (c.author[0].gd$image.src == noa) {
            im[g] = noar
        } else if (c.author[0].gd$image.src == ba) {
            im[g] = bar
        } else {
            im[g] = c.author[0].gd$image.src.replace(/\/s[0-9]+(-*c*)\//, rsa)
        }
    }
}
document.write('<script src="/feeds/comments/summary?alt=json-in-script&max-results=' + nc + '&callback=rc1"><\/script>');
//]]>
</script>

Trong đoạn Script có dòng
tcapid = 'pid-888757957';

Để lấy được pid-888757957 của Blogspot thì làm như sau nhé. Nhấn F12 rồi làm như hình dưới.

Widget Top Comments, Top Nhận Xét, Blogspot, Top Week Comment, Widget Top Nhận Xét Nhiều Nhất Trong Tuần Cho Blogspot

Lời kết


Chúc các bạn một ngày vui vẻ nhé.

...
  • Do thiếu hụt kinh phí nên chúng tôi buộc phải chạy quảng cáo để duy trì website. Chúng tôi rất xin lỗi về sự bất tiện này! !
  • Mọi thứ trên website đều là miễn phí.Được Leech Từ Nhiều Nguồn , Nếu Có Vấn Đề Bản Quyền Hãy Liên Hệ Với Chúng Tôi!
  • Tuyệt đối không click spam (click tặc quảng cáo). Hãy là một người sử dụng internet thông minh và có văn hóa! Xin cảm ơn.
CÓ THỂ BẠN ĐANG TÌM