// ==UserScript== // @name 亚马逊后台下载工具(个人使用) // @namespace https://greasyfork.org/zh-CN/scripts/447889 // @version 0.121 // @description 自动30天订单,库存|店铺高亮|业务报告自动昨天|自动化|跨境卫士|紫鸟浏览器 // @author menkeng // @match https://sellercentral.amazon.com/* // @icon https://www.google.com/s2/favicons?domain=amazon.com // @grant unsafeWindow // @require https://unpkg.com/jquery@3.6.0/dist/jquery.min.js // @downloadURL none // ==/UserScript== /* globals jQuery, $, waitForKeyElements */ // This is how site search get access to the shadow root // var shadowRoot = $(element.shadowRoot); // 定制服务 Q:605011383 //时间格式化问题 *特殊处理 昨日 UTC Date.prototype.Format = function (fmt) { var o = { "M+": this.getUTCMonth() + 1, //月份 "d+": this.getUTCDate() - 1, //日 "H+": this.getUTCHours(), //小时 "m+": this.getUTCMinutes(), //分 "s+": this.getUTCSeconds(), //秒 "q+": Math.floor((this.getMonth() + 3) / 3), //季度 "S": this.getMilliseconds() //毫秒 }; if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length)); for (var k in o) if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length))); return fmt; } var yesterday_cn = new Date().Format("yyyy年M月d日") var href = window.location.href // 日期范围报告 var reporthref = "https://sellercentral.amazon.com/payments/reports/custom/request?ref_=xx_report_ttab_dash&tbla_daterangereportstable=sort:%7B%22sortOrder%22%3A%22DESCENDING%22%7D;search:undefined;pagination:1;" // 业务报告 var rdailyhref = /sellercentral.amazon.com\/business-reports\/ref=xx_sitemetric_dnav_xx*/ // 订单报告 var orderhref = "https://sellercentral.amazon.com/reportcentral/FlatFileAllOrdersReport/1" // 后台 var homehref = "https://sellercentral.amazon.com/gp/homepage.html/ref=xx_home_logo_xx" // 付款控制面板 var payhref = "https://sellercentral.amazon.com/payments/dashboard/index.html/ref=xx_payments_dnav_xx" setTimeout(function(){ // 定时器 },2500); var buttom_css = "width: 50px;height: 50px;position: fixed;top: 100px;right: 50px;background: rgb(0, 0, 0);color: white;" setInterval(function(){ if (href == orderhref){Cbutton()} else{ document.querySelector("body").removeChild(button1) } },5000); var button1 = document.createElement("button") var button2 = document.createElement("button") // 店铺高亮 setTimeout(function(){red()},2500); // 业务报告点击前一天 if (rdailyhref.test(href)) {yday()} // 提现按钮 // if(href == homehref){Dbutton()} function yday() { setTimeout(function(){ // 或许是shadowdom解决方法 // var sr = $("[name='remark']")[0].shadowRoot; // $("sr").find("button").click() // alert("000") document.querySelector("div.css-wb79wd > div > kat-dropdown").shadowRoot.querySelector("div.kat-select-container > div.select-options > div > slot > kat-option:nth-child(5)").click() setTimeout(function(){ var dom1 = $("div.css-wb79wd > div.css-1nvf2ph > kat-date-picker:nth-child(1)")[0].shadowRoot var dom1_1 = $(dom1).find("kat-calendar")[0].shadowRoot $(dom1_1).find('button[aria-label="'+ yesterday_cn +'"]').click() setTimeout(function(){ var dom2 = $("div.css-wb79wd > div.css-1nvf2ph > kat-date-picker:nth-child(2)")[0].shadowRoot var dom2_1 = $(dom2).find("kat-calendar")[0].shadowRoot $(dom2_1).find('button[aria-label="'+ yesterday_cn +'"]').click() document.querySelector("div.css-1om0prg > kat-button").shadowRoot.querySelector("button").click() },500); },2000); },4000); } // 创建下载按钮 function Cbutton(){ button1.setAttribute("type", "button1"); button1.style.cssText = buttom_css button1.onclick =function(){dingdan()} button1.innerText="下载" document.querySelector("body").appendChild(button1) } function Dbutton(){ button2.setAttribute("type", "button2"); button2.style.cssText = buttom_css button2.onclick =function(){cash()} button2.innerText="提现" document.querySelector("body").appendChild(button2) } // 店铺高亮 function red() { document.querySelector("#partner-switcher > button").style.height="80px"; document.querySelector("#partner-switcher > button").style.fontSize="30px"; document.querySelector("#partner-switcher > button").style.color="red"; } // 自动提现 function cash() { $("#sc-navtab-reports-t1 > ul > li:nth-child(2) > a").click() setTimeout(function(){ alert("s") var dom3 = $("kat-button[label='请求付款']")[0].shadowRoot $(dom3).find("button").click() alert("9") },3500); } // 订单下载 function dingdan(){ document.querySelector("#daily-time-picker-style > kat-dropdown").value="30" document.querySelector("#report-page-kat-box > kat-button").shadowRoot.querySelector("button").click() setTimeout(function(){ document.querySelector("a[href='/reportcentral/FBA_MYI_UNSUPPRESSED_INVENTORY/1']").click() },100); setTimeout(function(){ document.querySelector("kat-button.download-report-page-kat-button-primary").click() },6000); } function dingdan_pass() { document.querySelector("#daily-time-picker-style > kat-dropdown").value="-1" document.querySelector("#daily-time-picker-kat-date-range-picker").shadowRoot.querySelector("kat-date-picker.start").value="" } // // This is how site search get access to the shadow root // var shadowRoot = $(element.shadowRoot); // // Use the shadow root to resolve to the cotnainer by ID // // and then finding any other elements in the shadow DOM // // works as expected. // var container = shadowRoot.find('#container'); // var span = container.find('span'); // console.log('jQuery set count: ' + span.length);