您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Greasy Fork is available in English.
用在沃尔玛运营时候简化一部分操作用 私人脚本
当前为
// ==UserScript== // @name walmart 绩效快速统计 // @namespace http://tampermonkey.net/ // @version 1.1 // @description 用在沃尔玛运营时候简化一部分操作用 私人脚本 // @author w1w // @match *://seller.walmart.com/partner-analytics/performance/financials* // @require http://libs.baidu.com/jquery/2.0.0/jquery.min.js // @icon https://www.google.com/s2/favicons?domain=walmart.com // @grant none // @license MIT // ==/UserScript== //缝缝补补用三年 简化下沃尔玛后台的运营操作。 window.copy=()=> { let transfer = document.createElement('textarea'); document.body.appendChild(transfer); transfer.value = copyData; // 这里表示想要复制的内容 transfer.focus(); transfer.select(); alert("复制完成"); if (document.execCommand('copy')) { document.execCommand('copy'); } transfer.blur(); console.log('复制成功'); document.body.removeChild(transfer); } window.todayValue = function() { var d = new Date(); var todayValue = d.getFullYear() + '-' + (d.getMonth() + 1) + '-' + d.getDate(); return todayValue; } window.addZero = function(data) { if (data.length < 2) { return '0' + data } else { return data } } window.id = 'tab' + Date.now(); window.timeIsRight = 1; var tem = ` <form class="newSearch" style="text-align:center;"> <input type="text" id="nowTime" value=""/> <span>开始时间:</span><input type="text" id="stt" value="2021-10-1"/> <span>结束时间:</span><input type="text" id="ent" value="2021-10-1"/> <!--<input type="button" id='today' value="数据直到今天" />--!> <input type="button" id = 'TDay' value="最近三天" /> <input type="button" id = 'SDay' value="最近七天" /> <input type="button" id = 'sameDay' value="同一天" /> <input type="button" id = 'go' value="开始" /> <span>请不要一下子搜索太长时间跨度单次上限100天(不要改系统时区,时间计算会出错的)</span></form> <tab id="` + id + `"><br/></tab>`; window.templete = `<tr> <td class='newT'> Data</td> <td class='newT'> ITEM ID</td> <td class='newT'> DEPARTMENT</td> <td class='newT'> BRAND</td> <td class='newT'> GMV</td> <td class='newT'> COMMISSION</td> <td class='newT'> GMV - COMMISSION</td> <td class='newT'> AUR</td> <td class='newT'> TOTAL UNITS SOLD</td> <td class='newT'> CANCELLED UNITS</td> <td class='newT'> CANCELLED SALES</td> <td class='newT'> CANCELLED SALES %</td> <td class='newT'> CANCELLED UNITS %</td> <td class='newT'> ITEM CONVERSION RATE</td> <td class='newT'> BASE ITEM ID</td> <td class='newT'> SKU</td> <td class='newT'> TOTAL PRODUCT VISITS</td> </tr>`; window.getDayilyData = function(dateTime) { var getXToken =()=>{ var r = new RegExp('XSRF-TOKEN=(.*?);') var xtoken = document.cookie.match(r)[1].toString(); console.log(xtoken); return xtoken; } window.tempVal = []; let offsetTime = new Date(dateTime); offsetTime = offsetTime.getTime() - 86400000 * 1 offsetTime = new Date(offsetTime) offsetTime = offsetTime.getFullYear() + '-' + addZero('' + (offsetTime.getMonth() + 1)) + '-' + addZero('' + offsetTime.getDate()) $.ajax({ url: 'https://seller.walmart.com/api/aurora/financial/getItemSales', type: 'POST', async: false, contentType: 'application/json', dataType: 'json', tryCount : 0, retryLimit : 5, headers: { Accept: "application/json", 'x-xsrf-token': getXToken() }, data: '{"filter":{"filterBy":{"duration":["' + offsetTime + '","' + offsetTime + '"],"program":"ALL"},"sortBy":{}},"pagination":{"pageNumber":1,"pageSize":25}}', success(e) { console.log('seccucs...') allDate.push(e['data']); tempVal.push(e) }, error (xhr, textStatus, errorThrown ) { this.tryCount++; if (this.tryCount <= this.retryLimit) { //try again $.ajax(this); return; } },}) }; window.getDaily = function() { window.allDate = []; window.tableData = ''; window.timeList = []; let stt = $('#stt').val(); let ent = $('#ent').val(); stt = new Date(stt); ent = new Date(ent); if(stt=="Invalid Date" || ent =="Invalid Date"){ alert("请输入正确时间格式!"); timeIsRight = 0; return 0 } var stt_T = stt.getTime() var ent_T = ent.getTime() if (stt_T > ent_T){ alert("请输入正确时间顺序!"); timeIsRight = 0; return 0 }else{ timeIsRight =1 ; } ent = (ent.getFullYear() + '-' + addZero('' + (ent.getMonth() + 1)) + '-' + addZero('' + ent.getDate())) var iii = 100 //单次搜索上限 let temp = stt.getFullYear() + '-' + addZero('' + (stt.getMonth() + 1)) + '-' + addZero('' + stt.getDate()) timeList.push(temp) if (temp != ent) { while (iii > 0) { stt_T = 86400000 + stt_T; let temDate = new Date(stt_T) temp = temDate.getFullYear() + '-' + addZero('' + (temDate.getMonth() + 1)) + '-' + addZero('' + temDate .getDate()) timeList.push(temp) if (temp == ent) { break } else { iii-- } } } return 0 }; window.mainLunch = function() { console.log("点击开始运行"); getDaily(); if (timeIsRight == 0){ return 0 } console.log(timeList.length); for (var i = 0; i < timeList.length; i++) { getDayilyData(timeList[i]) }; formatTable(); clearTable(); insertTable(); setTimeout(copy,2333); }; window.clearTable = function() { if ($('#' + id).children().length > 1) { $('#' + id).children()[0].remove(); } } window.insertTable = function() { window.allTable = window.templete + window.tableData; window.div_tab = document.createElement('table'); div_tab.innerHTML = allTable $('#' + id).children()[0].before(div_tab); $('#' + id).children()[0].style.fontSize = '6px'; $('#' + id).children()[0].style.border = '1px solid'; $('#' + id).children()[0].style.textAlign = 'center'; }; window.formatTable = function() { window.copyData=""; for (var i = 0; i < allDate.length; i++) { let temp = allDate[i] if (temp == []) { continue } else { for (var ii = 0; ii < temp.length; ii++) { var tempDate = temp[ii] window.copyData+= (timeList[i] +"\t"+ tempDate['catlgItemId'] +"\t"+ tempDate['department'] +"\t"+ tempDate['brandName'] +"\t"+ tempDate['TotalGMV'] +"\t"+ tempDate['TotalCommissions'] +"\t"+ (tempDate['TotalGMV'] - tempDate['TotalCommissions']) +"\t"+ tempDate['AuthAUR'] +"\t"+ tempDate['TotalUnits'] +"\t"+ tempDate['TotalCancelUnits'] +"\t"+ tempDate['TotalCancelAmt'] +"\t"+ (tempDate['TotalCancelAmt'] / tempDate['TotalAuthAmt']) +"\t"+ (tempDate['TotalCancelUnits'] / tempDate['TotalAuthUnits']) +"\t"+ tempDate['Conversion'] +"\t"+ tempDate['baseItemId'] +"\t"+ tempDate['skuId'] +"\t"+ tempDate['TotalProductVisits'] +"\r\n") window.tableData = window.tableData + "<tr><td class= 'newT'>" + timeList[i] + "</td><td class= 'newT'>" + tempDate['catlgItemId'] + "</td><td class= 'newT'>" + tempDate['department'] + "</td><td class= 'newT'>" + tempDate['brandName'] + "</td><td class= 'newT'>" + tempDate['TotalGMV'] + "</td><td class= 'newT'>" + tempDate['TotalCommissions'] + "</td><td class= 'newT'>" + (tempDate['TotalGMV'] - tempDate['TotalCommissions']) + "</td><td class= 'newT'>" + tempDate['AuthAUR'] + "</td><td class= 'newT'>" + tempDate['TotalUnits'] + "</td><td class= 'newT'>" + tempDate['TotalCancelUnits'] + "</td><td class= 'newT'>" + tempDate['TotalCancelAmt'] + "</td><td class= 'newT'>" + (tempDate['TotalCancelAmt'] / tempDate['TotalAuthAmt']) + "</td><td class= 'newT'>" + (tempDate['TotalCancelUnits'] / tempDate['TotalAuthUnits']) + "</td><td class= 'newT'>" + tempDate['Conversion'] + "</td><td class= 'newT'>" + tempDate['baseItemId'] + "</td><td class= 'newT'>" + tempDate['skuId'] + "</td><td class= 'newT'>" + tempDate['TotalProductVisits'] + "</td></tr>"; } } } }; $().ready(function() { let date =new Date(); date = date.getTime() let div_section = document.createElement('section') let tempDate; div_section.innerHTML = tem setTimeout(()=>{document.querySelector("#subapp-main-0 > div > div:nth-child(1) > div > div:nth-child(3) > div").before(div_section) //document.querySelector("span[text='Performance']").before(div_section) tempDate = date-86400000*5; tempDate = new Date(tempDate); $("#ent").val(todayValue()); $("#stt").val(tempDate.getFullYear() + '-' + addZero('' + (tempDate.getMonth() + 1)) + '-' + addZero('' + tempDate.getDate())); $("#sameDay").bind('click', function() { $("#ent").val($("#stt").val()); }); $("#TDay").bind('click', function() { $("#ent").val(todayValue()); tempDate = date-86400000*3; tempDate = new Date(tempDate); $("#stt").val(tempDate.getFullYear() + '-' + addZero('' + (tempDate.getMonth() + 1)) + '-' + addZero('' + tempDate.getDate())); }); $("#SDay").bind('click', function() { $("#ent").val(todayValue()); tempDate = date-86400000*7; tempDate = new Date(tempDate); $("#stt").val(tempDate.getFullYear() + '-' + addZero('' + (tempDate.getMonth() + 1)) + '-' + addZero('' + tempDate.getDate())); }); $("#go").bind('click', function() { mainLunch() }); $("#today").bind('click', function() { $("#ent").val(todayValue()) }); var nowTime = () => { let d = new Date() $('#nowTime').val('' + d.getHours() + ':' + addZero('' + d.getMinutes()) + ':' + addZero('' + d .getSeconds())) } setInterval(nowTime, 500)},1500) })