花前省一省©【京东11.11现金红包!每天领3次】-【隐藏券+返现!】--支持淘宝、天猫、京东、唯品会、考拉海购,可显示返现金额,历史价格走势,配合APP扫码下单后即可获得返现~~长期更新,放心使用。

双11现金红包在各个平台任一商品详情页可领取!每天可以领3次哦!在淘宝、天猫、京东、唯品会的【商品列表页】和【商品详情页】上显示优惠券详细信息及返现金额,无需进入商品详情页即可查看,商品详情页可直接领券,功能简单,显示直观,支持在商品详情页通过「花前省一省」APP扫码,直接在APP进入商品、领券及获得返现。在代码的编写过程中,参考了作者@simples的代码,受益匪浅。

当前为 2020-10-30 提交的版本,查看 最新版本

// ==UserScript==
// @name         花前省一省©【京东11.11现金红包!每天领3次】-【隐藏券+返现!】--支持淘宝、天猫、京东、唯品会、考拉海购,可显示返现金额,历史价格走势,配合APP扫码下单后即可获得返现~~长期更新,放心使用。
// @namespace    cyzlizhe
// @version      3.4
// @description  双11现金红包在各个平台任一商品详情页可领取!每天可以领3次哦!在淘宝、天猫、京东、唯品会的【商品列表页】和【商品详情页】上显示优惠券详细信息及返现金额,无需进入商品详情页即可查看,商品详情页可直接领券,功能简单,显示直观,支持在商品详情页通过「花前省一省」APP扫码,直接在APP进入商品、领券及获得返现。在代码的编写过程中,参考了作者@simples的代码,受益匪浅。
// @author       cyzlizhe
// @icon         https://s1.ax1x.com/2020/09/15/wybNRS.png
// @match        *://*.taobao.com/*
// @match        *://*.tmall.com/*
// @match        *://*.tmall.hk/*
// @match        *://*.liangxinyao.com/*
// @match        *://*.jd.com/*
// @match        *://*.jd.hk/*
// @match        *://*.vip.com/*
// @match        *://*.kaola.com/*
// @match        *://*.suning.com/*
// @match        *://*.fengwd.com/*
// @exclude      *://login.taobao.com/*
// @exclude      *://pages.tmall.com/*
// @exclude      *://uland.taobao.com/*
// @require      https://cdn.bootcdn.net/ajax/libs/jquery/1.6.3/jquery.js
// @require      https://cdn.bootcss.com/jquery.qrcode/1.0/jquery.qrcode.min.js
// @require      https://cdn.bootcdn.net/ajax/libs/apexcharts/3.9.0/apexcharts.min.js
// @require      https://cdn.bootcdn.net/ajax/libs/xlsx/0.16.7/xlsx.core.min.js
// @run-at       document-start
// @grant        GM_xmlhttpRequest
// @grant        GM_setValue
// @grant        GM_getValue
// @connect     gwdang.com
// @note    2020年10月30日14:14:54 准被适配考拉海购
// @note    2020年10月28日18:47:22 新增考拉海购详情页支持
// @note    2020年10月27日08:49:59 支持京东国际的预售页面
// @note    2020年10月26日09:53:53 修复页面图片显示异常
// @note    2020年10月25日17:17:19 新增双11领超级红包接口
// @note    2020年10月16日11:23:12 优化京东查券体验
// @note    2020年10月12日10:37:32 解决历史价格一直验证失败的bug,若一直验证失败,可以打开购物党独立验证窗口。
// @note    2020年9月29日09:42:51 接口调整。
// @note    2020年9月28日15:31:39 增加唯品会支持,修复京东图书详情页优惠券返现不出现的bug。
// @note    2020年9月27日09:46:31 增加京东拼购页面的支持。
// @note    2020年9月25日09:23:38 修复京东商品搜索页返现金额显示不正确的bug,修复京东商品返现二维码扫码后找不到商品的bug。
// @note    2020年9月23日09:54:58 京东支持历史价格查询了,优化界面,自动隐藏需要验证和没有历史数据的商品趋势图
// @note    2020年9月22日08:51:05 修复淘宝主页异常显示,修复在无历史价格时仍旧提示验证,修复验证窗口在某种情况下无法关闭,开始适配京东历史价格
// @note    2020年9月21日08:43:03 修复历史价格不显示的bug,调用购物党接口,增加验证环节,验证后可自动刷新显示。
// @note    2020年9月18日18:03:50 新增历史价格显示(目前只支持淘宝),点击可以隐藏/显示,修复京东详情页,价格出来的慢时候代码报错
// @note    2020年9月17日12:49:27 修复部分页面下优惠券会出现两个的问题。
// @note    2020年9月16日15:05:21 修复京东列表页懒加载后隐藏标签无效的bug,修复部分阿里健康大药房不显示优惠券的bug
// @note    2020年9月15日16:05:04 新增对京东新款,京东优评页面的支持,部分界面调整
// @note    2020年9月14日17:32:30 更新,修复部分页面不显示的bug,修复返现金额显示不准确。
// @note    2020年9月13日22:57:15 更新,新增京东优惠券及返现的支持,修复上一版中天猫超市优惠券查询无反应的bug。
// @note    2020年9月10日11:37:20 更新,修复返现金额查询时间长的bug,京东的查券返现功能正在适配中。
// ==/UserScript==

