Greasy Fork

来自缓存

Greasy Fork is available in English.

获取淘宝评论图片

Get TAOBAO 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      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});});});
	}
})();