// ==UserScript== // @name 京东秒杀价格过滤 // @version 0.2.1 // @icon https://www.jd.com/favicon.ico // @description 按价格过滤并排序(价格升序)秒杀商品列表 // @author You! // @grant GM_setValue // @grant GM_getValue // @match *://miaosha.jd.com/category.html?cate_id=* // @run-at document-end // @namespace http://tampermonkey.net/ // @downloadURL none // ==/UserScript== (function() { var uiInit = function(){ clearInterval(priceUI); var uiPos = $('#sk_mod_er'); if (uiPos.length > 0) { uiPos.append($( '
'+ '过滤价格:刷新
'+ '
'+ '
'+ '
' )); $('#fltReload').first().click(function(){ priceMin = getFloat($('#fltPriceMin').first().val()); priceMax = getFloat($('#fltPriceMax').first().val()); setTimeout(function() { GM_setValue("jd_miaosha_price_min", priceMin); GM_setValue("jd_miaosha_price_max", priceMax); }, 0); }); } else priceUI = setInterval(uiInit, 1000); }; var doFilter = function(){ clearInterval(priceFilter); var count = 0; //count += filterGoods($('div.skwrap')); //正在抢购 //count += filterGoods($('div.moregoods')); //更多好货 count += filterGoods($('div.catinfo_seckillnow')); //当天正在秒杀的商品 count += filterGoods($('div.catinfo_startsoon')); //明日秒杀的商品 if (count === 0) priceFilter = setInterval(doFilter, 1000); }; var filterGoods = function(goodsList) { var goods = goodsList.find('li.seckill_mod_goods'); if (goods.length > 0) { var niceGoods = []; goods.each(function(idx){ //按商品名过滤 if ('undefined' !== typeof(filterPName) && filterPName !== null) { var pname = getProductName(this); if (!filterPName(pname)) return; } //按价格过滤 var price = getPrice(this); if (price < priceMin || priceMax < price) return; //命中 niceGoods.push(this); }); //排序 if (niceGoods.length > 0) { niceGoods.sort(function(g1, g2){ return getPrice(g1) - getPrice(g2); //<-------------------------------------------------如果要降序,修改这里 }); //取消延迟加载 var lazyImgs = $(niceGoods).find('img[data-lazy-img!="done"]'); if (lazyImgs.length > 0) lazyImgs.each(function(idx){ var img = $(this); this.src = img.attr('data-lazy-img'); img.attr('data-lazy-img', 'done'); }); } else niceGoods = $('


该分类下所有商品的价格都不符合过滤条件。