获取淘宝评论图片

Get TAOBAO Comment Pic

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         获取淘宝评论图片
// @namespace    https://greasyfork.org/zh-CN/scripts/22386
// @version      20170820
// @description  Get TAOBAO Comment Pic
// @author       sbdx
// @match        https://item.taobao.com/item.htm?*
// @grant        none
// @require      http://cdn.bootcss.com/jquery/1.8.3/jquery.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='div.tb-revbd';
	itemid=g_config.itemId;
	sellerid=g_config.sellerId;

	function getJSON()
	{
		$('#J_IdsSegments').css('z-index',100);//降低右侧div的层级
		
		url="https://rate.taobao.com/feedRateList.htm?auctionNumId=" + itemid + "&userNumId=" + sellerid + "&currentPageNum=" + page + "&rateType=3&orderType=sort_weight&attribute=&sku=&hasSku=false&folded=0&_ksTS="+(new Date().getTime()) + "&callback=?";
		$.getJSON(url,function(d){
			if(page==1) PageTotal=d.maxPage;
			ProcessJSON(d);
			page++;
			if(page<=Math.min(10,PageTotal))getJSON();//最多取10页数据
		});

	}
	function ProcessJSON(d)
	{
		var ImgList=[];
		$.each(d.comments,function(i,v){
			img='';
			if(v.photos)
			{
				$.each(v.photos,function(pi,pv){
					img+="<img src='" + pv.url.replace('_400x400.jpg','') + "' /><br><br>\r\n";
				});
			}
			if(v.appendList.photos)
			{
				$.each(v.appendList.photos,function(pi,pv){
					img+="<img src='" + pv.url.replace('_400x400.jpg','') + "' /><br><br>\r\n";
				});
			}
			ImgList.push(img);
		});
		//$('.detail-eval.J_DetailEval').append('<div>第' + page + '页</div>'+ImgList.join(''));
		$(targetElement).append('<div>第' + page + '页</div>'+ImgList.join(''));
	}
	if($)
	{
		$("body").append("<div id='sbdx_tools_getAllImage' style='position:absolute;right:10px;top:100px;z-index:200000020'><button>显示评论全部图片</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});});});
	}
})();