(function () {
    "use strict";
    var $2 = $.noConflict(); // 第二个加载的jQuery对象变成了 $2
    if (!(location.href.indexOf('fengwd.com') > 0)) {

        // Your code here...
        var style = document.createElement("link");
        style.href = "https://www.youyizhineng.top/query_coupon/query_coupon.css";
        style.rel = "stylesheet";
        style.type = "text/css";
        document.getElementsByTagName("head").item(0).appendChild(style);

        style = document.createElement("link");
        style.href = "https://www.youyizhineng.top/query_coupon/coupon_style.css";
        style.rel = "stylesheet";
        style.type = "text/css";
        document.getElementsByTagName("head").item(0).appendChild(style);

        var obj = {};
        var couponArea;
        var jd_item_list = '';
        var jd_data_list_back = '';
        var check_url = '';
        var stop = '';
        var options = {
            title: { // 显示折现图的title
                text: '花前省一省-商品历史价格走势图',
                fontSize: '12px'
            },
            markers: {
                size: 0,
                colors: ['#fbb5b0'],
            },
            chart: {
                height: 200,
                width: "100%",
                type: "area",
                animations: {
                    initialAnimation: {
                        enabled: false
                    }
                }
            },
            series: [
                {
                    name: "价格",
                    data: []
                }
            ],
            xaxis: {
                type: "datetime",
                labels: {
                    datetimeFormatter: {
                        year: 'yyyy',
                        month: 'MM \-yy',
                        day: 'yyyy-MM-dd',
                        hour: 'HH:mm'
                    }
                }
            },
            stroke: {
                curve: 'smooth',
                width: [0.5, 0.5, 0.5]
            },
            colors: ['#F44336'],
            dataLabels: {
                enabled: false,
                style: {
                    colors: ['#000000']
                }
            },
            tooltip: {
                x: {
                    format: 'yyyy-MM-dd'
                },
                y: [{
                    formatter: function (y) {
                        if (typeof y !== "undefined") {
                            return y.toFixed(0) + "元";
                        }
                        return y;
                    }
                }]
            }
        }
        var chart;
        //列表页面操作
        obj.initSearchHtml = function (selectorList) {
            setInterval(function () {
                selectorList.forEach(function (selector) {
                    obj.initSearchItemSelector(selector);
                });
            }, 1000);
        };

        obj.initSearchItemSelector = function (selector) {
            $2(selector).each(function () {
                obj.initSearchItem(this);
            });
        };

        obj.initSearchItem = function (selector) {
            var $this = $2(selector);
            var nid;
            if ($this.hasClass("tb-cool-box-already")) {
                return;
            } else {
                $this.addClass("tb-cool-box-already");
            }
            if (obj.site_type() == "taobao_lst_page") {
                nid = $this.attr("data-id");
                if (!obj.isVailidItemId(nid)) {
                    nid = $this.attr("data-itemid");
                }

                if (!obj.isVailidItemId(nid)) {
                    if ($this.attr("href")) {
                        nid = location.protocol + $this.attr("href");
                    } else {
                        var $a = $this.find("a");
                        if (!$a.length) {
                            return;
                        }

                        nid = $a.attr("data-nid");
                        if (!obj.isVailidItemId(nid)) {
                            if ($a.hasClass("j_ReceiveCoupon") && $a.length > 1) {
                                nid = location.protocol + $2($a[1]).attr("href");
                            } else {
                                nid = location.protocol + $a.attr("href");
                            }
                        }
                    }
                }
            }
            else if (obj.site_type() == "jingdong_lst_page") {
                nid = $this.attr("data-sku");
                if (typeof (nid) == "undefined") {
                    nid = $this.find('.price').attr("data-skuid");
                }
                if (!obj.isVailidItemId(nid)) {
                    nid = $this.find(".p-operate").find("a").attr("skuid");
                }
            }
            else if (obj.site_type() == "vip_list_page") {
                nid = $this.attr("data-product-id");
                // console.log(nid);
                if (typeof (nid) == "undefined") {
                    nid = $this.find('.c-goods-item__sale-price').html().split("</span>")[1];
                }
                if (!obj.isVailidItemId(nid)) {
                    // nid = $this.find(".p-operate").find("a").attr("skuid");
                }
            }
            if (obj.isValidNid(nid)) {
                // console.log(nid);
                obj.appenBasicQueryHtml($this, nid);
            }
        };
        //图片上显示提示图标
        obj.initSearchEvent = function () {
            $2(".tb-cool-box-area").live("click", function () {
                var Show_hide_div_id = $2(this).attr("name");
                var a = document.getElementsByName(Show_hide_div_id)[0].style.opacity;
                for (let index = 0; index < document.getElementsByName(Show_hide_div_id).length; index++) {
                    if (a == "" || a == "1") {
                        document.getElementsByName(Show_hide_div_id)[index].style.opacity = "0.2";
                    } else {
                        document.getElementsByName(Show_hide_div_id)[index].style.opacity = "1";
                    }
                }
            });
            $2(".tb-cool-box-area-rm").live("click", function () {
                var Show_hide_div_id = $2(this).attr("name");
                var a = document.getElementsByName(Show_hide_div_id)[0].style.opacity;
                for (let index = 0; index < document.getElementsByName(Show_hide_div_id).length; index++) {
                    if (a == "" || a == "1") {
                        document.getElementsByName(Show_hide_div_id)[index].style.opacity = "0.2";
                    } else {
                        document.getElementsByName(Show_hide_div_id)[index].style.opacity = "1";
                    }
                }
            });
        };

        obj.basicQuery = function () {
            setInterval(function () {
                $2(".tb-cool-box-wait").each(function () {
                    obj.basicQueryItem(this);
                });
            }, 1000);
        };

        obj.basicQuery_jd_list = function () {
            setInterval(function () {
                if ($2(".tb-cool-box-wait").length > 0) {
                    jd_item_list = jd_item_list.substr(0, jd_item_list.length - 1);
                    obj.update_jd_list_data(jd_item_list);
                    // console.log(jd_item_list);
                    jd_item_list = '';
                }
                if ($2(".tb-cool-box-wait-rm").length > 0 && jd_data_list_back != '') {
                    // console.log($2(".tb-cool-box-wait-rm").length);
                    // console.log(jd_data_list_back);
                    $2(".tb-cool-box-wait-rm").each(function () {
                        obj.basicQueryItem_jd(this, jd_data_list_back, 'refresh_cashback');
                    });
                    jd_data_list_back = '';
                }
            }, 1500);
        };


        obj.update_jd_list_data = function (jd_item_list) {
            console.log(obj.site_type());
            var operate = '';
            if (obj.site_type() == "jingdong_lst_page") {
                operate = "quert_list_jd";
            } else if (obj.site_type() == "vip_list_page") {
                operate = "quert_list_vip";
            }
            url =
                "https://www.youyizhineng.top/query_coupon/query_coupon.php?operate=" + operate + "&itemid_list=" +
                jd_item_list;

            console.log(url);
            $2.getJSON(url, function (data) {
                console.log(data);
                $2(".tb-cool-box-wait").each(function () {
                    obj.basicQueryItem_jd(this, data, '');
                });
                jd_data_list_back = data;
            });
        }


        obj.appenBasicQueryHtml = function (selector, nid) {
            if (obj.site_type() == "jingdong_lst_page" || obj.site_type() == "vip_list_page") {
                jd_item_list = jd_item_list + nid + ",";
            }

            selector.append(
                '<div class="tb-cool-box-area tb-cool-box-wait"  data-nid="' +
                nid +
                '"  name="c_div_' +
                nid +
                '"><a class="tb-cool-box-info tb-cool-box-info-default" title="点击查询">查询中...</a></div>'
            );
            selector.append(
                '<div class="tb-cool-box-area-rm tb-cool-box-wait-rm"  data-nid="' +
                nid +
                '"  name="r_div_' +
                nid +
                '"><a class="tb-cool-box-info tb-cool-box-info-default" title="点击查询">查询中...</a></div>'
            );
        };

        obj.basicQueryItem = function (selector) {
            var $this = $2(selector);
            var url;
            $this.removeClass("tb-cool-box-wait");

            var nid = $this.attr("data-nid");
            url =
                "https://www.youyizhineng.top/query_coupon/query_coupon.php?operate=quert_single&itemid=" +
                nid;

            var xhr1 = new XMLHttpRequest();//第一步:新建对象
            xhr1.open('GET', url, true);//第二步:打开连接  将请求参数写在url中
            xhr1.send();//第三步:发送请求  将请求参数写在URL中
            /**
             * 获取数据后的处理程序
             */
            xhr1.onreadystatechange = function () {
                if (xhr1.readyState == 4 && xhr1.status == 200) {
                    var res = xhr1.responseText;//获取到json字符串,解析
                    var data = JSON.parse(res);

                    if (data.couponmoney != 0 || data.return_money_rate != 0) {
                        obj.showBasicQueryFind($this, data.couponmoney, data.return_money_rate, data.url2, '');
                    } else {
                        obj.showBasicQueryEmpty($this);
                    }
                }
            }
        };
        obj.basicQueryItem_jd = function (selector, data, flag) {
            if (flag == 'refresh_cashback') {
                var $this = $2(selector).prev();
            } else {
                var $this = $2(selector);
            }
            var url;
            var each_couponmoney;
            var each_return_money_rate;
            var each_return_money;
            var each_url2;
            if ($this.hasClass("tb-cool-box-wait")) {
                $this.removeClass("tb-cool-box-wait");
            } else {
                return;
            }
            // $this.next().removeClass("tb-cool-box-wait-rm");

            var nid = $this.attr("data-nid");
            if (typeof (data[nid]) == "undefined") {
                each_couponmoney = 0;
                each_return_money_rate = 0;
                each_url2 = '';
            }
            else {
                each_couponmoney = data[nid].couponmoney;
                each_return_money_rate = data[nid].return_money_rate;
                if (obj.site_type() == "vip_list_page") {
                    each_return_money = data[nid].return_money;
                }
                each_url2 = data.url2;
            }

            if (each_couponmoney != 0 || each_return_money_rate != 0) {
                obj.showBasicQueryFind($this, each_couponmoney, each_return_money_rate, each_url2, each_return_money)
            } else {
                obj.showBasicQueryEmpty($this);
            }
        };

        obj.showBasicQueryFind = function (selector, couponMoney, rm_Money, url2, return_money) {
            var price;
            if (selector.find(".tb-cool-box-info-find").length > 0) {
                return;
            }
            if (couponMoney == "0") {
                selector.html(
                    '<a target="_blank" class="tb-cool-box-info tb-cool-box-info-find" title="显示/隐藏">无券</a>'
                );
            } else {
                selector.html(
                    '<a target="_blank" class="tb-cool-box-info tb-cool-box-info-find" title="显示/隐藏">有券(减' +
                    couponMoney +
                    "元)</a>"
                );
            }

            var url = location.href;
            if (url.indexOf("//s.taobao.com/search") > 0 || url.indexOf("//s.taobao.com/list") > 0) {
                price = selector.prev().find("strong").html();
                if (url2 != '') {
                    selector.prev().find(".J_ClickStat").attr("href", url2);
                    selector.prev().prev().find(".pic").find("a").attr("href", url2);
                }
            }
            else if (url.indexOf("//list.tmall.com/search_product.htm") > 0) {
                price = selector.prev().find("em").attr('title');
                if (price > 0) {
                    price = selector.prev().find("em").attr('title');
                    if (url2 != '') {
                        selector.prev().find(".productTitle").find("a").attr("href", url2);
                        selector.prev().find(".productImg").attr("href", url2);
                    }
                }
                else {
                    price = selector.prev().find(".item-price").find("strong").html();
                }
            }
            else if (url.indexOf("//list.tmall.hk/search_product.htm") > 0) {
                price = selector.prev().find("em").attr('title');
                if (url2 != '') {
                    selector.prev().find(".productTitle").find("a").attr("href", url2);
                    selector.prev().find(".productImg").attr("href", url2);
                }
            }
            else if (url.indexOf("//maiyao.liangxinyao.com/shop/view_shop.htm") > 0) {
                price = selector.prev().prev().find(".c-price").html();
                if (price > 0) {
                    price = selector.prev().prev().find(".c-price").html();
                    if (url2 != '') {
                        selector.prev().prev().find("a").attr("href", url2);
                        selector.prev().prev().prev().find("a").attr("href", url2);
                    }
                }
                else {
                    price = selector.prev().find(".c-price").html();
                    if (url2 != '') {
                        selector.prev().find("a").attr("href", url2);
                        selector.prev().prev().find("a").attr("href", url2);
                    }
                }
            }
            else if (url.indexOf("//search.jd.com/Search") > 0 || url.indexOf("//list.jd.com/list.html") > 0) {
                price = selector.prev().find(".p-price").find("i").html();
                if (price > 0) {
                    price = selector.prev().find(".p-price").find("i").html();
                }
            }
            else if (url.toLowerCase().indexOf("//search.jd.hk/search".toLowerCase()) > 0) {
                price = selector.prev().find(".price").find("span").html().split('>')[2];
            }
            else if (url.toLowerCase().indexOf("//www.jd.com/xinkuan".toLowerCase()) > 0) {
                price = selector.prev().find(".price").find("strong").html().split('¥')[1];
                if (price == "暂无报价") {
                    return;
                }
            }

            if (obj.site_type() != "vip_list_page") {
                var rm_Money_clc = Math.round(Math.floor((price - couponMoney) * rm_Money * 1000) / 10) / 100;
            } else {
                var rm_Money_clc = Math.floor(return_money * 100) / 100;
            }

            if (rm_Money_clc != 0) {
                selector.next().html(
                    '<a target="_blank" class="tb-cool-box-info tb-cool-box-info-find-rm" title="使用APP「花前省一省」扫码宝贝详情页二维码可得返现">返现(约' +
                    rm_Money_clc +
                    "元)</a>"
                );
            }
            else {
                selector.next().html(
                    '<a target="_blank" class="tb-cool-box-info tb-cool-box-info-find" title="显示/隐藏">无返现</a>'
                );
            }
        };

        obj.showBasicQueryEmpty = function (selector) {
            // selector.addClass("tb-cool-box-info-translucent");
            selector.html(
                '<a href="javascript:void(0);" class="tb-cool-box-info tb-cool-box-info-empty" style="opacity:0.5;" title="切换透明度">暂无优惠</a>'
            );
            selector
                .next()
                .html(
                    '<a href="javascript:void(0);" class="tb-cool-box-info tb-cool-box-info-empty" style="opacity:0.5;" title="切换透明度">暂无返现</a>'
                );
        };

        obj.site_type = function () {
            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.liangxinyao.com/item.htm") > 0 ||
                url.indexOf("//detail.tmall.hk/item.htm") > 0
            ) {
                return "taobao_details_page";
            } else if (
                url.indexOf("//maiyao.liangxinyao.com/shop/view_shop.htm") > 0 ||
                url.indexOf("//list.tmall.com/search_product.htm") > 0 ||
                url.indexOf("//s.taobao.com/search") > 0 ||
                url.indexOf("//list.tmall.hk/search_product.htm") > 0
            ) {
                return "taobao_lst_page";
            }
            else if (
                url.indexOf("//search.jd.com/Search") > 0 ||
                url.indexOf("//search.jd.hk/search") > 0 ||
                url.indexOf("//www.jd.com/xinkuan") > 0 ||
                url.indexOf("//list.jd.com/list.html") > 0 ||
                url.indexOf("//search.jd.hk/Search") > 0
            ) {
                return "jingdong_lst_page";
            }
            else if (
                url.indexOf("//item.jd.hk") > 0 ||
                url.indexOf("//pcitem.jd.hk") > 0 ||
                url.indexOf("//item.jd.com") > 0
            ) {
                return "jingdong_details_page";
            }
            else if (
                url.indexOf("//category.vip.com/suggest.php") > 0 ||
                url.indexOf("//list.vip.com") > 0
            ) {
                return "vip_list_page";
            }
            else if (
                url.indexOf("//detail.vip.com") > 0
            ) {
                return "vip_detail_page";
            }
            else if (
                url.indexOf("//goods.kaola.com/product") > 0
            ) {
                // alert(1);
                return "kaola_detail_page";
            }
            else if (
                url.indexOf("//product.suning.com") > 0
            ) {
                // alert(1);
                return "suning_detail_page";
            }
        }
        obj.isDetailPageTaoBao = function (url) {
            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
            ) {
                return true;
            } else {
                return false;
            }
        };

        obj.DetailPageTB_or_TM_or_JD = function () {

            var url = location.href;
            if (url.indexOf("//item.taobao.com/item.htm") > 0 || url.indexOf("//detail.liangxinyao.com/item.htm") > 0) {
                return 1;
            }
            else if (url.indexOf("//detail.tmall.com/item.htm") > 0) {
                return 2;
            }
            else if (url.indexOf("//item.jd.com") > 0) {
                return 3;
            }
        };


        obj.isVailidItemId = function (itemId) {
            if (!itemId) {
                return false;
            }

            var itemIdInt = parseInt(itemId);
            if (itemIdInt == itemId && itemId > 10000) {
                return true;
            } else {
                return false;
            }
        };

        obj.isValidNid = function (nid) {
            if (!nid) {
                return false;
            } else if (nid.indexOf("http") >= 0) {
                if (
                    obj.isDetailPageTaoBao(nid) ||
                    nid.indexOf("//detail.ju.taobao.com/home.htm") > 0
                ) {
                    return true;
                } else {
                    return false;
                }
            } else {
                return true;
            }
        };

        obj.getprice = function (selector) {
            if (!nid) {
                return false;
            } else if (nid.indexOf("http") >= 0) {
                if (
                    obj.isDetailPageTaoBao(nid) ||
                    nid.indexOf("//detail.ju.taobao.com/home.htm") > 0
                ) {
                    return true;
                } else {
                    return false;
                }
            } else {
                return true;
            }
        };

        obj.send_get_req = function (url) {
            var xhr = new XMLHttpRequest();//第一步:新建对象
            xhr.open('GET', url, true);//第二步:打开连接  将请求参数写在url中
            xhr.send();//第三步:发送请求  将请求参数写在URL中
            /**
             * 获取数据后的处理程序
             */
            xhr.onreadystatechange = function () {
                if (xhr.readyState == 4 && xhr.status == 200) {
                    var res = xhr.responseText;//获取到json字符串,解析
                }
            };
        };
        obj.get_tb_price = function (price_str) {
            var price = '';
            if (price_str != null) {
                if (price_str.indexOf("-") > 0) {
                    price = price_str.split("-")[0];
                }
                else {
                    price = price_str;
                }
            }
            return price;
        };

        obj.get_data = function () {
            var operate = '';

            if (obj.site_type() == "jingdong_details_page") {
                if (location.href.length > 70) {
                    return;
                }
                operate = "get_info";
            } else if (obj.site_type() == "vip_detail_page") {
                if (location.href.indexOf("wq=1") > 0) {
                    return;
                }
                operate = "get_info_vip";
            } else if (obj.site_type() == "kaola_detail_page") {
                if (location.href.indexOf("?__") > 0) {
                    // alert(1);
                    return;
                }
                operate = "get_info_kaola";
            }

            // alert(location.href);
            var url =
                "https://www.youyizhineng.top/query_coupon/query_coupon.php?operate=" + operate + "&data_i=" +
                location.href;
            console.log(url);
            $2.ajax({
                url: url,
                async: false,
                timeout: 1000,
                // dataType: "json",
                success: function (data) {
                    console.log(data);
                    try {
                        var data_tmp = JSON.parse(data);
                        if (data_tmp.data_i != null) {
                            window.location.href = data_tmp.data_i;
                            stop = '1';
                        }
                    } catch {

                    }
                }
            })
        };

        obj.generate_trend_data = function (all_begin_time, all_line) {

            if (all_line.length > 0) {
                for (let index = 0; index < all_line.length; index++) {
                    var data_tmp = {};
                    var newTime = new Date(all_begin_time);
                    newTime = newTime.setDate(newTime.getDate() + index);
                    newTime = new Date(newTime);

                    var newTime_d = (newTime.getMonth() + 1).toString().padStart(2, '0') + "-" + newTime.getDate().toString().padStart(2, '0') + "-" + newTime.getFullYear() + " GMT";
                    data_tmp["x"] = newTime_d;
                    data_tmp["y"] = all_line[index];
                    options.series[0].data.push(data_tmp);
                }
            }
        };
        obj.query_trend_data = function () {
            // alert(1);
            //获得价格波动var url = location.href;
            var gwdUrl = "https://browser.gwdang.com/extension/price_towards?url=" + encodeURIComponent(location.href);
            // console.log(gwdUrl);
            // console.log('1');
            GM_xmlhttpRequest({
                url: gwdUrl,
                method: 'GET',
                timeout: 10000,
                headers: {
                    'Content-Type': 'application/json',
                    'Accept': 'application/json',
                    'Cache-Control': 'public'
                },
                onload: function (res) {
                    //loadingMask.parentNode.removeChild(mask);
                    const json = JSON.parse(res.responseText);
                    const data = json;
                    // console.log(data);
                    if (data.is_ban == null) {
                        // console.log(typeof (data.store));
                        var all_line;
                        var all_begin_time;
                        if ($2("#float_div").css("display") == "block") {
                            location.reload();
                        }
                        if (typeof (data.store) != "undefined" && data.store[0].all_line != null) {
                            all_begin_time = data.store[0].all_line_begin_time;
                            all_line = data.store[0].all_line;
                            if (all_line.length != 0) {
                                obj.generate_trend_data(all_begin_time, all_line);
                            } else {
                                options.title.text = "花前省一省-本商品暂无历史数据";
                            }
                        }
                        else {
                            options.title.text = "花前省一省-本商品暂无历史数据";
                        }
                        // console.log(check_url);
                    } else {
                        options.title.text = "本次需要验证:【点击上方按钮进行验证】";
                        check_url = data.action.to;
                        // console.log(check_url);
                    }
                }
            });
        }
        obj.add_iframe = function () {
            // console.log(check_url);
            // console.log(options);
            if (options.title.text == "花前省一省-本商品暂无历史数据") {
                $2(".image-status").attr("title", "历史数据加载成功");
                $2(".image-status").attr("src", "https://s1.ax1x.com/2020/10/26/BnYQkn.png");

                $2(".status-span").html("经查询,本商品暂无历史数据");
                $2("#coupon-wrap-trend").css("display", "none");
            }
            else if (options.series[0].data.length > 0) {
                $2(".image-status").attr("title", "历史数据加载成功");
                $2(".image-status").attr("src", "https://s1.ax1x.com/2020/10/26/BnYQkn.png");
            } else {
                //在chart上提示显示文字
                $2(".trend-div").append('<span class="cover-chart-span">21321321321</span>');

                $2(".image-status").attr("title", "需要验证");
                $2(".image-status").attr("src", "https://s1.ax1x.com/2020/10/26/BnYkfP.gif");
                $2(".image-status").css("cursor", "pointer");
                $2("#coupon-wrap-trend").css("display", "none");

                $2(".status-span").html("← 点击左侧按钮验证");
                $2("body").append('<div id="float_div" class="frame_div"></div>');
                document.getElementById("float_div").style.left = (window.screen.width - 800) / 2 + "px";
                document.getElementById("float_div").style.top = (window.screen.height - 500) / 2 + "px";
                $2("#float_div").append('<iframe id="iframe_check" src="" ></iframe>');
                $2("#iframe_check").attr("src", check_url);
                $2("#iframe_check").attr("scrolling", "no");
                $2("#float_div").append('<div class="cover"><img src="https://s1.ax1x.com/2020/09/23/wjSB4K.png" alt="未命名1600825169" border="0"><br>验证后将自动刷新,若一直验证失败,<a style="color:red" target="_blank"  href="' + check_url + '">点击此处</a>在独立页面中验证后关闭即可</div>');
                $2(".image-status").click(function (event) {
                    $2("#float_div").css("display", "none");
                    if ($2("#float_div").css("display") == "block") {
                        $2("#float_div").css("display", "none");
                    } else {
                        $2("#float_div").css("display", "block");
                        var w_check = setInterval(function () {
                            obj.query_trend_data();
                            if (options.series[0].data.length > 0) {
                                console.log(options);
                                $2("#float_div").css("display", "none");
                                chart = new ApexCharts(document.querySelector("#chart"), options);
                                chart.render();
                                clearInterval(w_check);
                            }
                        }, 1000);
                    }
                });
                //关闭按钮
                $2("#float_div").append('<img class="cover-close" src="https://s1.ax1x.com/2020/10/26/BnYYXF.png" ></img>');
                $2(".cover-close").click(function (event) {
                    $2("#float_div").css("display", "none");
                });
            }


            $2("#trend_click").click(function (event) {
                $2("#coupon-wrap-qr").css("display", "none");
                if ($2("#coupon-wrap-trend").css("display") == "block") {
                    $2("#coupon-wrap-trend").css("display", "none");
                } else {
                    $2("#coupon-wrap-trend").css("display", "block");
                }
            });


        }

        obj.close = function () {
            window.close();
        }
        if (obj.site_type() == "taobao_details_page") {
            var params = location.search.split("?")[1].split("&");
            for (var index in params) {
                if (params[index].split("=")[0] == "id") {
                    var productId = params[index].split("=")[1];
                    break;
                }
            }
            obj.query_trend_data();
            var url =
                "https://www.youyizhineng.top/query_coupon/query_coupon.php?operate=quert_single&itemid=" +
                productId;

            var xhr = new XMLHttpRequest();//第一步:新建对象
            xhr.open('GET', url, true);//第二步:打开连接  将请求参数写在url中
            xhr.send();//第三步:发送请求  将请求参数写在URL中
            /**
             * 获取数据后的处理程序
             */
            xhr.onreadystatechange = function () {
                if (xhr.readyState == 4 && xhr.status == 200) {
                    var res = xhr.responseText;//获取到json字符串,解析
                    console.log(res);
                    var data = JSON.parse(res);
                    var couponArea;
                    if (data.couponmoney == 0) {
                        couponArea =
                            '<div class="coupon-wrap"><div class="stamp stamp04">' +
                            '<div class="par"><sub class="sign">¥</sub><span style="font-size:20px">暂无优惠券</span><p></p></div>' +
                            "<i></i></div></div>";
                    } else {
                        couponArea =
                            '<div class="coupon-wrap"><div class="stamp stamp04">' +
                            '<div class="par"><sub class="sign">¥</sub><span>' +
                            data.couponmoney +
                            "</span><p>" +
                            data.couponexplain +
                            "</p></div>" +
                            '<div class="copy">优惠券<p>' +
                            data.couponstarttime +
                            "<br>" +
                            data.couponendtime +
                            '</p><a href="' +
                            data.url1 +
                            '">直接领券</a></div>' +
                            "<i></i></div></div>";
                    }

                    if (data.return_money_rate == 0) {
                        couponArea =
                            couponArea +
                            '<div class="coupon-wrap-rm"><div class="rm-div">' +
                            '<span>暂无返现</span>' +
                            '<div class="rm-btn" id="a_click">其他功能</div>' +
                            '</div></div>' +
                            '<div class="coupon-wrap-rm"><div class="rm-div">' +
                            '<div class="trend-btn" id="trend_click">历史价格走势<img class="trend-btn-img" src="https://s1.ax1x.com/2020/10/26/BnY0t1.png" alt=""></div>' +
                            '<img class="image-status">' +
                            '<em class="status-span"></em>' +
                            '</div></div>' +
                            '<div id="coupon-wrap-qr" class="coupon-wrap-qr"><div class="qr-code-div">' +
                            '<img class="qr-img" src="https://s1.ax1x.com/2020/10/26/BnY7jS.png"></img>' +
                            '<span class="title">「花前省一省」是一款领券返现的APP,支持淘宝、天猫、京东、拼多多、唯品会等等主流平台~还有点外卖领券返现,电影票优惠购,全网vip视频免费看等功能,让您花钱之前,再省一省</span>' +
                            '<span class="foot" style="height:20px">扫码下载,支持IOS和安卓,也可在各大应用市场下载</span>' +
                            '</div></div>' +
                            '<div id="coupon-wrap-trend" class="coupon-wrap-price"><div class="trend-div">' +
                            '<div id="chart"></div>' +
                            '</div></div>';
                    } else {
                        couponArea =
                            couponArea +
                            '<div class="coupon-wrap-rm"><div class="rm-div" style="width:600px">' +
                            '<span id="rm_money">返现查询中...</span>' +
                            '<div class="rm-btn" id="a_click">点击领取返现</div>' +
                            '</div></div>' +
                            '<div class="coupon-wrap-rm"><div class="rm-div">' +
                            '<div class="trend-btn" id="trend_click">历史价格走势<img class="trend-btn-img" src="https://s1.ax1x.com/2020/10/26/BnY0t1.png" alt=""></div>' +
                            '<img  class="image-status" >' +
                            '<em class="status-span"></em>' +
                            '</div></div>' +
                            '<div id="coupon-wrap-qr" class="coupon-wrap-qr"><div class="qr-code-div">' +
                            '<div id="qrcode"></div><span class="title">获得返现只需三步~</br></br>①应用商店下载APP:花前省一省</br>②使用APP主页扫一扫功能扫左侧生成的商品码</br>③在APP上领券下单,确认收货后返现将进入app账户余额~</br><br>花前省一省--花钱之前,再省一省</span>' +
                            '<span class="foot" style="height:20px">支持IOS和安卓,各大应用市场均有下载</span>' +
                            '</div></div>' +
                            '<div id="coupon-wrap-trend" class="coupon-wrap-price"><div class="trend-div">' +
                            '<div id="chart"></div>' +
                            '</div></div>';
                    }

                    var si = setInterval(function () {
                        if ($2(".coupon-wrap").length == 0) {
                            if ($2(".tm-fcs-panel").length > 0) {
                                $2(".tm-fcs-panel").after(couponArea);
                            } else if ($2("ul.tb-meta").length > 0) {
                                $2("ul.tb-meta").after(couponArea);
                            }
                            $2(".coupon-wrap").eq(0).before(data.html);
                            console.log(data.html);
                            var qr_code_text = obj.DetailPageTB_or_TM_or_JD() + '//' + productId;
                            $2("#qrcode").qrcode({ width: 150, height: 150, text: qr_code_text });
                            $2("#a_click").click(function (event) {
                                $2("#coupon-wrap-trend").css("display", "none");
                                if ($2("#coupon-wrap-qr").css("display") == "block") {
                                    $2("#coupon-wrap-qr").css("display", "none");
                                } else {
                                    $2("#coupon-wrap-qr").css("display", "block");
                                }
                            });

                            obj.add_iframe();
                            chart = new ApexCharts(document.querySelector("#chart"), options);
                            chart.render();

                        }

                        if (data.return_money_rate != 0) {
                            var price_str = '';
                            if ($2(".tm-price-panel").find(".tm-price").length > 0) {
                                var price_str = $2(".tm-price-panel").find(".tm-price").html();
                            } else if ($2("#J_StrPrice").find(".tb-rmb-num").length > 0) {
                                var price_str = $2("#J_StrPrice").find(".tb-rmb-num").html();
                            }
                            var price = obj.get_tb_price(price_str);

                            var price_prompt_str = '';
                            if ($2(".tm-promo-price").find(".tm-price").length > 0) {
                                price_prompt_str = $2(".tm-promo-price").find(".tm-price").html();
                            } else if ($2("#J_PromoPriceNum").length > 0) {
                                price_prompt_str = $2("#J_PromoPriceNum").html();
                            }
                            var price_prompt = obj.get_tb_price(price_prompt_str);
                            if (price != null) {
                                if (price_prompt != null && price_prompt != '') {
                                    var rm = Math.round(Math.floor((price_prompt - data.couponmoney) * data.return_money_rate * 1000) / 10) / 100;
                                }
                                else {
                                    rm = Math.round(Math.floor((price - data.couponmoney) * data.return_money_rate * 1000) / 10) / 100;
                                }

                                if (rm > 0) {
                                    var str = '返现约为:' + rm + '元'
                                    $2("#rm_money").html(str);
                                }
                            }


                        }
                    }, 500);

                }
            };
        } else if (obj.site_type() == "taobao_lst_page") {
            if (document.title.indexOf("天猫超市") > 0) {
                // return;
            }
            var selectorList = [];
            url = location.href;
            if (
                url.indexOf("//s.taobao.com/search") > 0 ||
                url.indexOf("//s.taobao.com/list") > 0
            ) {
                selectorList.push(".items .item");
            } else if (url.indexOf("//list.tmall.com/search_product.htm") > 0) {
                selectorList.push(".product");
                selectorList.push(".chaoshi-recommend-list .chaoshi-recommend-item");
            } else if (url.indexOf("//list.tmall.hk/search_product.htm") > 0) {
                selectorList.push("#J_ItemList .product");
            } else if (url.indexOf("//maiyao.liangxinyao.com/shop/view_shop") > 0) {
                selectorList.push("#J_ShopSearchResult .item");
            }
            if (selectorList && selectorList.length > 0) {

                obj.initSearchHtml(selectorList);
                obj.initSearchEvent();
                obj.basicQuery();
            }
        } else if (obj.site_type() == "jingdong_details_page") {
            var price = 0;
            var rm = 0;
            var str = 0;

            //get data
            obj.get_data();
            if (stop == '1') {
                return;
            }
            var productId = location.href.split("//")[1].split("/")[1].split(".")[0];
            var url =
                "https://www.youyizhineng.top/query_coupon/query_coupon.php?operate=quert_single_jd&itemid=" +
                productId;

            obj.query_trend_data();
            var xhr = new XMLHttpRequest();//第一步:新建对象
            xhr.open('GET', url, true);//第二步:打开连接  将请求参数写在url中
            xhr.send();//第三步:发送请求  将请求参数写在URL中
            /**
             * 获取数据后的处理程序
             */
            xhr.onreadystatechange = function () {
                if (xhr.readyState == 4 && xhr.status == 200) {
                    var res = xhr.responseText;//获取到json字符串,解析
                    console.log("resresres");
                    console.log(res);
                    var data_tmp = JSON.parse(res);
                    var data = data_tmp[productId];
                    var data_detail = data_tmp[productId];
                    if (data.couponmoney == 0) {
                        couponArea =
                            '<div class="coupon-wrap"><div class="stamp stamp04">' +
                            '<div class="par"><sub class="sign">¥</sub><span style="font-size:20px">暂无隐藏优惠券</span><p></p></div>' +
                            "<i></i></div></div>";
                    } else {
                        couponArea =
                            '<div class="coupon-wrap"><div class="stamp stamp04">' +
                            '<div class="par"><sub class="sign">¥</sub><span>' +
                            data.couponmoney +
                            "</span><p>" +
                            data.couponexplain +
                            "</p></div>" +
                            '<div class="copy">优惠券<p>' +
                            data.couponstarttime +
                            "<br>" +
                            data.couponendtime +
                            '</p><a href="' +
                            data.url1 +
                            '">直接领券</a></div>' +
                            "<i></i></div></div>";
                    }

                    if (data.return_money_rate == 0) {
                        couponArea =
                            couponArea +
                            '<div class="coupon-wrap-rm"><div class="rm-div">' +
                            '<span>暂无返现</span>' +
                            '<div class="rm-btn" id="a_click">其他功能</div>' +
                            '</div></div>' +
                            '<div class="coupon-wrap-rm"><div class="rm-div">' +
                            '<div class="trend-btn" id="trend_click">历史价格走势<img class="trend-btn-img" src="https://s1.ax1x.com/2020/10/26/BnY0t1.png" alt=""></div>' +
                            '<img class="image-status">' +
                            '<em class="status-span"></em>' +
                            '</div></div>' +
                            '<div id="coupon-wrap-qr" class="coupon-wrap-qr"><div class="qr-code-div">' +
                            '<img class="qr-img" src="https://s1.ax1x.com/2020/10/26/BnY7jS.png"></img>' +
                            '<span class="title">「花前省一省」是一款领券返现的APP,支持淘宝、天猫、京东、拼多多、唯品会等等主流平台~还有点外卖领券返现,电影票优惠购,全网vip视频免费看等功能,让您花钱之前,再省一省</span>' +
                            '<span class="foot" style="height:20px">扫码下载,支持IOS和安卓,也可在各大应用市场下载</span>' +
                            '</div></div>' +
                            '<div id="coupon-wrap-trend" class="coupon-wrap-price"><div class="trend-div">' +
                            '<div id="chart"></div>' +
                            '</div></div>';
                    } else {
                        couponArea =
                            couponArea +
                            '<div class="coupon-wrap-rm"><div class="rm-div" style="width:600px">' +
                            '<span id="rm_money">返现查询中...</span>' +
                            '<div class="rm-btn" id="a_click">点击领取返现</div>' +
                            '</div></div>' +
                            '<div class="coupon-wrap-rm"><div class="rm-div">' +
                            '<div class="trend-btn" id="trend_click">历史价格走势<img class="trend-btn-img" src="https://s1.ax1x.com/2020/10/26/BnY0t1.png" alt=""></div>' +
                            '<img  class="image-status" >' +
                            '<em class="status-span"></em>' +
                            '</div></div>' +
                            '<div id="coupon-wrap-qr" class="coupon-wrap-qr"><div class="qr-code-div">' +
                            '<div id="qrcode"></div><span class="title">获得返现只需三步~</br></br>①应用商店下载APP:花前省一省</br>②使用APP主页扫一扫功能扫左侧生成的商品码</br>③在APP上领券下单,确认收货后返现将进入app账户余额~</br><br>花前省一省--花钱之前,再省一省</span>' +
                            '<span class="foot" style="height:20px">支持IOS和安卓,各大应用市场均有下载</span>' +
                            '</div></div>' +
                            '<div id="coupon-wrap-trend" class="coupon-wrap-price"><div class="trend-div">' +
                            '<div id="chart"></div>' +
                            '</div></div>';
                    }
                    var ls = setInterval(function () {
                        if ($2(".coupon-wrap").length == 0) {
                            if (location.href.indexOf('//item.jd.com') > 0) {
                                if ($2(".summary-first").length > 0) {
                                    $2(".summary-first").after(couponArea);
                                }
                                else if ($2("#summary").length > 0) {
                                    $2("#summary").after(couponArea);
                                }
                                else if ($2("#pingou").length > 0) {
                                    $2("#pingou").after(couponArea);
                                }
                            } else if (location.href.indexOf('//item.jd.hk') > 0) {
                                if ($2(".summary-first").length > 0) {
                                    $2(".summary-first").after(couponArea);
                                }
                                else if ($2("#summary").length > 0) {
                                    $2("#summary").after(couponArea);

                                }
                                else if ($2("#summary-wrap").length > 0) {
                                    $2("#summary-wrap").after(couponArea);

                                }
                                else if ($2(".summary").length > 0) {
                                    $2(".summary").after(couponArea);

                                }
                            } else if (location.href.indexOf('//pcitem.jd.hk') > 0) {
                                if ($2(".summary").length > 0) {
                                    $2(".summary").after(couponArea);
                                }
                            } else {
                                $2("ul.tb-meta").after(couponArea);
                            }

                            $2(".coupon-wrap").eq(0).before(data.html);
                        }
                        else {
                            var qr_code_text = obj.DetailPageTB_or_TM_or_JD() + '//' + productId;
                            $2("#qrcode").qrcode({ width: 150, height: 150, text: qr_code_text });
                            $2("#a_click").click(function (event) {
                                $2("#coupon-wrap-trend").css("display", "none");
                                if ($2("#coupon-wrap-qr").css("display") == "block") {
                                    $2("#coupon-wrap-qr").css("display", "none");
                                } else {
                                    $2("#coupon-wrap-qr").css("display", "block");
                                }
                            });

                            obj.add_iframe();
                            chart = new ApexCharts(document.querySelector("#chart"), options);
                            chart.render();

                            clearInterval(ls);
                            return;
                        }
                    });

                    setInterval(function () {
                        if (location.href.indexOf('//item.jd.com')) {
                            if ($2("#summary-price").find("#jd-price").length > 0) {
                                price = $2("#summary-price").find("#jd-price").html().split("</span>")[1];
                                rm = Math.round(Math.floor((price - data_detail.couponmoney) * data_detail.return_money_rate * 1000) / 10) / 100;
                            } else if ($2(".p-price").find("span").eq(1).length > 0) {
                                price = $2(".p-price").find("span").eq(1).html();
                                if (price > 0 && price != "¥") {
                                    rm = Math.round(Math.floor((price - data_detail.couponmoney) * data_detail.return_money_rate * 1000) / 10) / 100;
                                }
                            }
                            if (price > 0) {
                                str = '返现约为:' + rm + '元'
                                $2("#rm_money").html(str);
                            }
                        } else {
                            price = $2(".p-price").find("span").eq(1).html();
                            if (price > 0) {
                                rm = Math.round(Math.floor((price - data_detail.couponmoney) * data_detail.return_money_rate * 1000) / 10) / 100;
                            }
                            str = '返现约为:' + rm + '元'
                            $2("#rm_money").html(str);
                        }
                    }, 500);

                }
            };
        } else if (obj.site_type() == "jingdong_lst_page") {
            var selectorList_jd = [];
            selectorList_jd.push(".gl-item");
            selectorList_jd.push(".sku-detail");
            obj.initSearchHtml(selectorList_jd);
            obj.initSearchEvent();
            obj.basicQuery_jd_list();
        } else if (obj.site_type() == "vip_list_page") {
            var selectorList_vip = [];

            // document.body.insertAdjacentHTML("afterbegin", injectHtml.settingPage);
            selectorList_vip.push(".c-goods-item");
            obj.initSearchHtml(selectorList_vip);
            obj.initSearchEvent();
            obj.basicQuery_jd_list();
        } else if (obj.site_type() == "vip_detail_page") {
            var price = 0;
            var rm = 0;
            var str = 0;
            //get data
            obj.get_data();
            if (stop == '1') {
                return;
            }
            var productId = location.href.split("-")[location.href.split("-").length - 1].split(".")[0];
            // alert(productId);
            var url =
                "https://www.youyizhineng.top/query_coupon/query_coupon.php?operate=quert_list_vip&itemid_list=" +
                productId;
            // console.log(url);
            obj.query_trend_data();
            var xhr = new XMLHttpRequest();//第一步:新建对象
            xhr.open('GET', url, true);//第二步:打开连接  将请求参数写在url中
            xhr.send();//第三步:发送请求  将请求参数写在URL中
            /**
             * 获取数据后的处理程序
             */
            xhr.onreadystatechange = function () {
                if (xhr.readyState == 4 && xhr.status == 200) {
                    var res = xhr.responseText;//获取到json字符串,解析
                    var data_tmp = JSON.parse(res);
                    var data = data_tmp[productId];
                    console.log(data);
                    var data_detail = data_tmp[productId];
                    if (data.couponmoney == 0) {
                        couponArea =
                            '<div class="coupon-wrap"><div class="stamp stamp04">' +
                            '<div class="par"><sub class="sign">¥</sub><span style="font-size:20px">暂无隐藏优惠券</span><p></p></div>' +
                            "<i></i></div></div>";
                    } else {
                        couponArea =
                            '<div class="coupon-wrap"><div class="stamp stamp04">' +
                            '<div class="par"><sub class="sign">¥</sub><span>' +
                            data.couponmoney +
                            "</span><p>" +
                            data.couponexplain +
                            "</p></div>" +
                            '<div class="copy">优惠券<p>' +
                            data.couponstarttime +
                            "<br>" +
                            data.couponendtime +
                            '</p><a href="' +
                            data.url1 +
                            '">直接领券</a></div>' +
                            "<i></i></div></div>";
                    }

                    if (data.return_money_rate == 0) {
                        couponArea =
                            couponArea +
                            '<div class="coupon-wrap-rm"><div class="rm-div">' +
                            '<span>暂无返现</span>' +
                            '<div class="rm-btn" id="a_click">其他功能</div>' +
                            '</div></div>' +
                            '<div class="coupon-wrap-rm"><div class="rm-div">' +
                            '<div class="trend-btn" id="trend_click">历史价格走势<img class="trend-btn-img" src="https://s1.ax1x.com/2020/10/26/BnY0t1.png" alt=""></div>' +
                            '<img class="image-status">' +
                            '<em class="status-span"></em>' +
                            '</div></div>' +
                            '<div id="coupon-wrap-qr" class="coupon-wrap-qr"><div class="qr-code-div">' +
                            '<img class="qr-img" src="https://s1.ax1x.com/2020/10/26/BnY7jS.png"></img>' +
                            '<span class="title">「花前省一省」是一款领券返现的APP,支持淘宝、天猫、京东、拼多多、唯品会等等主流平台~还有点外卖领券返现,电影票优惠购,全网vip视频免费看等功能,让您花钱之前,再省一省</span>' +
                            '<span class="foot" style="height:20px">扫码下载,支持IOS和安卓,也可在各大应用市场下载</span>' +
                            '</div></div>' +
                            '<div id="coupon-wrap-trend" class="coupon-wrap-price"><div class="trend-div">' +
                            '<div id="chart"></div>' +
                            '</div></div>';
                    } else {
                        couponArea =
                            couponArea +
                            '<div class="coupon-wrap-rm"><div class="rm-div" style="width:600px">' +
                            '<span id="rm_money">返现查询中...</span>' +
                            '<div class="rm-btn" id="a_click">点击领取返现</div>' +
                            '</div></div>' +
                            '<div class="coupon-wrap-rm"><div class="rm-div">' +
                            '<div class="trend-btn" id="trend_click">历史价格走势<img class="trend-btn-img" src="https://s1.ax1x.com/2020/10/26/BnY0t1.png" alt=""></div>' +
                            '<img  class="image-status" >' +
                            '<em class="status-span"></em>' +
                            '</div></div>' +
                            '<div id="coupon-wrap-qr" class="coupon-wrap-qr"><div class="qr-code-div">' +
                            '<div id="qrcode"></div><span class="title">获得返现只需三步~</br></br>①应用商店下载APP:花前省一省</br>②使用APP主页扫一扫功能扫左侧生成的商品码</br>③在APP上领券下单,确认收货后返现将进入app账户余额~</br><br>花前省一省--花钱之前,再省一省</span>' +
                            '<span class="foot" style="height:20px">支持IOS和安卓,各大应用市场均有下载</span>' +
                            '</div></div>' +
                            '<div id="coupon-wrap-trend" class="coupon-wrap-price"><div class="trend-div">' +
                            '<div id="chart"></div>' +
                            '</div></div>';
                    }
                    var ls = setInterval(function () {
                        console.log($2(".coupon-wrap").length);
                        if ($2(".coupon-wrap").length == 0) {
                            if ($2("#J-pi-price-box").length > 0) {
                                // alert(1);
                                $2("#J-pi-price-box").after(couponArea);
                            }

                            $2(".coupon-wrap").eq(0).before(data.html);

                            var qr_code_text = location.href + "/--/vipvip";
                            $2("#qrcode").qrcode({ width: 150, height: 150, text: qr_code_text });
                            $2("#a_click").click(function (event) {
                                $2("#coupon-wrap-trend").css("display", "none");
                                if ($2("#coupon-wrap-qr").css("display") == "block") {
                                    $2("#coupon-wrap-qr").css("display", "none");
                                } else {
                                    $2("#coupon-wrap-qr").css("display", "block");
                                }
                            });

                            obj.add_iframe();
                            chart = new ApexCharts(document.querySelector("#chart"), options);
                            chart.render();
                            if ($2("#rm_money").length > 0) {
                                $2("#rm_money").html("返现约为:" + Math.floor(data.return_money * 100) / 100 + "元");
                            }
                            clearInterval(ls);
                            return;

                        }
                    }, 500);
                }
            };
        }

        $2(document).ready(function () {
            if (obj.site_type() == "kaola_detail_page") {
                // alert(1);
                var price = 0;
                var rm = 0;
                var str = 0;
                //get data
                obj.get_data();
                if (stop == '1') {
                    return;
                }
                // alert(2);
                var productId = location.href.split("/product/")[1].split(".")[0];
                // alert(productId);
                var url =
                    "https://www.youyizhineng.top/query_coupon/query_coupon.php?operate=kaola_single&itemid_list=" +
                    productId;
                console.log(url);
                obj.query_trend_data();
                var xhr = new XMLHttpRequest();//第一步:新建对象
                xhr.open('GET', url, true);//第二步:打开连接  将请求参数写在url中
                xhr.send();//第三步:发送请求  将请求参数写在URL中
                /**
                 * 获取数据后的处理程序
                 */
                xhr.onreadystatechange = function () {
                    if (xhr.readyState == 4 && xhr.status == 200) {
                        var res = xhr.responseText;//获取到json字符串,解析
                        var data_tmp = JSON.parse(res);
                        var data = data_tmp[productId];
                        console.log(data);
                        var data_detail = data_tmp[productId];
                        if (data.couponmoney == 0) {
                            couponArea =
                                '<div class="coupon-wrap"><div class="stamp stamp04">' +
                                '<div class="par"><sub class="sign">¥</sub><span style="font-size:20px">暂无隐藏优惠券</span><p></p></div>' +
                                "<i></i></div></div>";
                        } else {
                            couponArea =
                                '<div class="coupon-wrap"><div class="stamp stamp04">' +
                                '<div class="par"><sub class="sign">¥</sub><span>' +
                                data.couponmoney +
                                "</span><p>" +
                                data.couponexplain +
                                "</p></div>" +
                                '<div class="copy">优惠券<p>' +
                                data.couponstarttime +
                                "<br>" +
                                data.couponendtime +
                                '</p><a href="' +
                                data.url1 +
                                '">直接领券</a></div>' +
                                "<i></i></div></div>";
                        }

                        if (data.return_money_rate == 0) {
                            couponArea =
                                couponArea +
                                '<div class="coupon-wrap-rm"><div class="rm-div">' +
                                '<span>暂无返现</span>' +
                                '<div class="rm-btn" id="a_click">其他功能</div>' +
                                '</div></div>' +
                                '<div class="coupon-wrap-rm"><div class="rm-div">' +
                                '<div class="trend-btn" id="trend_click">历史价格走势<img class="trend-btn-img" src="https://s1.ax1x.com/2020/10/26/BnY0t1.png" alt=""></div>' +
                                '<img class="image-status">' +
                                '<em class="status-span"></em>' +
                                '</div></div>' +
                                '<div id="coupon-wrap-qr" class="coupon-wrap-qr"><div class="qr-code-div">' +
                                '<img class="qr-img" src="https://s1.ax1x.com/2020/10/26/BnY7jS.png"></img>' +
                                '<span class="title">「花前省一省」是一款领券返现的APP,支持淘宝、天猫、京东、拼多多、唯品会等等主流平台~还有点外卖领券返现,电影票优惠购,全网vip视频免费看等功能,让您花钱之前,再省一省</span>' +
                                '<span class="foot" style="height:20px">扫码下载,支持IOS和安卓,也可在各大应用市场下载</span>' +
                                '</div></div>' +
                                '<div id="coupon-wrap-trend" class="coupon-wrap-price"><div class="trend-div">' +
                                '<div id="chart"></div>' +
                                '</div></div>';
                        } else {
                            couponArea =
                                couponArea +
                                '<div class="coupon-wrap-rm"><div class="rm-div" style="width:600px">' +
                                '<span id="rm_money">返现查询中...</span>' +
                                '<div class="rm-btn" id="a_click">点击领取返现</div>' +
                                '</div></div>' +
                                '<div class="coupon-wrap-rm"><div class="rm-div">' +
                                '<div class="trend-btn" id="trend_click">历史价格走势<img class="trend-btn-img" src="https://s1.ax1x.com/2020/10/26/BnY0t1.png" alt=""></div>' +
                                '<img  class="image-status" >' +
                                '<em class="status-span"></em>' +
                                '</div></div>' +
                                '<div id="coupon-wrap-qr" class="coupon-wrap-qr"><div class="qr-code-div">' +
                                '<div id="qrcode"></div><span class="title">获得返现只需三步~</br></br>①应用商店下载APP:花前省一省</br>②使用APP主页扫一扫功能扫左侧生成的商品码</br>③在APP上领券下单,确认收货后返现将进入app账户余额~</br>(    扫码暂不支持考拉海购,您可在APP内搜索商品下单获得返现)<br>花前省一省--花钱之前,再省一省</span>' +
                                '<span class="foot" style="height:20px">支持IOS和安卓,各大应用市场均有下载</span>' +
                                '</div></div>' +
                                '<div id="coupon-wrap-trend" class="coupon-wrap-price"><div class="trend-div">' +
                                '<div id="chart"></div>' +
                                '</div></div>';
                        }
                        var ls = setInterval(function () {
                            console.log($2(".m-price-wrap").length);
                            if ($2(".coupon-wrap").length == 0) {
                                if ($2(".m-price-wrap").length > 0) {
                                    // alert(1);
                                    $2(".m-price-wrap").after(couponArea);
                                }

                                $2(".coupon-wrap").eq(0).before(data.html);

                                var qr_code_text = location.href + "/--/kaola";
                                $2("#qrcode").qrcode({ width: 150, height: 150, text: qr_code_text });
                                $2("#a_click").click(function (event) {
                                    $2("#coupon-wrap-trend").css("display", "none");
                                    if ($2("#coupon-wrap-qr").css("display") == "block") {
                                        $2("#coupon-wrap-qr").css("display", "none");
                                    } else {
                                        $2("#coupon-wrap-qr").css("display", "block");
                                    }
                                });

                                obj.add_iframe();
                                chart = new ApexCharts(document.querySelector("#chart"), options);
                                chart.render();
                                if ($2("#rm_money").length > 0) {
                                    $2("#rm_money").html("返现约为:" + Math.floor(data.return_money * 100) / 100 + "元");
                                }
                                clearInterval(ls);
                                return;

                            }
                        }, 500);
                    }
                };
            }
            // else if (obj.site_type() == "suning_detail_page") {
            //     retur;
            //     // alert(1);
            //     var price = 0;
            //     var rm = 0;
            //     var str = 0;
            //     //get data
            //     obj.get_data();
            //     if (stop == '1') {
            //         return;
            //     }
            //     // alert(2);
            //     // var productId = location.href.split("/product/")[1].split(".")[0];
            //     var productId = '8243296';
            //     // alert(productId);
            //     var url =
            //         "https://www.youyizhineng.top/query_coupon/query_coupon.php?operate=kaola_single&itemid_list=" +
            //         productId;
            //     console.log(url);
            //     obj.query_trend_data();
            //     var xhr = new XMLHttpRequest();//第一步:新建对象
            //     xhr.open('GET', url, true);//第二步:打开连接  将请求参数写在url中
            //     xhr.send();//第三步:发送请求  将请求参数写在URL中
            //     /**
            //      * 获取数据后的处理程序
            //      */
            //     xhr.onreadystatechange = function () {
            //         if (xhr.readyState == 4 && xhr.status == 200) {
            //             var res = xhr.responseText;//获取到json字符串,解析
            //             var data_tmp = JSON.parse(res);
            //             var data = data_tmp[productId];
            //             console.log(data);
            //             var data_detail = data_tmp[productId];
            //             if (data.couponmoney == 0) {
            //                 couponArea =
            //                     '<div class="coupon-wrap"><div class="stamp stamp04">' +
            //                     '<div class="par"><sub class="sign">¥</sub><span style="font-size:20px">暂无隐藏优惠券</span><p></p></div>' +
            //                     "<i></i></div></div>";
            //             } else {
            //                 couponArea =
            //                     '<div class="coupon-wrap"><div class="stamp stamp04">' +
            //                     '<div class="par"><sub class="sign">¥</sub><span>' +
            //                     data.couponmoney +
            //                     "</span><p>" +
            //                     data.couponexplain +
            //                     "</p></div>" +
            //                     '<div class="copy">优惠券<p>' +
            //                     data.couponstarttime +
            //                     "<br>" +
            //                     data.couponendtime +
            //                     '</p><a href="' +
            //                     data.url1 +
            //                     '">直接领券</a></div>' +
            //                     "<i></i></div></div>";
            //             }

            //             if (data.return_money_rate == 0) {
            //                 couponArea =
            //                     couponArea +
            //                     '<div class="coupon-wrap-rm"><div class="rm-div">' +
            //                     '<span>暂无返现</span>' +
            //                     '<div class="rm-btn" id="a_click">其他功能</div>' +
            //                     '</div></div>' +
            //                     '<div class="coupon-wrap-rm"><div class="rm-div">' +
            //                     '<div class="trend-btn" id="trend_click">历史价格走势<img class="trend-btn-img" src="https://s1.ax1x.com/2020/10/26/BnY0t1.png" alt=""></div>' +
            //                     '<img class="image-status">' +
            //                     '<em class="status-span"></em>' +
            //                     '</div></div>' +
            //                     '<div id="coupon-wrap-qr" class="coupon-wrap-qr"><div class="qr-code-div">' +
            //                     '<img class="qr-img" src="https://s1.ax1x.com/2020/10/26/BnY7jS.png"></img>' +
            //                     '<span class="title">「花前省一省」是一款领券返现的APP,支持淘宝、天猫、京东、拼多多、唯品会等等主流平台~还有点外卖领券返现,电影票优惠购,全网vip视频免费看等功能,让您花钱之前,再省一省</span>' +
            //                     '<span class="foot" style="height:20px">扫码下载,支持IOS和安卓,也可在各大应用市场下载</span>' +
            //                     '</div></div>' +
            //                     '<div id="coupon-wrap-trend" class="coupon-wrap-price"><div class="trend-div">' +
            //                     '<div id="chart"></div>' +
            //                     '</div></div>';
            //             } else {
            //                 couponArea =
            //                     couponArea +
            //                     '<div class="coupon-wrap-rm"><div class="rm-div" style="width:600px">' +
            //                     '<span id="rm_money">返现查询中...</span>' +
            //                     '<div class="rm-btn" id="a_click">点击领取返现</div>' +
            //                     '</div></div>' +
            //                     '<div class="coupon-wrap-rm"><div class="rm-div">' +
            //                     '<div class="trend-btn" id="trend_click">历史价格走势<img class="trend-btn-img" src="https://s1.ax1x.com/2020/10/26/BnY0t1.png" alt=""></div>' +
            //                     '<img  class="image-status" >' +
            //                     '<em class="status-span"></em>' +
            //                     '</div></div>' +
            //                     '<div id="coupon-wrap-qr" class="coupon-wrap-qr"><div class="qr-code-div">' +
            //                     '<div id="qrcode"></div><span class="title">获得返现只需三步~</br></br>①应用商店下载APP:花前省一省</br>②使用APP主页扫一扫功能扫左侧生成的商品码</br>③在APP上领券下单,确认收货后返现将进入app账户余额~</br>(    扫码暂不支持考拉海购,您可在APP内搜索商品下单获得返现)<br>花前省一省--花钱之前,再省一省</span>' +
            //                     '<span class="foot" style="height:20px">支持IOS和安卓,各大应用市场均有下载</span>' +
            //                     '</div></div>' +
            //                     '<div id="coupon-wrap-trend" class="coupon-wrap-price"><div class="trend-div">' +
            //                     '<div id="chart"></div>' +
            //                     '</div></div>';
            //             }
            //             var ls = setInterval(function () {
            //                 console.log($2(".m-price-wrap").length);
            //                 if ($2(".coupon-wrap").length == 0) {
            //                     if ($2("#priceDom").length > 0) {
            //                         // alert(1);
            //                         $2("#priceDom").after(couponArea);
            //                     }

            //                     $2(".coupon-wrap").eq(0).before(data.html);

            //                     var qr_code_text = location.href + "/--/kaola";
            //                     $2("#qrcode").qrcode({ width: 150, height: 150, text: qr_code_text });
            //                     $2("#a_click").click(function (event) {
            //                         $2("#coupon-wrap-trend").css("display", "none");
            //                         if ($2("#coupon-wrap-qr").css("display") == "block") {
            //                             $2("#coupon-wrap-qr").css("display", "none");
            //                         } else {
            //                             $2("#coupon-wrap-qr").css("display", "block");
            //                         }
            //                     });

            //                     obj.add_iframe();
            //                     chart = new ApexCharts(document.querySelector("#chart"), options);
            //                     chart.render();
            //                     if ($2("#rm_money").length > 0) {
            //                         $2("#rm_money").html("返现约为:" + Math.floor(data.return_money * 100) / 100 + "元");
            //                     }
            //                     clearInterval(ls);
            //                     return;

            //                 }
            //             }, 500);
            //         }
            //     };
            // }
        });
    } else {
        // var $2 = $.noConflict(); // 第二个加载的jQuery对象变成了 $2

        var objj = {};
        var download = '0';
        var item_num = 0;
        var double_firstitem = 0;
        objj.site_type_fj = function () {
            var url = location.href;
            if (
                url.indexOf("://loan.fengwd.com/loan") > 0
            ) {
                return "projectDetailsPage";
            }
            else if (
                url.indexOf("//my.fengwd.com/account/record/fy") > 0
            ) {
                return "fy_record";
            }
            else if (
                url.indexOf("//my.fengwd.com/account/record") > 0
            ) {
                return "initialPage";
            }
            else if (
                url.indexOf("//my.fengwd.com/account/wd/investdetail") > 0
            ) {
                return "investdetail";
            }
            else if (
                url.indexOf("//loan.fengwd.com/zqdetail") > 0
            ) {
                return "zqdetail";
            }
            else if (
                url.indexOf("//loan.fengwd.com/reserve/detail") > 0
            ) {
                return "reserve_detail";
            }
            else if (
                url.indexOf("//my.fengwd.com/account/wd/group") > 0
            ) {
                return "wd_group_fy";
            }

        }

        objj.openBondDetails = function () {
            $2('[data-flag="zqdetail"]').click()
        }

        objj.clickOnTheCreditorsRightsDetails = function () {
            //获得债权明细总页数
            var total_page = $2(".page-bar").find(".next").eq(0).prev().html();
            for (let index = 0; index < total_page; index++) {


            }
        }




        objj.add_btn = function () {
            setInterval(function () {
                if ($2(".account-nav1").find("li").eq(0).attr("class") == "active") {
                    var length = $2("#loanRequest").find("tbody").find("tr").find(".fcjh-outbtn").length;
                    for (let index = 0; index < length; index++) {
                        var $this = $2("#loanRequest").find("tbody").find("tr").find(".fcjh-outbtn").eq(index);
                        var $this2 = $2("#loanRequest").find("tbody").find("tr").find(".tb-tit-td").eq(index);
                        if ($this.next().hasClass("add_btn") && $this2.find("a").next().hasClass("add_btn")) {
                            return;
                        } else {
                            $this.after('<span  class="split add_btn" style="cursor:pointer;color:blue">开始采集</span>');
                            $this2.find("a").after('<span class="original add_btn" style="cursor:pointer;color:blue">采</span>');
                        }
                    }
                }
                if ($2(".account-nav1").find("li").eq(1).attr("class") == "active") {
                    var length = $2("#loanRequest").find("tbody").find("tr").find(".tb-tit-td").length;
                    for (let index = 0; index < length; index++) {
                        var $this = $2("#loanRequest").find("tbody").find("tr").find(".tb-tit-td").eq(index);
                        if ($this.next().next().next().next().next().find("a").next().hasClass("add_btn") && $this.find("a").next().hasClass("add_btn")) {
                            return;
                        } else {
                            $this.next().next().next().next().next().find("a").after('<span class="split add_btn" style="cursor:pointer;color:blue">开始采集</span>');
                            $this.find("a").after('<span class="original add_btn" style="cursor:pointer;color:blue">采</span>');
                        }
                    }
                }

            }, 500);


            $2(".add_btn").live("click", function () {
                download = '0';
                var $this = $2(this);
                var class_type = $this.attr("class");
                console.log(class_type);
                if ($2(".account-nav1").find("li").eq(0).attr("class") == "active") {
                    var tmp0 = $this.parent().parent().find("td").eq(0).find("a").html();
                    var tmp1 = $this.parent().parent().find("td").eq(0).find("span").html();
                    var tmp2 = $this.parent().parent().find("td").eq(1).html();
                    var tmp3 = $this.parent().parent().find("td").eq(2).html();
                    var tmp4 = $this.parent().parent().find("td").eq(3).html();
                    var tmp5 = $this.parent().parent().find("td").eq(4).html();
                    var tmp6 = $this.parent().parent().find("td").eq(5).html();
                    var tmp7 = $this.parent().parent().find("td").eq(6).html();
                }

                if ($2(".account-nav1").find("li").eq(1).attr("class") == "active") {
                    var tmp0 = $this.parent().parent().find("td").eq(0).find("a").html();
                    var tmp1 = $this.parent().parent().find("td").eq(0).find("span").html();
                    var tmp2 = $this.parent().parent().find("td").eq(1).html();
                    var tmp3 = "--";
                    var tmp4 = "--";
                    var tmp5 = $this.parent().parent().find("td").eq(2).html();
                    var tmp6 = $this.parent().parent().find("td").eq(3).html();
                    var tmp7 = $this.parent().parent().find("td").eq(4).html();
                }
                var array_sheet;
                if (class_type == "split add_btn") {
                    array_sheet = [['投资产品', '投资日期', '投资金额', '持有资产', '待收收益', '年利率', '期限', '状态',
                        '购买成功', '开始计息', '还款周期', '产品结清', '拆分产品', '拆分金额', '拆分时间', '拆分后状态', '协议年化利率', '剩余期限', '后台编号',
                        '散标代码', '产品总期限', '认购规模', '产品起息日', '产品到期日', '借款人姓名', '身份证', '婚姻状况', '年龄', '学历', '手机号码', '性别', '月收入',
                        '公司行业', '工作城市', '岗位', '工作年限', '累计借款次数', '平台逾期次数', '征信情况', '累计借款金额', '平台逾期金额', '当前贷款余额', '负债信息', '还款来源']];
                } else {
                    array_sheet = [['投资产品', '投资日期', '投资金额', '持有资产', '待收收益', '年利率', '期限', '状态',
                        '开放购买日期', '产品起息日期', '锁定期满', '收回本息', '拆分产品', '拆分金额', '拆分时间', '拆分后状态', '协议年化利率', '剩余期限', '后台编号',
                        '散标代码', '产品总期限', '认购规模', '产品起息日', '产品到期日', '借款人姓名', '身份证', '婚姻状况', '年龄', '学历', '手机号码', '性别', '月收入',
                        '公司行业', '工作城市', '岗位', '工作年限', '累计借款次数', '平台逾期次数', '征信情况', '累计借款金额', '平台逾期金额', '当前贷款余额', '负债信息', '还款来源']];
                }
                array_sheet[1] = [tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7];
                GM_setValue('data_array', array_sheet);

                // var aaa = GM_getValue('data_array');
                // var sheet = XLSX.utils.aoa_to_sheet(aaa);
                // openDownloadDialog(sheet2blob(sheet), '导出.xlsx');

                GM_setValue('step', 'collecting');
                // console.log(GM_getValue('step'));

                if (class_type == "split add_btn") {
                    if ($2(".account-nav1").find("li").eq(0).attr("class") == "active") {
                        $this.prev().prev()[0].click();
                    }
                    if ($2(".account-nav1").find("li").eq(1).attr("class") == "active") {
                        $this.prev()[0].click();
                    }
                }
                else {
                    $this.prev()[0].click();
                }
            });
        }
        objj.exportExcel_listen = function () {
            var ls = setInterval(function () {
                var step = GM_getValue('step');
                console.log(step);
                if (step == "finish") {
                    if (download == '1') {
                        return;
                    } else {
                        var data_array = GM_getValue('data_array');
                        var sheet = XLSX.utils.aoa_to_sheet(data_array);
                        openDownloadDialog(sheet2blob(sheet), data_array[1][0] + '.xlsx');
                        location.reload();//刷新本页,避免点击查看又进入到采集
                        console.log(data_array);
                        download = '1';
                    }
                    // clearInterval(ls);
                }
            }, 2000);
        }
        objj.add_btn_fy = function () {
            setInterval(function () {
                //持有中active
                if ($2(".account-nav1").find("li").eq(0).attr("class") == "active") {
                    var length = $2("#loanRequest").find("tbody").find("tr").find(".tb-tit-td").length;
                    for (let index = 0; index < length; index++) {
                        var $this = $2("#loanRequest").find("tbody").find("tr").find(".tb-tit-td").eq(index);
                        if ($this.next().next().next().next().next().next().next().find("a").next().hasClass("add_btn") && $this.find("a").next().hasClass("add_btn")) {
                            return;
                        } else {
                            $this.next().next().next().next().next().next().next().find("a").after('<span class="split add_btn" style="cursor:pointer;color:blue">开始采集</span>');
                            $this.find("a").after('<span class="original add_btn" style="cursor:pointer;color:blue"></span>');
                        }
                    }

                }
                //已结束active
                if ($2(".account-nav1").find("li").eq(1).attr("class") == "active") {
                    var length = $2("#loanRequest").find("tbody").find("tr").find(".tb-tit-td").length;
                    for (let index = 0; index < length; index++) {
                        var $this = $2("#loanRequest").find("tbody").find("tr").find(".tb-tit-td").eq(index);
                        if ($this.next().next().next().next().next().find("a").next().hasClass("add_btn") && $this.find("a").next().hasClass("add_btn")) {
                            return;
                        } else {
                            $this.next().next().next().next().next().find("a").after('<span class="split add_btn" style="cursor:pointer;color:blue">开始采集</span>');
                            // $this.find("a").after('<span class="original add_btn" style="cursor:pointer;color:blue"></span>');
                        }
                    }
                }

            }, 500);


            $2(".add_btn").live("click", function () {
                download = '0';
                var $this = $2(this);
                var class_type = $this.attr("class");
                console.log(class_type);
                if ($2(".account-nav1").find("li").eq(0).attr("class") == "active") {
                    var tmp0 = $this.parent().parent().find("td").eq(0).find("a").html();
                    var tmp1 = $this.parent().parent().find("td").eq(0).find("span").html();
                    var tmp2 = $this.parent().parent().find("td").eq(1).html();
                    var tmp3 = $this.parent().parent().find("td").eq(2).html();
                    var tmp4 = $this.parent().parent().find("td").eq(3).html();
                    var tmp5 = $this.parent().parent().find("td").eq(4).html();
                    var tmp6 = $this.parent().parent().find("td").eq(5).html();
                    var tmp7 = $this.parent().parent().find("td").eq(6).html();
                }

                if ($2(".account-nav1").find("li").eq(1).attr("class") == "active") {
                    var tmp0 = $this.parent().parent().find("td").eq(0).find("a").html();
                    var tmp1 = $this.parent().parent().find("td").eq(0).find("span").html();
                    var tmp2 = $this.parent().parent().find("td").eq(1).html();
                    var tmp3 = "--";
                    var tmp4 = "--";
                    var tmp5 = $this.parent().parent().find("td").eq(2).html();
                    var tmp6 = $this.parent().parent().find("td").eq(3).html();
                    var tmp7 = $this.parent().parent().find("td").eq(4).html();
                }
                var array_sheet;
                if (class_type == "split add_btn") {
                    array_sheet = [['投资产品', '投资日期', '投资金额', '持有资产', '待收收益', '协议年利率', '期限', '状态',
                        '散标名称', '投资金额', '已到收益', '还款进度', '状态', '购买成功', '开始计息', '产品结清', '协议年化利率', '剩余期限', '后台编号',
                        '散标代码', '产品总期限', '认购规模', '产品起息日', '产品到期日', '借款人姓名', '身份证', '婚姻状况', '年龄', '学历', '手机号码', '性别', '月收入',
                        '公司行业', '工作城市', '岗位', '工作年限', '累计借款次数', '平台逾期次数', '征信情况', '累计借款金额', '平台逾期金额', '当前贷款余额', '负债信息', '还款来源']];
                } else {
                    array_sheet = [['投资产品', '投资日期', '投资金额', '持有资产', '待收收益', '年利率', '期限', '状态',
                        '开放购买日期', '产品起息日期', '锁定期满', '收回本息', '拆分产品', '拆分金额', '拆分时间', '拆分后状态', '协议年化利率', '剩余期限', '后台编号',
                        '散标代码', '产品总期限', '认购规模', '产品起息日', '产品到期日', '借款人姓名', '身份证', '婚姻状况', '年龄', '学历', '手机号码', '性别', '月收入',
                        '公司行业', '工作城市', '岗位', '工作年限', '累计借款次数', '平台逾期次数', '征信情况', '累计借款金额', '平台逾期金额', '当前贷款余额', '负债信息', '还款来源']];
                }
                array_sheet[1] = [tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7];
                GM_setValue('data_array', array_sheet);

                GM_setValue('step', 'collecting');

                if (class_type == "split add_btn") {
                    if ($2(".account-nav1").find("li").eq(0).attr("class") == "active") {
                        $this.prev()[0].click();
                    }
                    if ($2(".account-nav1").find("li").eq(1).attr("class") == "active") {
                        $this.prev()[0].click();
                    }
                }
                else {
                    $this.prev()[0].click();
                }
            });
        }
        objj.collectInformation = function () {

            var data_array = GM_getValue('data_array');
            var length = data_array.length;
            if (objj.site_type_fj() == "initialPage") {

            } else if (objj.site_type_fj() == "wd_group_fy") {

                // console.log(data_array);
                // if (GM_getValue('recode_type') == '') {
                //     if (length > 0) {
                //         var tmp0 = $2(".state-list").find(".detail").eq(0).find("span").eq(1).html();
                //         var tmp1 = $2(".state-list").find(".detail").eq(1).find("span").eq(1).html();
                //         var tmp2 = $2(".state-list").find(".detail").eq(2).find("span").eq(1).html();
                //         var tmp3 = $2(".state-list").find(".detail").eq(3).find("span").eq(1).html();
                //         data_array[length - 1] = data_array[length - 1].concat([tmp0, tmp1, tmp2, tmp3]);
                //         GM_setValue('data_array', data_array);
                //         console.log(GM_getValue('data_array'));
                //     }
                // } 

                // if(GM_getValue('recode_type') == 'fy'){

                // }
            } else if (objj.site_type_fj() == "investdetail") {

                console.log(data_array);
                if (GM_getValue('recode_type') == '') {
                    if (length > 0) {
                        var tmp0 = $2(".state-list").find(".detail").eq(0).find("span").eq(1).html();
                        var tmp1 = $2(".state-list").find(".detail").eq(1).find("span").eq(1).html();
                        var tmp2 = $2(".state-list").find(".detail").eq(2).find("span").eq(1).html();
                        var tmp3 = $2(".state-list").find(".detail").eq(3).find("span").eq(1).html();
                        data_array[length - 1] = data_array[length - 1].concat([tmp0, tmp1, tmp2, tmp3]);
                        GM_setValue('data_array', data_array);
                        console.log(GM_getValue('data_array'));
                    }
                }

                if (GM_getValue('recode_type') == 'fy') {

                }
            } else if (objj.site_type_fj() == "reserve_detail") {
                if (length > 0) {
                    var tmp0 = $2(".animated.val.now").html();
                    var tmp1 = $2(".animated.val.settled").html();
                    var tmp2 = $2(".animated.val.lock").html();
                    var tmp3 = $2(".animated.val.due").html();
                    data_array[length - 1] = data_array[length - 1].concat([tmp0, tmp1, tmp2, tmp3]);
                    GM_setValue('data_array', data_array);
                    console.log(GM_getValue('data_array'));
                }
            } else if (objj.site_type_fj() == "zqdetail") {
                if (length > 0) {
                    var tmp0 = $2(".content").find("tbody").find("td").eq(1).find("span").eq(0).html() + $2(".content").find("tbody").find("td").eq(1).find("span").eq(1).html();
                    var tmp1 = $2(".content").find("tbody").find("td").eq(2).find("span").eq(0).html() + $2(".content").find("tbody").find("td").eq(2).find("span").eq(1).html();
                    // var bg_no = $2(".zqdetail-wrapper").find(".panel").find(".title").find("a").attr('href').toString().replace('https://loan.fengwd.com/loan/', '');
                    data_array[length - 1] = data_array[length - 1].concat([tmp0, tmp1]);
                    GM_setValue('data_array', data_array);
                    console.log(GM_getValue('data_array'));
                }
            }
            else if (objj.site_type_fj() == "projectDetailsPage") {
                if (length > 0) {
                    var bg_no = location.href.split("/loan/")[1];
                    var annualAgreement = $2(".column.fst").find("span").eq(0).text() + $2(".column.fst").find("span").eq(1).text();
                    var zqx = $2(".loan-info").find(".flt-cont.clearfix").find("div").eq(1).find("span.val").html() + $2(".loan-info").find(".flt-cont.clearfix").find("div").eq(1).find("span.unit").html();
                    var loan_sum = $2(".tabpanel").find("tbody").eq(0).find("tr").eq(6).find(".col2").html();
                    var loname = $2(".loname").html();
                    var date_begin = $2(".tabpanel").find("tbody").eq(0).find("tr").eq(3).find(".col2").html();
                    var date_end = $2(".tabpanel").find("tbody").eq(0).find("tr").eq(4).find(".col2").html();
                    var tmp0 = $2(".infolist.clearfix").eq(0).find(".flo.inle").find("p").eq(0).text().replace('借款人姓名', '');
                    var tmp1 = $2(".infolist.clearfix").eq(0).find(".flo.inle").find("p").eq(1).text().replace('身份证号码', '');
                    var tmp2 = $2(".infolist.clearfix").eq(0).find(".flo.inle").find("p").eq(2).text().replace('婚姻状况', '');

                    var tmp3 = $2(".infolist.clearfix").eq(0).find(".flo.inmi").find("p").eq(0).text().replace('年龄', '');
                    var tmp4 = $2(".infolist.clearfix").eq(0).find(".flo.inmi").find("p").eq(1).text().replace('学历', '');

                    var tmp5 = $2(".infolist.clearfix").eq(0).find(".flo.inri").find("p").eq(0).text().replace('手机号码', '');
                    var tmp6 = $2(".infolist.clearfix").eq(0).find(".flo.inri").find("p").eq(1).text().replace('性别', '');


                    var tmp7 = $2(".infolist.clearfix").eq(1).find(".flo.inle").find("p").eq(0).text().replace('个人月收入', '');
                    var tmp8 = $2(".infolist.clearfix").eq(1).find(".flo.inle").find("p").eq(1).text().replace('公司行业', '');

                    var tmp9 = $2(".infolist.clearfix").eq(1).find(".flo.inmi").find("p").eq(0).text().replace('工作城市', '');
                    var tmp10 = $2(".infolist.clearfix").eq(1).find(".flo.inmi").find("p").eq(1).text().replace('岗位/职务', '');

                    var tmp11 = $2(".infolist.clearfix").eq(1).find(".flo.inri").find("p").eq(0).text().replace('工作年限', '');


                    var tmp12 = $2(".infolist.clearfix").eq(3).find(".flo.inle").find("p").eq(0).text().replace('累计借款次数', '');
                    var tmp13 = $2(".infolist.clearfix").eq(3).find(".flo.inle").find("p").eq(1).text().replace('平台逾期次数', '');
                    var tmp14 = $2(".infolist.clearfix").eq(3).find(".flo.inle").find("p").eq(2).text().replace('借款前6个月内征信报告中的逾期情况', '');

                    var tmp15 = $2(".infolist.clearfix").eq(3).find(".flo.inmi").find("p").eq(0).text().replace('累计借款金额', '');
                    var tmp16 = $2(".infolist.clearfix").eq(3).find(".flo.inmi").find("p").eq(1).text().replace('平台逾期金额', '');

                    var tmp17 = $2(".infolist.clearfix").eq(3).find(".flo.inri").find("p").eq(0).text().replace('当前贷款余额', '');
                    var tmp18 = $2(".infolist.clearfix").eq(3).find(".flo.inri").find("p").eq(1).text().replace('负债信息', '');
                    var source_of_repayment = $2(".info-other").find("p").eq(2).text();


                    console.log("projectDetailsPage");
                    console.log(data_array);
                    var befor_length = 18;
                    var current_length = data_array[length - 1].length;

                    //不等于18,补齐18,保证后面的数据对齐,这个数值befor_length随前面采集的数据个数改变,如果上个页面多采集了,记得这里要改。
                    if (data_array[length - 1].length != befor_length) {
                        for (let index = 0; index < befor_length - current_length; index++) {
                            data_array[length - 1] = data_array[length - 1].concat('--');
                        }
                    }

                    if (data_array[length - 1][16] == "--") {
                        data_array[length - 1][16] = annualAgreement;
                    }
                    data_array[length - 1] = data_array[length - 1].concat([bg_no, loname, zqx, loan_sum, date_begin, date_end, tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7, tmp8, tmp9, tmp10, tmp11, tmp12, tmp13, tmp14, tmp15, tmp16, tmp17, tmp18, source_of_repayment]);
                    GM_setValue('data_array', data_array);
                    console.log(GM_getValue('data_array'));
                }
            }
        }

        objj.traverseClaims = function () {
            if (objj.site_type_fj() == "investdetail") {
                setInterval(function () {
                    var single_recode = GM_getValue('single_recode');
                    var total_page_length = $2(".ret-detail.zqdetail").find("tbody").find("a").length;
                    console.log(total_page_length);
                    console.log(item_num);
                    console.log(single_recode);
                    if (total_page_length == 0) {
                        return;
                    }
                    else if (single_recode == 'finish' || single_recode == '') {
                        if (total_page_length == item_num) {
                            //判断有无next,有则点击
                            if ($2(".btn-page.next").length > 0) {
                                $2(".btn-page.next").click();
                                double_firstitem = 1;
                                item_num = 0;
                            } else {
                                GM_setValue('step', 'finish');
                                objj.close();
                            }
                        }
                        else {
                            //记录标信息

                            var data_array = GM_getValue('data_array');
                            var length = data_array.length;

                            if (length > 0) {
                                var tmp0 = $2(".ret-detail.zqdetail").find("tbody").find("tr").eq(item_num).find("td").eq(0).find("a").html();
                                var tmp1 = $2(".ret-detail.zqdetail").find("tbody").find("tr").eq(item_num).find("td").eq(1).html();
                                var tmp2 = $2(".ret-detail.zqdetail").find("tbody").find("tr").eq(item_num).find("td").eq(2).html();
                                var tmp3 = $2(".ret-detail.zqdetail").find("tbody").find("tr").eq(item_num).find("td").eq(3).html();
                                if (item_num == 0 && double_firstitem == 2) {
                                    data_array[length - 1] = ['', '', '', '', '', '', '', '', '', '', '', '', tmp0, tmp1, tmp2, tmp3];
                                    double_firstitem = 0;
                                }
                                else {
                                    data_array[length] = ['', '', '', '', '', '', '', '', '', '', '', '', tmp0, tmp1, tmp2, tmp3];
                                }

                                GM_setValue('data_array', data_array);
                                console.log(GM_getValue('data_array'));
                            }
                            //打开标
                            GM_setValue('single_recode', 'recoding');
                            $2(".ret-detail.zqdetail").find("tbody").find("tr").eq(item_num).find("a")[0].click();
                            // item_num == 0, need to do this 1 more time (because page ready is delay 1 time)
                            if (item_num == 0 && double_firstitem == 1) {
                                //item_num = item_num;
                                double_firstitem = 2;
                            }
                            else {
                                item_num = item_num + 1;
                            }
                        }
                    }
                }, 500);
            }

            if (objj.site_type_fj() == "reserve_detail") {
                setInterval(function () {
                    var single_recode = GM_getValue('single_recode');
                    var total_page_length = $2(".zq-list.clearfix").find("tbody").find("a").length;
                    console.log(total_page_length);
                    console.log(item_num);
                    console.log(single_recode);
                    if (total_page_length == 0) {
                        return;
                    }
                    else if (single_recode == 'finish' || single_recode == '') {
                        if (total_page_length == item_num) {
                            //判断有无next,有则点击
                            if ($2(".btn-page.next").length > 0) {
                                $2(".btn-page.next").click();
                                double_firstitem = 1;
                                item_num = 0;
                            } else {
                                GM_setValue('step', 'finish');
                                objj.close();
                            }
                        }
                        else {
                            //记录标信息

                            var data_array = GM_getValue('data_array');
                            var length = data_array.length;

                            if (length > 0) {
                                var tmp0 = $2(".zq-list.clearfix").find("tbody").find("tr").eq(item_num).find("td").eq(0).html();
                                var tmp1 = $2(".zq-list.clearfix").find("tbody").find("tr").eq(item_num).find("td").eq(1).html();
                                var tmp2 = $2(".zq-list.clearfix").find("tbody").find("tr").eq(item_num).find("td").eq(2).html();
                                // var tmp3 = $2(".zq-list.clearfix").find("tbody").find("tr").eq(item_num).find("td").eq(3).html();
                                if (item_num == 0 && double_firstitem == 2) {
                                    data_array[length - 1] = ['', '', '', '', '', '', '', '', '', '', '', '', tmp0, tmp1, tmp2, ''];
                                    double_firstitem = 0;
                                }
                                else {
                                    data_array[length] = ['', '', '', '', '', '', '', '', '', '', '', '', tmp0, tmp1, tmp2, ''];
                                }

                                GM_setValue('data_array', data_array);
                                console.log(GM_getValue('data_array'));
                            }
                            //打开标
                            GM_setValue('single_recode', 'recoding');
                            $2(".zq-list.clearfix").find("tbody").find("tr").eq(item_num).find("a")[0].click();
                            // item_num == 0, need to do this 1 more time (because page ready is delay 1 time)
                            if (item_num == 0 && double_firstitem == 1) {
                                //item_num = item_num;
                                double_firstitem = 2;
                            }
                            else {
                                item_num = item_num + 1;
                            }
                        }
                    }
                }, 500);
            }
        }
        objj.traverseClaims_fy = function () {
            // alert("traverseClaims_fy");
            if (objj.site_type_fj() == "wd_group_fy") {
                setInterval(function () {
                    var single_recode = GM_getValue('single_recode');
                    var total_page_length = $2(".normal-link").length;
                    // alert(total_page_length);
                    console.log(item_num);
                    console.log(single_recode);
                    if (total_page_length == 0) {
                        return;
                    }
                    else if (single_recode == 'finish' || single_recode == '') {
                        if (total_page_length == item_num) {
                            //判断有无next,有则点击
                            if ($2(".btn-page.next").length > 0) {
                                $2(".btn-page.next").click();
                                double_firstitem = 1;
                                item_num = 0;
                            } else {
                                GM_setValue('step', 'finish');
                                objj.close();
                            }
                        }
                        else {
                            //记录标信息

                            var data_array = GM_getValue('data_array');
                            var length = data_array.length;

                            if (length > 0) {
                                var tmp0 = $2(".list.tablecon1").find("tbody").find("tr").eq(item_num).find("td").eq(0).find("a").html();
                                var tmp1 = $2(".list.tablecon1").find("tbody").find("tr").eq(item_num).find("td").eq(1).html();
                                var tmp2 = $2(".list.tablecon1").find("tbody").find("tr").eq(item_num).find("td").eq(2).html();
                                var tmp3 = $2(".list.tablecon1").find("tbody").find("tr").eq(item_num).find("td").eq(3).html();
                                var tmp4 = $2(".list.tablecon1").find("tbody").find("tr").eq(item_num).find("td").eq(4).html();

                                if (item_num == 0 && double_firstitem == 2) {
                                    data_array[length - 1] = ['', '', '', '', '', '', '', '', tmp0, tmp1, tmp2, tmp3, tmp4];
                                    double_firstitem = 0;
                                }
                                else {
                                    data_array[length] = ['', '', '', '', '', '', '', '', tmp0, tmp1, tmp2, tmp3, tmp4];
                                }

                                GM_setValue('data_array', data_array);
                                console.log(GM_getValue('data_array'));
                            }
                            //打开标
                            GM_setValue('single_recode', 'recoding');
                            window.open($2(".list.tablecon1").find("tbody").find("tr").eq(item_num).find("a").eq(1).attr("href"));
                            if (item_num == 0 && double_firstitem == 1) {
                                //item_num = item_num;
                                double_firstitem = 2;
                            }
                            else {
                                item_num = item_num + 1;
                            }
                        }
                    }
                }, 500);
            }
        }

        objj.close = function () {
            window.close();
        }

        function openDownloadDialog(url, saveName) {
            if (typeof url == 'object' && url instanceof Blob) {
                url = URL.createObjectURL(url); // 创建blob地址
            }
            var aLink = document.createElement('a');
            aLink.href = url;
            aLink.download = saveName || ''; // HTML5新增的属性,指定保存文件名,可以不要后缀,注意,file:///模式下不会生效
            var event;
            if (window.MouseEvent) event = new MouseEvent('click');
            else {
                event = document.createEvent('MouseEvents');
                event.initMouseEvent('click', true, false, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
            }
            aLink.dispatchEvent(event);
        }

        // 将一个sheet转成最终的excel文件的blob对象,然后利用URL.createObjectURL下载
        function sheet2blob(sheet, sheetName) {
            sheetName = sheetName || 'sheet1';
            var workbook = {
                SheetNames: [sheetName],
                Sheets: {}
            };
            workbook.Sheets[sheetName] = sheet;
            // 生成excel的配置项
            var wopts = {
                bookType: 'xlsx', // 要生成的文件类型
                bookSST: false, // 是否生成Shared String Table,官方解释是,如果开启生成速度会下降,但在低版本IOS设备上有更好的兼容性
                type: 'binary'
            };
            var wbout = XLSX.write(workbook, wopts);
            var blob = new Blob([s2ab(wbout)], { type: "application/octet-stream" });
            // 字符串转ArrayBuffer
            function s2ab(s) {
                var buf = new ArrayBuffer(s.length);
                var view = new Uint8Array(buf);
                for (var i = 0; i != s.length; ++i) view[i] = s.charCodeAt(i) & 0xFF;
                return buf;
            }
            return blob;
        }

        $2(document).ready(function () {
            if (objj.site_type_fj() == "initialPage") {

                GM_setValue('recode_type', '');
                GM_setValue('step', '');
                GM_setValue('data_array', '');

                objj.add_btn();
                objj.exportExcel_listen();

            } else if (objj.site_type_fj() == "investdetail") {
                if (GM_getValue('step') == '') {
                    return;
                }
                if (GM_getValue('recode_type') == '') {
                    //采集信息
                    objj.collectInformation();
                    //点击债权明细
                    $2('[data-type="detaillist"]').click();
                    //遍历每一个债权
                    GM_setValue('single_recode', '');
                    objj.traverseClaims();
                }

                if (GM_getValue('recode_type') == 'fy') {
                    //采集信息
                    objj.collectInformation();
                    //点击散标名称
                    $2(".link")[0].click();

                    //关闭自身
                    objj.close();
                }
            } else if (objj.site_type_fj() == "reserve_detail") {
                if (GM_getValue('step') == '') {
                    return;
                }
                //采集信息
                objj.collectInformation();
                //点击债权明细
                $2('[data-flag="zqdetail"]').click();
                //遍历每一个债权
                GM_setValue('single_recode', '');
                objj.traverseClaims();
            } else if (objj.site_type_fj() == "zqdetail") {
                if (GM_getValue('step') == '') {
                    return;
                }
                //采集信息
                objj.collectInformation();
                //点击原产品详情
                $2(".col-light").next()[0].click();
                //关闭自身
                objj.close();
            } else if (objj.site_type_fj() == "projectDetailsPage") {
                if (GM_getValue('step') == '') {
                    return;
                }
                //点击借款方信息
                $2('[data-flag="invest"]').prev().click();
                //采集信息
                objj.collectInformation();
                //关闭自身
                GM_setValue('single_recode', 'finish');
                objj.close();
            } else if (objj.site_type_fj() == "fy_record") {
                GM_setValue('step', '');
                GM_setValue('data_array', '');
                objj.add_btn_fy();
                objj.exportExcel_listen();

            } else if (objj.site_type_fj() == "wd_group_fy") {
                if (GM_getValue('step') == '') {
                    return;
                }
                //采集信息
                objj.collectInformation();
                GM_setValue('recode_type', 'fy');
                GM_setValue('single_recode', '');
                //遍历每一个散标
                objj.traverseClaims_fy();
            }
        });

    }
})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址