! 超简洁的网购省钱小助手,自动显示京东、淘宝、聚划算、天猫隐藏优惠券与历史价格。简洁无广告,一目了然,让您告别虚假降价。持续维护中...

或许是最简洁好用的购物小助手啦~ 自动显示京东(jd.com)、淘宝(taobao.com)、天猫(tmall.com)、聚划算、天猫超市、天猫国际(tmall.hk)、京东国际(jd.hk)、京东图书、京东大药房(yiyaojd.com)隐藏优惠券与历史价格。不止让您省钱开心购物,更可以告别虚假降价,以最优惠的价格,把宝贝抱回家。

// ==UserScript==
// @name              ! 超简洁的网购省钱小助手,自动显示京东、淘宝、聚划算、天猫隐藏优惠券与历史价格。简洁无广告,一目了然,让您告别虚假降价。持续维护中...
// @name:zh           ! 超简洁的网购省钱小助手,自动显示京东、淘宝、聚划算、天猫隐藏优惠券与历史价格。简洁无广告,一目了然,让您告别虚假降价。持续维护中...
// @name:zh-TW        ! 超簡潔的網購省錢小助手,自動顯示京東、淘寶、聚劃算、天貓隱藏優惠券與歷史價格。簡潔無廣告,一目了然,讓您告別虛假降價。持續維護中...
// @namespace         http://shop.xuelg.com
// @version           2.0.5
// @description       或许是最简洁好用的购物小助手啦~ 自动显示京东(jd.com)、淘宝(taobao.com)、天猫(tmall.com)、聚划算、天猫超市、天猫国际(tmall.hk)、京东国际(jd.hk)、京东图书、京东大药房(yiyaojd.com)隐藏优惠券与历史价格。不止让您省钱开心购物,更可以告别虚假降价,以最优惠的价格,把宝贝抱回家。
// @description:zh    或許是最簡潔好用的購物小助手啦~ 自動顯示京東(jd.com)、淘寶(taobao.com)、天貓(tmall.com)、聚劃算、天貓超市、天貓國際(tmall.hk)、京東國際(jd.hk)、京東圖書、京東大藥房(yiyaojd.com)隱藏優惠券與歷史價格。不止讓您省錢開心購物,更可以告別虛假降價,以最優惠的價格,把寶貝抱回家。
// @description:zh-TW 或許是最簡潔好用的購物小助手啦~ 自動顯示京東(jd.com)、淘寶(taobao.com)、天貓(tmall.com)、聚劃算、天貓超市、天貓國際(tmall.hk)、京東國際(jd.hk)、京東圖書、京東大藥房(yiyaojd.com)隱藏優惠券與歷史價格。不止讓您省錢開心購物,更可以告別虛假降價,以最優惠的價格,把寶貝抱回家。
// @author            血莲
// @icon              data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADgAAAA4CAMAAACfWMssAAAAhFBMVEVHcEwDAgL68vLz5uWeBAXv5eT16unv4+Pr3t57Cg2XBQaOBQd/BAZqBAbs3961q6tuaGhHQUImIyTj0tEXERJhW1xUT08MCgodGxuWjo47Njd9dnaHgYExLS6gmJjfv7y/trWqoaGhFhePMDDOxMTIeXnVnpx2IiK2SUqrJylIDQ2ZYmHjbvk7AAAACnRSTlMA////////YWFjn3/5VwAABvVJREFUSMdlV4eWo7oSNCbsXoIiEkJCZBuH//+/VxKesOdpOPaMTdHVqbrnconnT5rneZrmKckTnC6JpxNcK+a0xMcpibeQ/M/l55yYeJHEJN+nM5Yz1vc9JyR+TcJV5F84fJafVy4T8YNLWgCVcsNC552EG9J4a5r+n72eudH9cG29ZpqxoQdw3wOm+Nx44vITl5ORMsVa680H2Bntxr7HNdNgtPi6NSLPhxSgr7j1nHvRnuaSRHvuRjrTZXZ4pbvM89OjHGT/pqfJPFfOWyUSY7pOn0CvlBpGCmuzCzapTL9s/o0ekvCQnfLWeABe79vBug5AoYKDYzBG2TwiRuREFojPx3pBKPe4t348s6y8v50AY6GcG4ZlAYIOfoSvNNoIiAs5Yem89/Yoq6zMAFwbxy0SynrXD2NPh3FeBgfjwx4DgutyJjW/HVUdIFk8VXo4bU3HKVXjOLJhmBfmUAtsJGcG0ksR3m5V+YUJ6KmumoFpK8RIOVwbnKJUM8Up63cQDSxDcLaqqqsPrnyEF3KdLFNWt/3SLYz2vWVzjydRxaj8UL1WgNVfwLVeb89gXL4M52ymvsW9CxPICYCj4suMSglUy6p63AGEnR+yWba9hG2HpffCDKgmY+dFuXZ2tp/JWa7lOycV0GWW/QaWjfbd0Dvhu9HqRPB50QpAPY6xUUD1eq1/cf0+B5WeD6ozCYA2sZRanvSMKxbK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rpRNvFmEC1LEpMv6Tkf8zjX0yEsN1y0GlNp6yca3buO27q+twPib1uuWhEWoGEIunpSzYudQ20Twzs/uKraNj6N875MwE1VdYMQm5YP3gPYFj3c/NoBsMWFiKHZO66zUt7Wdka1NnV2h3C9GhGcTEQrgpgz/h3VnLRdF4D7yMd3k922FXSn17bK8jgeTc0ZGt90GJWIA6S1uJx7o5Q85KGjSz/SO+xMa/WYbtP6KBGao6oOZr0drHVhi03cUlz+hALIiTIGDc5VP2ALqqDP5Tt7p/WzzKrnA1L9wg5ilW59WGe5L/7GrTMnuxFWeKEdVqlxaJ7QvfS2PcobtKgM6gIg1kp1tB22Ni38uT3K2aHufeLdcAKDxds9e98mbAevEgpqtejw4KZq4m4pzgWZ5F1rEbGmx+o2jOx1KrRcoT4Q5/oFqkxg3rE37ONR9bkik7nFOgR1zRbgXK/9K0htvZZgHEYLJOlQBpNAbXHPqL6W8u0VR3lZYlvE1q9Mc4rttq3nYlHVPACNSAKw/vV/wH8BVtbCQYmYM2EOgS80vDpHWYNy61rUTVP/dyL+BwudtHVhVmwyAAAAAElFTkSuQmCC
// @match             *://*.taobao.com/*
// @match             *://*.tmall.com/*
// @match             *://chaoshi.detail.tmall.com/*
// @match             *://*.tmall.hk/*
// @match             *://*.liangxinyao.com/*
// @match             *://*.jd.com/*
// @match             *://*.jd.hk/*
// @match             *://*.yiyaojd.com/*
// @match             *://*.vip.com/*
// @match             *://*.vipglobal.hk/*
// @exclude           *://login.taobao.com/*
// @exclude           *://login.tmall.com/*
// @exclude           *://uland.taobao.com/*
// @exclude           *://pages.tmall.com/*
// @require           https://cdn.bootcdn.net/ajax/libs/jquery/1.8.3/jquery.min.js
// @require           https://cdn.bootcdn.net/ajax/libs/jquery.qrcode/1.0/jquery.qrcode.min.js
// @antifeature       referral-link 【应GreasyFork代码规范要求:含有优惠券查询功能的脚本必须添加此提示!在此感谢大家的理解...】
// @grant             unsafeWindow
// ==/UserScript==

