Greasy Fork

Greasy Fork is available in English.

获取天猫评论图片

Get TMALL Comment Pic

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         获取天猫评论图片
// @namespace    http://greasyfork.icu/zh-CN/scripts/22386
// @version      20170429
// @description  Get TMALL Comment Pic
// @author       sbdx
// @match        detail.tmall.com/item.htm?*
// @grant        none
// @require      https://code.jquery.com/jquery-1.9.1.min.js
// ==/UserScript==
/*
Target URL: https://item.taobao.com/item.htm?id=528857970664
*/
(function() {
    //   'use strict';
    var page=1;
    var url,PageTotal;
    var itemid,sellerid;
    var targetElement='#mainwrap';
    itemid=g_config.itemId;
    sellerid=g_config.sellerId;

    function getJSON()
    {
        //$('#J_IdsSegments').css('z-index',100);//降低右侧div的层级
        url="https://rate.tmall.com/list_detail_rate.htm?itemId=" + itemid + "&sellerId=" + sellerid + "&order=3&content=1&currentPage=" + page + "&picture=1&_ksTS="+(new Date().getTime()) + "&callback=?";
        $.getJSON(url,function(d){
            if(page==1) PageTotal=d.rateDetail.paginator.lastPage;//获取总页数
            ProcessJSON(d);
            page++;
            if(page<=Math.min(10,PageTotal))getJSON();//最多取10页数据
        });

    }
    function ProcessJSON(d)
    {
        var ImgList=[];
        $.each(d.rateDetail.rateList,function(i,v){
            img='';
            if(v.pics)
            {
                $.each(v.pics,function(pi,pv){
                    img+="<img src='" + pv.replace('_400x400.jpg','') + "' /><br><br>\r\n";
                });
            }
            if(v.appendComment.pics)
            {
                $.each(v.appendComment.pics,function(pi,pv){
                    img+="<img src='" + pv.replace('_400x400.jpg','') + "' /><br><br>\r\n";
                });
            }
            ImgList.push(img);
        });
        append='<div>第' + page + '页</div>'+ImgList.join('');
        console.log(append);
        $(targetElement).append(append);
        
    }
    if(jQuery)
    {
        $("body").append("<div id='sbdx_tools_getAllImage' style='position:absolute;right:10px;top:100px;z-index:200000020'><button>显示天猫<br>评论图片</button></div>");$("#sbdx_tools_getAllImage").on("click",function(){page=1;$(targetElement).html('');getJSON();});
        $(window).scroll(function(){$("div[id^=sbdx]").each(function(i){$(this).offset({top:$(document).scrollTop()+100+i*30});});});
    }
    else
    {
        alert('Tampermonkey 加载jquery.js 失败!脚本终止运行!');
    }
})();