// ==UserScript== // @name 抖音小店订单管理4.5 // @version 4.5 // @author 大师兄 476116973@qq.com // @namespace https://greasyfork.org/zh-CN/users/724782-caogen1207 // @match *://fxg.jinritemai.com/ffa/morder/order/list // @date 05/27/2021 // @description 方便抖音订单查看,必须要打开抖音小店的订单管理界面,才能显示 // @icon https://mms0.baidu.com/it/u=685985501,228922170&fm=27&gp=0.jpg&fmt=auto // @run-at document-idle // @note 2.5 @updateURL/@installURL/@downloadURL https://greasyfork.org/zh-CN/scripts/431480 // @require https://code.jquery.com/jquery-3.6.0.min.js // @require https://cdn.staticfile.org/datatables/1.10.9/js/jquery.dataTables.min.js // @resource dashixiongCSS https://gitee.com/da-shixiong/ajax/raw/master/hs/dataTables/min.css // @grant GM_addStyle // @grant GM_getResourceText // @grant GM_getValue // @grant GM_setValue // @grant GM_deleteValue // @downloadURL none // ==/UserScript== (function() { "use strict"; GM_addStyle(GM_getResourceText("dashixiongCSS")); var dsx = { AC_addStyle:function (css, className, addToTarget, isReload, initType) { // 添加CSS代码,不考虑文本载入时间,只执行一次-无论成功与否,带有className RAFInterval(function () { /** * addToTarget这里不要使用head标签,head标签的css会在html载入时加载, * html加载后似乎不会再次加载,body会自动加载 * **/ let addTo = document.querySelector(addToTarget); if (typeof (addToTarget) === "undefined") addTo = (document.head || document.body || document.documentElement); isReload = isReload || false; // 默认是非加载型 initType = initType || "text/css"; // 如果没有目标节点(则直接加) || 有目标节点且找到了节点(进行新增) if (typeof (addToTarget) === "undefined" || (typeof (addToTarget) != "undefined" && document.querySelector(addToTarget) != null)) { // clearInterval(tout); // 如果true 强行覆盖,不管有没有--先删除 // 如果false,不覆盖,但是如果有的话,要退出,不存在则新增--无需删除 if (isReload === true) { safeRemove("." + className); } else if (isReload === false && document.querySelector("." + className) != null) { // 节点存在 && 不准备覆盖 return true; } let cssNode = document.createElement("style"); if (className != null) cssNode.className = className; cssNode.setAttribute("type", initType); cssNode.innerHTML = css; try { addTo.appendChild(cssNode); } catch (e) { console.log(e.message); } return true; } }, 20, true); }, formatDate: function(data) { //时间戳转格式 let timestamp = new Date(data * 1000); let year = timestamp.getFullYear(); let month = timestamp.getMonth() + 1; let date = timestamp.getDate(); let hour = timestamp.getHours(); let minute = timestamp.getMinutes(); let second = timestamp.getSeconds(); return (year + "-" + th(month) + "-" + th(date) + " " + th(hour) + ":" + th(minute) + ":" + th(second)); function th(num) { return num < 10 ? "0" + num : num; } }, Toast: function(msg, duration) { duration = isNaN(duration) ? 3000 : duration; let m = document.createElement('div'); m.innerHTML = msg; m.style.cssText = "max-width:60%;min-width: 150px;padding:0 14px;height: 40px;color: rgb(255, 255, 255);line-height: 40px;text-align: center;border-radius: 4px;position: fixed;top: 50%;left: 50%;transform: translate(-50%, -50%);z-index: 999999999999999;background: rgba(0, 0, 0,.7);font-size: 16px;"; document.body.appendChild(m); setTimeout(function() { let d = 0.5; m.style.webkitTransition = '-webkit-transform ' + d + 's ease-in, opacity ' + d + 's ease-in'; m.style.opacity = '0'; setTimeout(function() { document.body.removeChild(m) },d * 1000); },duration); }, movedom: function(domstr){ $(domstr).mousemove(function(e){ $(domstr).unbind("mousedown"); $(domstr).css("cursor","default"); //$("span > b").text(parseInt($("div").width())); var left = $(domstr).offset().left - $(document).scrollLeft(); var top = $(domstr).offset().top - $(document).scrollTop(); // 如果鼠标在中间 if(e.clientX - left > 10 && e.clientX-left < parseInt($(domstr).width()) - 10 && e.clientY - top > 10 && e.clientY-top < 60) { $(domstr).css("cursor","move"); $(domstr).mousedown(function(e) { var ismove = true; var x = e.pageX - $(domstr).offset().left + $(document).scrollLeft(); var y = e.pageY - $(domstr).offset().top + $(document).scrollTop(); $(document).mousemove(function(e) { if(ismove) { $(domstr).css({"left":e.pageX - x, "top":e.pageY - y}); } }).mouseup(function() { ismove = false; }); }); } //如果鼠标在左上角 if(e.clientX - left < 10 && e.clientY - top < 10) { $(domstr).css("cursor","nw-resize"); $(domstr).mousedown(function(e) { var ismove = true; var y = e.pageY - $(domstr).offset().top + $(document).scrollTop(); var h = e.pageY + parseInt($(domstr).css("height")); $(document).mousemove(function(e) { if(ismove) { $(domstr).css({"height":h - e.pageY, "top":e.pageY - y}); } }).mouseup(function() { ismove = false; }); }); $(domstr).mousedown(function(e) { var ismove = true; var x = e.pageX - $(domstr).offset().left + $(document).scrollLeft(); var w = e.pageX + parseInt($(domstr).css("width")); $(document).mousemove(function(e) { if(ismove) { $(domstr).css({"width":w - e.pageX, "left":e.pageX - x}); } }).mouseup(function() { ismove = false; }); }); }; //如果鼠标在上 if(e.clientY - top < 10 && e.clientX - left > 10 && e.clientX-left < parseInt($(domstr).width()) - 10) { $(domstr).css("cursor","n-resize"); $(domstr).mousedown(function(e) { var ismove = true; var y = e.pageY - $(domstr).offset().top + $(document).scrollTop(); var h = e.pageY + parseInt($(domstr).css("height")); $(document).mousemove(function(e) { if(ismove) { $(domstr).css({"height":h - e.pageY, "top":e.pageY - y}); } }).mouseup(function() { ismove = false; }); }); }; //如果鼠标在右上角 if(e.clientY - top < 10 && e.clientX-left > parseInt($(domstr).width()) - 10) { $(domstr).css("cursor","ne-resize"); $(domstr).mousedown(function(e) { var ismove = true; var y = e.pageY - $(domstr).offset().top + $(document).scrollTop(); var h = e.pageY + parseInt($(domstr).css("height")); $(document).mousemove(function(e) { if(ismove) { $(domstr).css({"height":h - e.pageY, "top":e.pageY - y}); } }).mouseup(function() { ismove = false; }); }); $(domstr).mousedown(function(e) { var ismove = true; var x = e.pageX - $(domstr).offset().left + $(document).scrollLeft(); var w = e.pageX - parseInt($(domstr).css("width")); $(document).mousemove(function(e) { if(ismove) { $(domstr).css({"width":e.pageX - w}); } }).mouseup(function() { ismove = false; }); }); }; //如果鼠标在右 if(e.clientX-left > parseInt($(domstr).width()) - 10 && e.clientY - top > 10 && e.clientY-top < parseInt($(domstr).height()) - 10) { $(domstr).css("cursor","e-resize"); $(domstr).mousedown(function(e) { var ismove = true; var x = e.pageX - $(domstr).offset().left + $(document).scrollLeft(); var w = e.pageX - parseInt($(domstr).css("width")); $(document).mousemove(function(e) { if(ismove) { $(domstr).css({"width":e.pageX - w}); } }).mouseup(function() { ismove = false; }); }); }; //如果鼠标在右下 if(e.clientX-left > parseInt($(domstr).width()) - 10 && e.clientY-top > parseInt($(domstr).height()) - 10) { $(domstr).css("cursor","se-resize"); $(domstr).mousedown(function(e) { var ismove = true; var x = e.pageX - $(domstr).offset().left + $(document).scrollLeft(); var w = e.pageX - parseInt($(domstr).css("width")); $(document).mousemove(function(e) { if(ismove) { $(domstr).css({"width":e.pageX - w}); } }).mouseup(function() { ismove = false; }); }); $(domstr).mousedown(function(e) { var ismove = true; var y = e.pageY - $(domstr).offset().top + $(document).scrollTop(); var h = e.pageY - parseInt($(domstr).css("height")); $(document).mousemove(function(e) { if(ismove) { $(domstr).css({"height":e.pageY - h}); } }).mouseup(function() { ismove = false; }); }); }; //如果鼠标在下 if(e.clientY-top > parseInt($(domstr).height()) - 10 && e.clientX - left > 10 && e.clientX-left < parseInt($(domstr).width()) - 10) { $(domstr).css("cursor","s-resize"); $(domstr).mousedown(function(e) { var ismove = true; var y = e.pageY - $(domstr).offset().top + $(document).scrollTop(); var h = e.pageY - parseInt($(domstr).css("height")); $(document).mousemove(function(e) { if(ismove) { $(domstr).css({"height":e.pageY - h}); } }).mouseup(function() { ismove = false; }); }); }; //如果鼠标在左下 if(e.clientY-top > parseInt($(domstr).height()) - 10 && e.clientX - left < 10) { $(domstr).css("cursor","sw-resize"); $(domstr).mousedown(function(e) { var ismove = true; var x = e.pageX - $(domstr).offset().left + $(document).scrollLeft(); var w = e.pageX + parseInt($(domstr).css("width")); $(document).mousemove(function(e) { if(ismove) { $(domstr).css({"width":w - e.pageX, "left":e.pageX - x}); } }).mouseup(function() { ismove = false; }); }); $(domstr).mousedown(function(e) { var ismove = true; var y = e.pageY - $(domstr).offset().top + $(document).scrollTop(); var h = e.pageY - parseInt($(domstr).css("height")); $(document).mousemove(function(e) { if(ismove) { $(domstr).css({"height":e.pageY - h}); } }).mouseup(function() { ismove = false; }); }); }; //如果鼠标在左 if(e.clientX - left < 10 && e.clientY - top > 10 && e.clientY-top < parseInt($(domstr).height()) - 10) { $(domstr).css("cursor","w-resize"); $(domstr).mousedown(function(e) { var ismove = true; var x = e.pageX - $(domstr).offset().left + $(document).scrollLeft(); var w = e.pageX + parseInt($(domstr).css("width")); $(document).mousemove(function(e) { if(ismove) { $(domstr).css({"width":w - e.pageX, "left":e.pageX - x}); } }).mouseup(function() { ismove = false; }); }); } }); }, tianjiawangluojianting:function (callback) { window.addEventListener('ajaxReadyStateChange', function(e){ //console.log(e.detail, e.detail._byted_method, e.detail.responseURL, e.detail.responseText, e.detail._data); // XMLHttpRequest Object if(e.detail.readyState == 4 && e.detail.status >= 200 && e.detail.status < 300){ callback(e); } }); }, panduanshuju:function(e){ if(e.detail.responseURL.indexOf("/fxg.jinritemai.com/api/order/searchlist?tab=all") != -1){ let obj = JSON.parse(e.detail.responseText).data; console.log("监听到的订单数据是:",obj); dsx.chulidingdanshuju(obj); }else if(e.detail.responseURL.indexOf("/fxg.jinritemai.com/api/order/receiveinfo") != -1){ let obj = JSON.parse(e.detail.responseText).data; if(obj != null){ let id = e.detail.responseURL.match(/order_id=(\d*)&/)[1]; dsx.shuju.some((item,i)=>{ if(id==item.shop_order_id){ dsx.shuju[i].receiver_info = obj.receive_info; dsx.shuju[i].user_nickname = obj.nick_name; dsx.chongxinhuizhibiaoge(dsx.shuju); }; }); } }; }, shuju:{}, saveshuju:function(obj){ GM_setValue("dingdanshuju", obj); }, getshuju:function(){ dsx.shuju = GM_getValue("dingdanshuju", "没有储存数据"); return dsx.shuju; }, tiqushuju:function(obj,i) { let kehunicheng = obj[i].user_nickname; let dingdanjine = obj[i].pay_amount / 100; let dingdanzhuangtai = obj[i].order_status_info.order_status_text; let xiadanshijian = this.formatDate(obj[i].create_time); let dingdanbianhao = obj[i].shop_order_id; let lianjiebiaoti = obj[i].product_item[0].product_name; /* let daihuodaren; let kehushoujianren; try{kehushoujianren = obj[i].receiver_info.post_receiver}catch(e){kehushoujianren = "没有"}; let shoujihao = obj[i].receiver_info.post_tel; let dizhi = obj[i].receiver_info.post_addr.province.name + obj[i].receiver_info.post_addr.city.name + obj[i].receiver_info.post_addr.town.name + obj[i].receiver_info.post_addr.street.name; try{daihuodaren = obj[i].product_item[0].properties[2].text}catch(e){daihuodaren = "没有"}; */ return {kehunicheng:kehunicheng,dingdanjine:dingdanjine,dingdanzhuangtai:dingdanzhuangtai,xiadanshijian:xiadanshijian,dingdanbianhao:dingdanbianhao,lianjiebiaoti:lianjiebiaoti}; }, duquhuizhidingdanshuju:function(){ let obj = dsx.getshuju(); if(obj !== "没有储存数据"){ dsx.shaixuanshujuhuizhibiaoge(obj); }; }, shaixuanshujuhuizhibiaoge:function(obj){ let shuzu = []; let dlength = obj.length; for (let i = 0; i < dlength; i++) { let d = dsx.tiqushuju(obj,i); shuzu[i] = [dlength-i,d.kehunicheng,d.dingdanjine,d.dingdanzhuangtai,d.xiadanshijian,d.lianjiebiaoti,d.dingdanbianhao]; }; dsx.huizhibiaoge([{ title: "序号" },{ title: "昵称" },{ title: "金额" },{ title: "状态" },{ title: "下单时间" },{ title: "链接标题" },{ title: "订单编号" }],shuzu); }, dashixiongtimer: 300000, shifouyincangbiaoge: GM_getValue("shifouyincangbiaoge",true), table:{}, huizhibiaoge : function(datehead,dataSet) { dsx.saveshuju(dsx.shuju); dsx.table = $('#dashixiongtable').DataTable({ data: dataSet, columns: datehead, oLanguage: { "sLengthMenu": "每页显示 _MENU_ 条记录", "sZeroRecords": "对不起,查询不到任何相关数据", "sInfo": "当前显示 _START_ 到 _END_ 条,共 _TOTAL_条记录", "sInfoEmtpy": "找不到相关数据", "sInfoFiltered": " 数据表中共为 _MAX_ 条记录", "sProcessing": "正在加载中...", "sSearch": "搜索", "oPaginate": { "sFirst": "第一页", "sPrevious": " 上一页 ", "sNext": " 下一页 ", "sLast": " 最后一页 " }, }, order:[4,"desc"], scrollX: true, scrollY: $(window).height() - 300, scrollCollapse: true,//滚动折叠 paging: false, createdRow: function ( row, data, index ) { if ( data[2] * 1 >= 396 ) { $('td', row).eq(2).css('font-weight',"bold").css("color","red"); } } }); $("#dashixiongtable_filter").before($('')); $("#dashixiongtable_filter").before($('')); console.log("表格对象",dsx.table); }, chongxinhuizhibiaoge: function (obj) { dsx.saveshuju(dsx.shuju); let shuzu = []; let dlength = obj.length; for (let i = 0; i < dlength; i++) { let d = dsx.tiqushuju(obj,i); shuzu[i] = [dlength-i,d.kehunicheng,d.dingdanjine,d.dingdanzhuangtai,d.xiadanshijian,d.lianjiebiaoti,d.dingdanbianhao]; }; //dsx.table.data(shuzu).draw(); dsx.table.clear().rows.add(shuzu).draw(); /* $(".dataTables_scrollHead").onload=function(){ let aa = $(".dataTables_scrollBody tbody").width(); $(".dataTables_scrollHead").css("cssText", "width:" + aa + "px !important;"); //$(".dataTables_scrollHead").width($(".dataTables_scrollBody tbody").width()); }; */ }, chulidingdanshuju : function(obj) { if(!($("#dashixiongtable tbody tr").length > 0)){ //第一次运行 dsx.shaixuanshujuhuizhibiaoge(obj); }else{ dsx.gengxinshuju(obj); } }, gengxinshuju : function(obj) { let result; //obj.sort((a,b) => {return b.exp_ship_time - a.exp_ship_time}); obj.forEach((objitem) => { result = dsx.shuju.some((shujuitem,i) => { if (dsx.shuju[i].shop_order_id == objitem.shop_order_id) { objitem.receiver_info = shujuitem.receiver_info; objitem.user_nickname = shujuitem.user_nickname; dsx.shuju[i] = objitem; return true; }; }); if (!result){ dsx.shuju.unshift(objitem); dsx.huoqudizhi(objitem.shop_order_id); setTimeout(function(){dsx.huoqudizhi(objitem.shop_order_id)},2000);//间隔2秒点击敏感信息 }; }); dsx.shuju = dsx.shuju.sort((a,b) => {return b.exp_ship_time - a.exp_ship_time}); dsx.chongxinhuizhibiaoge(dsx.shuju); dsx.Toast("更新完毕", 1000); }, huoqudizhi:function(id) { $(".index_content__3R2D9").each(function(){ if($(this).text().indexOf(id)>-1){ let zhudom = $(this).parent().parent().parent().parent().parent().parent(); let ydom = zhudom.find(".index_viewIconWrapper__1pa53").find("a").find("span"); if(ydom.length > 0 && zhudom.text().indexOf("已关闭") == -1){ ydom.click(); while ($("#captcha-verify-image").length > 0 ){ dsx.Toast("请手动验证",1000); dsx.sleep(5000); }; }; } }); }, sleep: function(time) { let startTime = new Date().getTime() + parseInt(time, 10); while(new Date().getTime() < startTime) {} }, dizhixianshi:function() { let nicname,name,tel,dizhi; let id = $(this).parent().children().eq(6).text(); dsx.shuju.some((item)=>{ if(id==item.shop_order_id){ nicname = item.user_nickname; name = item.receiver_info.post_receiver; tel = item.receiver_info.post_tel; dizhi = item.receiver_info.post_addr.province.name + item.receiver_info.post_addr.city.name + item.receiver_info.post_addr.town.name + item.receiver_info.post_addr.street.name + item.receiver_info.post_addr.detail; }; }); $("#dashixiongdizhi div:nth-child(1)").html(nicname); $("#dashixiongdizhi div:nth-child(2)").html(name + "," + tel + "," + dizhi); let X = $(this).offset().top - $(document).scrollTop() - $("#dashixiongdizhi").outerHeight(); let Y = $(this).parent().offset().left - $(document).scrollLeft(); $("#dashixiongdizhi").css({"top": X , "left": Y}).show(); $(this).parent().css("background-color", "rgba(200, 200, 200, 0.9)"); $(this).on("mouseleave", function(e) { $("#dashixiongdizhi").hide(); $(this).parent().css("background-color", "rgba(255, 255, 255, 1)"); }); }, dingshiqiid:0, duqushezhi:function(){ let time = GM_getValue("dashixiongtimer",300000); $('#dashixiongtimer').val(time/60000); dsx.dashixiongtimer = time; }, xiangyingshijian : function () { $("#dashixiongXuanFu").click(function() { $(".auxo-btn.auxo-btn-primary.auxo-btn-sm").click(); }); $("#dashixiongXuanFu").mouseenter(function() { $("#dashixiongDIV").stop(true, false).show(); }); $("#dashixiong-main").mouseleave(function() { if(dsx.shifouyincangbiaoge){ $("#dashixiongDIV").stop(true, false).hide(); } }); $("body").on("mouseenter", "#dashixiongtable>tbody tr td:nth-child(2)",dsx.dizhixianshi); $("#dashixiongbiaogeyincang").on("click",function(){ if(dsx.shifouyincangbiaoge){ dsx.shifouyincangbiaoge = false; GM_setValue("shifouyincangbiaoge",false); }else{ dsx.shifouyincangbiaoge = true; GM_setValue("shifouyincangbiaoge",true); }; }); $('#dashixiongtimer').change(function() { dsx.dashixiongtimer = $(this).val() * 60 *1000; GM_setValue("dashixiongtimer",$(this).val() * 60 *1000); window.clearInterval(dsx.dingshiqiid); dsx.dingshiqiid = window.setInterval(function() { $(".auxo-btn.auxo-btn-primary.auxo-btn-sm").click(); },dsx.dashixiongtimer); }); dsx.dingshiqiid = window.setInterval(function() { $(".auxo-btn.auxo-btn-primary.auxo-btn-sm").click(); },dsx.dashixiongtimer); }, addhtml:function(){ let a = `