(function() {
    'use strict';
    var style = document.createElement('link');
    style.href = 'https://cdn.xuelg.com/shop/style.css';
    style.rel = 'stylesheet';
    style.type = 'text/css';
    document.getElementsByTagName('head').item(0).appendChild(style);
    var apijiekou = 'https://api.shop.xuelg.com/';
    var url = location.href;
    if (url.indexOf("//item.taobao.com/item.htm") > 0 || url.indexOf("//detail.tmall.com/item.htm") > 0 || url.indexOf("//chaoshi.detail.tmall.com/item.htm") > 0 || url.indexOf("//detail.tmall.hk/hk/item.htm") > 0 || url.indexOf("//detail.tmall.hk/item.htm") > 0) {
        function QueryString(item){
            var sValue=location.search.match(new RegExp("[\?\&]"+item+"=([^\&]*)(\&?)","i"))
            return sValue?sValue[1]:sValue
        }
        $.get(apijiekou+'?id='+QueryString("id")+'&m=shangpin',function(data) {
            var yhq = '<div class="coupon-wrap"><div class="coupon"><div class="coupon-info"><div class="coupon-desc">优惠券 ' + data.coupon_amount + '元</div><div class="coupon-info2">' + data.coupon_info + '</div></div>'+
                    '<a class="coupon-get" href="' + data.coupon_click_url + '">立即领取</a></div><div class="coupon-time">优惠券截止时间:' + data.coupon_end_time + ' <b>剩余:'+ data.coupon_remain_count +'张</b></div>';
            var wyh = '<div class="coupon-wrap"><div class="coupon"><div class="coupon-info"><div class="coupon-desc">未查询到优惠券</div><div class="coupon-info2">' + data.qun + '</div></div>'+
                    '<a class="coupon-get" target="blank" href="' + data.search + '">搜索类似商品</a></div>';
            var lsj = '<div class="coupon-time"><b>历史最低价:<span id="zuidijia">加载中...</span></b> 历史高最价:<span id="zuigaojia">加载中...</span></div>';
            var ewm = '<div id="qrcode" style="position: fixed;bottom: 10px;right:35px;z-index: 9999;"><p class="coupon-time"><b>使用淘宝APP扫码领取优惠券</b></p></div>';
            if (url.indexOf('//detail.tmall.') != -1 || url.indexOf('//chaoshi.detail.tmall.') != -1) {
                if (data.coupon_amount) {
                    $('.tm-fcs-panel').after(yhq + lsj + ewm);
                } else {
                    if (url.indexOf(data.sign) != -1 || data.urltz == null) {
                        $('.tm-fcs-panel').after(wyh + lsj);
                    } else {
                        window.location.replace(data.urltz);
                    }
                }
            } else {
                if (data.coupon_amount) {
                    $('ul.tb-meta').after(yhq + lsj + ewm);
                } else {
                    if (url.indexOf(data.sign) != -1 || data.urltz == null) {
                        $('ul.tb-meta').after(wyh + lsj);
                    } else {
                        window.location.replace(data.urltz);
                    }
                }
            }
            $("#qrcode").qrcode({
                width:156,
                height:156,
                text:data.shorturl
            })
            $.get(apijiekou+'lsjg/?tbid='+QueryString("id"),function(lsjg_data) {
                document.getElementById("zuidijia").innerHTML=lsjg_data.zuidijia;
                document.getElementById("zuigaojia").innerHTML=lsjg_data.zuigaojia;
            })
        })
    } else if (url.indexOf("//item.jd.com/") > 0 || url.indexOf("//npcitem.jd.hk/") > 0 || url.indexOf("//item.yiyaojd.com/") > 0 || url.indexOf("//pcitem.jd.hk/") > 0 || url.indexOf("//pro.jd.com/") > 0 || url.indexOf("//pro.m.jd.com/") > 0 || url.indexOf("//story.m.jd.com/") > 0 || url.indexOf("//prodev.m.jd.com/") > 0 || url.indexOf("//prodev.jd.com/") > 0) {
        if (url.indexOf("?") > 0) {
            url = url.substr(0, url.indexOf("?"));
        }
        $.get(apijiekou+'jd/?url='+url,function(data) {
            var yhq = '<div class="coupon-wrap"><div class="coupon"><div class="coupon-info"><div class="coupon-desc">优惠券 ' + data.coupon_money + '元</div><div class="coupon-info2">' + data.coupon_info + '</div></div>'+
                    '<a class="coupon-get" href="' + data.clickURL + '">立即领取</a></div><div class="coupon-time">优惠券截止时间:' + data.coupon_final + '</div>';
            var wyh = '<div class="coupon-wrap"><div class="coupon"><div class="coupon-info"><div class="coupon-desc">未查询到优惠券</div><div class="coupon-info2">' + data.qun + '</div></div>'+
                    '<a class="coupon-get" target="blank" href="' + data.search + '">搜索相关优惠</a></div>';
            var lsj = '<div class="coupon-time"><b>历史最低价:<span id="zuidijia">加载中...</span></b> 历史高最价:<span id="zuigaojia">加载中...</span></div>';
            var ewm = '<div id="qrcode" style="position: fixed;bottom: 3px;right:39px;z-index: 9999;"><p class="coupon-time"><b>使用京东APP扫码领取优惠券</b></p></div>';
            if (data.coupon_money) {
                $('.summary-top').after(yhq + lsj + ewm);
            } else {
                if (location.href.indexOf(data.sign) != -1) {
                    $('.summary-top').after(wyh + lsj);
                }else {
                    window.location.replace(data.urltz);
                }
            }
            $("#qrcode").qrcode({
                width:156,
                height:156,
                text:data.shortURL
            })
            $.get(apijiekou+'lsjg/?jdurl='+url,function(lsjg_data) {
                document.getElementById("zuidijia").innerHTML=lsjg_data.zuidijia;
                document.getElementById("zuigaojia").innerHTML=lsjg_data.zuigaojia;
            })
        })
    } else if (url.indexOf("//detail.vip.com/detail") > 0 || url.indexOf("//www.vipglobal.hk/detail") > 0) {
        if (url.indexOf("?") > 0) {
            url = url.substr(0, url.indexOf("?"));
        }
        $.get(apijiekou+'vip/?url='+url,function(data) {
            var ewm = '<div id="qrcode" style="position: fixed;bottom: 3px;right:39px;z-index: 9999;"><p class="coupon-time"><b>使用微信或唯品会APP扫码购买</b></p></div>';
            if (data.url) {
                $('.pi-title-box').after(ewm);
                $("#qrcode").qrcode({
                    width:168,
                    height:168,
                    text:data.url
                })
            }
        })
    }  else {
        var objs = {};
        objs.initSearchItem = function (selector) {
            var $tmthis = $(selector);
            if ($tmthis.hasClass("tb-cool-box-already")) {
                return;
            } else {
                $tmthis.addClass("tb-cool-box-already")
            }
            var nid = $tmthis.attr("data-id");
            if (!nid || parseInt(nid) != nid || nid <= 10000) {
                nid = $tmthis.attr("data-itemid");
            }
            if (!nid || parseInt(nid) != nid || nid <= 10000) {
                if ($tmthis.attr("href")) {
                    nid = location.protocol + $tmthis.attr("href");
                } else {
                    var $tma = $tmthis.find("a");
                    if (!$tma.length) {
                        return;
                    }
                    nid = $tma.attr("data-nid");
                    if (!nid || parseInt(nid) != nid || nid <= 10000) {
                        if ($tma.hasClass("j_ReceiveCoupon") && $tma.length > 1) {
                            nid = location.protocol + $($tma[1]).attr("href");
                        } else {
                            nid = location.protocol + $tma.attr("href");
                        }
                    }
                }
            }
            var ssqun = '<div class="tb-cool-box-area tb-cool-box-wait" data-nid="' + nid + '"><a class="tb-cool-box-info tb-cool-box-info-default" title="点击查询">待查询</a></div>'
            if (nid.indexOf('http') >= 0) {
                if (nid.indexOf("//detail.ju.taobao.com/home.htm") > 0 || nid.indexOf("//item.taobao.com/item.htm") > 0 || nid.indexOf("//detail.tmall.com/item.htm") > 0 || nid.indexOf("//chaoshi.detail.tmall.com/item.htm") > 0 || nid.indexOf("//detail.tmall.hk/hk/item.htm") > 0 || nid.indexOf("//detail.tmall.hk/item.htm") > 0) {
                    $tmthis.append(ssqun);
                }
            } else if (nid) {
                $tmthis.append(ssqun);
            }
        };
        objs.basicQueryItem = function (selector) {
            var $tmthis = $(selector);
            $tmthis.removeClass("tb-cool-box-wait");
            var nid = $tmthis.attr("data-nid");
            if (nid.indexOf("?") > 0) {
                var sValue = nid.match(new RegExp("[\?\&]id=([^\&]*)(\&?)","i"));
                nid = sValue?sValue[1]:sValue;
            }
            $.get(apijiekou+'?id='+nid+'&m=sousuo',function(data) {
                if (data.coupon_amount) {
                    $tmthis.html('<a target="_blank" class="tb-cool-box-info tb-cool-box-info-find" title="切换透明度">有券(减' + data.coupon_amount + '元)</a>');
                } else {
                    $tmthis.addClass("tb-cool-box-info-translucent");
                    $tmthis.html('<a href="javascript:void(0);" class="tb-cool-box-info tb-cool-box-info-empty" title="切换透明度">暂无优惠</a>');
                }
            })
        };
        var tmselectorList = [];
        if (url.indexOf("//s.taobao.com/search") > 0 || url.indexOf("//s.taobao.com/list") > 0) {
            tmselectorList.push(".items .item");
        } else if (url.indexOf("//list.tmall.com/search_product.htm") > 0 || url.indexOf("//list.tmall.com//search_product.htm") > 0 || url.indexOf("//list.tmall.com/coudan/search_product.htm") > 0) {
            tmselectorList.push(".product");
            tmselectorList.push(".chaoshi-recommend-list .chaoshi-recommend-item");
        } else if (url.indexOf("//list.tmall.hk/search_product.htm") > 0) {
            tmselectorList.push("#J_ItemList .product");
        } else if (document.getElementById('J_ShopSearchResult')) {
            tmselectorList.push("#J_ShopSearchResult .item");
        }
        if (tmselectorList && tmselectorList.length > 0) {
            setInterval(function () {
                tmselectorList.forEach(function (selector) {
                    $(selector).each(function () {
                        objs.initSearchItem(this);
                    });
                });
            }, 1500);
            $(document).on("click", ".tb-cool-box-area", function () {
                var $tmthis = $(this);
                if ($tmthis.hasClass("tb-cool-box-wait")) {
                    objs.basicQueryItem(this);
                } else if ($tmthis.hasClass("tb-cool-box-info-translucent")) {
                    $tmthis.removeClass("tb-cool-box-info-translucent");
                } else {
                    $tmthis.addClass("tb-cool-box-info-translucent");
                }
            });
            setInterval(function () {
                $(".tb-cool-box-wait").each(function () {
                    objs.basicQueryItem(this);
                });
            }, 1500);
        }
    }
})();