Greasy Fork is available in English.
每月自动操作一次,替代用户点击生成亚马逊账单报告
当前为
// ==UserScript==
// @name 自动生成亚马逊账单报告
// @namespace liu12
// @version 0.3
// @description 每月自动操作一次,替代用户点击生成亚马逊账单报告
// @author 刘一二
// @match *://sellercentral.amazon.com/*
// @match *://sellercentral.amazon.ca/*
// @match *://sellercentral.amazon.com.mx/*
// @match *://sellercentral.amazon.co.uk/*
// @match *://sellercentral.amazon.de/*
// @match *://sellercentral.amazon.fr/*
// @match *://sellercentral.amazon.it/*
// @match *://sellercentral.amazon.es/*
// @match *://sellercentral.amazon.jp/*
// @require https://code.jquery.com/jquery-latest.js
// ==/UserScript==
(function() {
'use strict';
var AmazonReport = {
year: 0,
month: 0,
/**
* 获取账号
*/
getAccount: function() {
return $("#sc-mkt-switcher-form .sc-mkt-picker-switcher-txt")[0].html()
},
/**
* 申请生成报告
*/
requestReport: function() {
var sKey = 'amazon-request-report-' + year + '-' + month
console.log(localStorage.getItem(sKey));
if (localStorage.getItem(sKey) == null) {
var postData = {
reportType: "Transaction",
timeRangeType: "Monthly",
year: this.year,
month: this.month
};
$.ajax({
type: "POST",
url: "/payments/reports/custom/submit/generateReports",
data: JSON.stringify(postData),
dataType: "json",
contentType: "application/json;charset=utf-8",
success: function(response) {
// {"status":"SUCCESS","message":"请求交易月份:3年份:2020"}
console.log(response);
if (response.status == "SUCCESS") {
localStorage.setItem(sKey, 1);
}
}
});
}
},
/**
* 通知账单系统拉取报告,
*/
notify: function() {
var _this = this;
$.ajax({
type: "POST",
url: "账单系统网址",
data: {
account:_this.getAccount(),
yearMonth: (_this.year + "=" + _this.month)
},
success: function(response) {
console.log(response);
}
});
},
init: function() {
var account = this.getAccount();
if (!account) {
return;
}
var date = new Date();
var year = parseInt(date.getFullYear());
var month = parseInt(date.getMonth());
if (month == 0) {
year--;
month = 12;
}
this.year = year;
this.month = month;
this.requestReport();
//this.notify();
}
};
$(function() {
AmazonReport.init();
});
})();