// ==UserScript==
// @name walmart 绩效快速统计
// @namespace http://tampermonkey.net/
// @version 1.4
// @description 用在沃尔玛运营时候简化一部分操作用 私人脚本
// @author w1w
// @match *://seller.walmart.com/partner-analytics/performance/financials*
// @require http://libs.baidu.com/jquery/2.0.0/jquery.min.js
// @require https://cdn.bootcdn.net/ajax/libs/noty/3.1.4/noty.min.js
// @icon https://www.google.com/s2/favicons?domain=walmart.com
// @grant none
// @license MIT
// @downloadURL none
// ==/UserScript==
//缝缝补补用三年 简化下沃尔玛后台的运营操作。
window.hide = (el, showtime, time) => {
let alpha = 100;
el.style.opacity = alpha / 100;
setTimeout(() => {
let a = setInterval(() => {
//console.log(alpha)
el.style.opacity = alpha / 100;
alpha -= 2;
if (alpha <= 15) {
el.style.opacity = 0;
clearInterval(a);
}
}, time / 50);
}, showtime);
};
window.copy = () => {
let transfer = document.querySelector("#textarea22588");
transfer.style.display = "";
transfer.value = copyData; // 这里表示想要复制的内容
transfer.focus();
transfer.select();
//alert("复制完成");
hide(document.querySelector("artDilog"), 1.6e3, 1.6e3);
if (document.execCommand("copy")) {
document.execCommand("copy");
}
transfer.blur();
transfer.style.display = "none";
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 =
`
" +
timeList[i] +
" | " +
tempDate["catlgItemId"] +
" | " +
tempDate["department"] +
" | " +
tempDate["brandName"] +
" | " +
tempDate["TotalGMV"] +
" | " +
tempDate["TotalCommissions"] +
" | " +
(tempDate["TotalGMV"] - tempDate["TotalCommissions"]) +
" | " +
tempDate["AuthAUR"] +
" | " +
tempDate["TotalUnits"] +
" | " +
tempDate["TotalCancelUnits"] +
" | " +
tempDate["TotalCancelAmt"] +
" | " +
tempDate["TotalCancelAmt"] / tempDate["TotalAuthAmt"] +
" | " +
tempDate["TotalCancelUnits"] / tempDate["TotalAuthUnits"] +
" | " +
tempDate["Conversion"] +
" | " +
tempDate["baseItemId"] +
" | " +
tempDate["skuId"] +
" | " +
tempDate["TotalProductVisitsItemLvl"] + //似乎这里有修改
" |
";
}
}
}
};
$().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);
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());
});
$("#copyData").bind("click", function () {
copy();
});
var nowTime = () => {
let d = new Date();
$("#nowTime").val(
"" +
d.getHours() +
":" +
addZero("" + d.getMinutes()) +
":" +
addZero("" + d.getSeconds())
);
};
setInterval(nowTime, 500);
}, 1500);
});
window.getDayilyData2 = (dateTime, sort) => {
window.tempVal2 = [];
let offsetTime = new Date(dateTime);
offsetTime = offsetTime.getTime() - 86400000 * 1;
offsetTime = new Date(offsetTime);
offsetTime =
offsetTime.getFullYear() +
"-" +
addZero("" + (offsetTime.getMonth() + 1)) +
"-" +
addZero("" + offsetTime.getDate());
async function postData(url = "") {
// Default options are marked with *
const response = await fetch(url, {
method: "POST", // *GET, POST, PUT, DELETE, etc.
contentType: "application/json",
dataType: "json",
credentials: "same-origin",
headers: {
Accept: "application/json",
"x-xsrf-token": window.xtoken,
"X-Requested-With": "XMLHttpRequest",
"Content-Type": "application/json",
},
body:
'{"filter":{"filterBy":{"duration":["' +
offsetTime +
'","' +
offsetTime +
'"],"program":"ALL"},"sortBy":{}},"pagination":{"pageNumber":1,"pageSize":25}}',
});
return response.json();
}
postData("https://seller.walmart.com/api/aurora/financial/getItemSales").then(
(data) => {
tempVal2.push([sort, data["data"]]);
window.fetchFishedCount += 1;
}
);
};