Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wfs_export
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
yexing
wfs_export
Commits
5ac648ae
Commit
5ac648ae
authored
Dec 11, 2025
by
yexing
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
月度表优化
parent
23967a5e
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
43 additions
and
169 deletions
+43
-169
plugin/.version
+2
-2
plugin/dist.crx
+0
-0
plugin/dist/js/background.js
+0
-136
plugin/dist/js/main.js
+30
-19
plugin/dist/js/popup.js
+8
-9
plugin/dist/manifest.json
+2
-2
plugin/src/main.js
+1
-1
No files found.
plugin/.version
View file @
5ac648ae
3.4.6
\ No newline at end of file
3.4.8
\ No newline at end of file
plugin/dist.crx
View file @
5ac648ae
No preview for this file type
plugin/dist/js/background.js
View file @
5ac648ae
...
...
@@ -19581,72 +19581,6 @@
dayjs
.
extend
(
isSameOrBefore
);
const
CST
=
"Asia/Shanghai"
;
class
Plan
{
constructor
(
dt
,
params
)
{
this
.
dt
=
dayjs
.
tz
(
dt
??
new
Date
(),
CST
);
this
.
setHandler
();
this
.
table
=
new
Proxy
({},
this
.
handler
);
this
.
params
=
[];
params
?.
forEach
(
param
=>
this
.
_addParam
(...
param
));
}
setHandler
()
{
this
.
handler
=
{
dt
:
this
.
dt
,
order
:
[],
// 逆序
get
(
obj
,
prop
)
{
if
(
prop
in
obj
)
return
obj
[
prop
];
const
idx
=
this
.
order
.
find
(
x
=>
prop
-
x
>=
0
);
return
obj
[
idx
];
},
set
(
obj
,
prop
,
value
)
{
const
result
=
Reflect
.
set
(...
arguments
);
this
.
order
=
Object
.
keys
(
obj
).
sort
((
a
,
b
)
=>
b
-
a
);
let
[
x1
,
x2
]
=
value
.
period
,
dt
=
this
.
dt
;
if
(
this
.
dt
.
date
()
<
parseInt
(
x2
)
||
x2
===
0
)
{
dt
=
this
.
dt
.
subtract
(
1
,
"month"
);
}
let
year
=
dt
.
year
();
let
month
=
dt
.
month
()
+
1
;
x2
=
x2
===
0
?
dt
.
daysInMonth
()
:
x2
;
month
=
(
month
+
''
).
padStart
(
2
,
"0"
);
value
.
period
=
[
`
${
year
}
-
${
month
}
-
${
x1
}
`
,
`
${
year
}
-
${
month
}
-
${
x2
}
`
];
return
result
;
}
};
}
get
(
day
=
null
)
{
const
it
=
day
?
this
.
table
[
day
]
:
this
.
table
[
this
.
dt
.
date
()];
return
it
?.
period
;
}
next
()
{
let
dt
=
this
.
dt
;
const
order
=
this
.
handler
.
order
;
const
idx
=
(
order
.
indexOf
(
this
.
get
().
dt
.
date
()
+
''
)
-
1
+
order
.
length
// 向上
)
%
order
.
length
;
if
(
idx
==
order
.
length
-
1
)
{
dt
=
dt
.
add
(
1
,
"month"
);
}
let
year
=
dt
.
year
();
let
month
=
dt
.
month
();
dt
=
this
.
table
[
order
[
idx
]].
dt
.
set
(
"year"
,
year
)
.
set
(
"month"
,
month
);
return
new
Plan
(
dt
,
this
.
params
);
}
_addParam
(
execTime
,
period
)
{
// MM-dd HH:mm:ss
const
dt
=
dayjs
.
tz
(
new
Date
(),
CST
)
.
set
(
"date"
,
+
execTime
.
substring
(
0
,
2
))
.
set
(
"hour"
,
+
execTime
.
substring
(
3
,
5
));
this
.
table
[
dt
.
date
()]
=
{
period
,
dt
};
this
.
params
.
push
(
arguments
);
}
}
const
makeLogEntry
=
(
message
)
=>
{
return
{
time
:
dayjs
.
tz
(
new
Date
(),
CST
).
format
(
"HH:mm:ss"
),
...
...
@@ -19703,46 +19637,6 @@
}
}
const
hour
=
17
;
const
p1
=
[
[
`11
${
hour
}
:`
,
[
"01"
,
"10"
]],
[
`21
${
hour
}
:`
,
[
'11'
,
'20'
]],
[
`01
${
hour
}
:`
,
[
'21'
,
0
]],
[
`05 00:`
,
[
'01'
,
0
]]
];
// const p2 = [
// [`11 ${hour}:`, ["01", "10"]],
// [`21 ${hour}:`, ['11', '20']],
// [`05 00:`, ['01', 0]]
// ];
const
TABLE
=
{
WFS
:
{
name
:
"WFS"
,
uri
:
"https://seller.walmart.com/aurora/v1/wfs/reports/"
,
params
:
p1
},
PAYMENT
:
{
name
:
"放款表"
,
uri
:
"https://seller.walmart.com/aurora/v1/"
,
params
:
p1
},
GQL
:
{
name
:
"营销表"
,
uri
:
"https://seller.walmart.com/aurora/v2/marketing-self-serve/gql"
,
params
:
p1
},
ORDER
:
{
name
:
"订单表"
,
uri
:
"https://seller.walmart.com/aurora/v1/reports/"
,
params
:
p1
},
ADVERT
:
{
name
:
"广告表"
,
uri
:
"https://advertising.walmart.com/sp/api/"
,
params
:
p1
}
};
const
checkURL
=
(
u1
,
u2
)
=>
{
if
(
!
u1
||
!
u2
)
return
false
;
return
u1
.
startsWith
(
new
URL
(
u2
).
origin
)
&&
!
u1
.
includes
(
"signin"
);
...
...
@@ -19863,35 +19757,5 @@
}
},
1000
);
}
chrome
.
alarms
.
onAlarm
.
addListener
((
alarm
)
=>
{
let
[
key
,
fromDate
,
toDate
,
when
]
=
alarm
.
name
.
split
(
'_'
);
if
(
!
Object
.
keys
(
TABLE
).
includes
(
key
))
return
;
const
{
uri
,
params
}
=
TABLE
[
key
];
const
plan
=
new
Plan
(
null
,
params
);
const
period
=
!
fromDate
||
!
toDate
?
plan
.
get
()
:
[
fromDate
,
toDate
];
if
(
!
when
)
{
when
=
plan
.
next
().
dt
.
valueOf
();
chrome
.
alarms
.
create
(
alarm
.
name
,
{
when
});
console
.
log
(
`[timedTask] uri:
${
uri
}
period:
${
period
}
when:
${
when
}
`
);
}
startTask
();
sendTabMsg
({
type
:
"run"
,
data
:
{
uri
,
period
}
});
});
// 初始化
// initTimedTask();
// chrome.storage.local.get(null, console.log);
// chrome.storage.local.clear();
// chrome.alarms.getAll(console.log);
chrome
.
alarms
.
clearAll
();
globalThis
.
initTmpTimedTask
=
(
when
)
=>
{
const
period
=
[
'2025-02-01'
,
'2025-02-28'
];
for
(
const
[
key
,
{
uri
}]
of
Object
.
entries
(
TABLE
))
{
const
name
=
[
key
,
...
period
,
when
].
join
(
'_'
);
chrome
.
alarms
.
create
(
name
,
{
when
});
console
.
log
(
`[timedTask] uri:
${
uri
}
period:
${
period
}
when:
${
when
}
`
);
}
};
// globalThis.initTmpTimedTask(getTmpClock());
// initTmpTimedTask(new Date().getTime() + 10)
})();
plugin/dist/js/main.js
View file @
5ac648ae
...
...
@@ -456,7 +456,7 @@
[
`11
${
hour
}
:`
,
[
"01"
,
"10"
]],
[
`21
${
hour
}
:`
,
[
'11'
,
'20'
]],
[
`01
${
hour
}
:`
,
[
'21'
,
0
]],
[
`05 00:`
,
[
'01'
,
0
]]
[
`05 00:`
,
[
'01'
,
0
]
,
true
]
];
// const p2 = [
// [`11 ${hour}:`, ["01", "10"]],
...
...
@@ -616,7 +616,7 @@
return
null
;
};
const
gqlCallback
=
async
function
(
response
)
{
const
uri
=
this
.
uri
,
method
=
"POST"
,
body
=
this
.
options
.
body
,
headers
=
this
.
options
.
headers
,
[
fromDate
,
toDate
]
=
this
.
options
.
period
;
const
uri
=
this
.
uri
,
method
=
"POST"
,
{
body
,
headers
,
fromDate
,
toDate
}
=
this
.
options
;
async
function
getID
(
json
)
{
const
{
campaignReports
=
null
,
pagination
=
null
}
=
json
.
data
.
get_coop_campaigns
;
if
(
!
campaignReports
?.
length
)
{
...
...
@@ -792,7 +792,8 @@
...
bodyArgs
,
},
// noLowerCase: true,
callback
:
advertCallback
callback
:
advertCallback
,
isMmonthly
:
options
.
isMmonthly
,
}
};
...
...
@@ -862,12 +863,11 @@
}
);
};
async
function
createTasks
(
uri
,
period
)
{
async
function
createTasks
(
uri
,
fromDate
,
toDate
)
{
if
(
!
uri
.
startsWith
(
location
.
origin
))
{
return
[];
}
uri
=
uri
||
TABLE
.
WFS
.
uri
;
let
[
fromDate
,
toDate
]
=
period
||
[
fmt0
(
new
Date
(),
-
10
),
fmt0
(
new
Date
(),
-
1
)];
Task
.
partnerId
=
sessionStorage
.
getItem
(
'partnerId'
);
Task
.
uri
=
uri
;
// 不适用于异步
if
(
fromDate
&&
toDate
)
{
...
...
@@ -1010,7 +1010,8 @@
method
:
"POST"
,
ext
:
"json"
,
body
,
period
,
fromDate
,
toDate
,
headers
:
rrHeaders
(),
callback
:
gqlCallback
,
next
:
true
,
...
...
@@ -1041,7 +1042,7 @@
attributionWindow
:
"days3"
,
extraFields
:
[
"noDate"
],
},
{
initialState
}
{
initialState
,
isMmonthly
:
true
}
),
createAdvertTask
(
"Placement Performance"
,
...
...
@@ -1052,7 +1053,7 @@
attributionWindow
:
"days3"
,
extraFields
:
[
"noDate"
],
},
{
initialState
}
{
initialState
,
isMmonthly
:
true
}
),
createAdvertTask
(
"Item Keyword Performance"
,
...
...
@@ -1063,7 +1064,7 @@
attributionWindow
:
"days3"
,
extraFields
:
[
"noDate"
],
},
{
initialState
}
{
initialState
,
isMmonthly
:
true
}
),
createAdvertTask
(
"Item Performance"
,
...
...
@@ -1084,6 +1085,7 @@
{
request
:
"/v1/snapshot/recommendations"
,
initialState
,
isMmonthly
:
true
}
),
];
...
...
@@ -1103,7 +1105,7 @@
fromDate
,
toDate
,
},
{
ext
:
"json"
}
{
ext
:
"json"
,
isMmonthly
:
true
}
),
new
Task
(
{
...
...
@@ -1115,7 +1117,7 @@
toDate
,
type
:
"MCS"
,
},
{
ext
:
"json"
}
{
ext
:
"json"
,
isMmonthly
:
true
}
),
new
TaskGroup
(
...
...
@@ -1153,7 +1155,8 @@
{
fromDate
,
toDate
,
}
},
{
isMmonthly
:
true
}
),
new
Task
(
{
...
...
@@ -1164,7 +1167,8 @@
fromDate
,
toDate
,
gtin
:
""
,
}
},
{
isMmonthly
:
true
}
),
new
Task
(
{
...
...
@@ -1194,7 +1198,8 @@
{
startDate
:
fromDate
,
endDate
:
toDate
,
}
},
{
isMmonthly
:
true
}
),
new
Task
(
...
...
@@ -1213,7 +1218,7 @@
{
reportType
:
"multichannel"
,
},
{
callback
:
inventoryHealthCallback
}
{
callback
:
inventoryHealthCallback
,
isMmonthly
:
true
}
),
];
}
...
...
@@ -1280,10 +1285,11 @@
).
click
();
}
}
async
function
run
(
options
=
{})
{
const
{
uri
,
period
,
sn
}
=
options
;
const
[
fromDate
,
toDate
]
=
period
||
[
fmt0
(
new
Date
(),
-
10
),
fmt0
(
new
Date
(),
-
1
)];
const
{
uri
,
plan
,
sn
}
=
options
;
plan
.
period
||=
[
fmt0
(
new
Date
(),
-
10
),
fmt0
(
new
Date
(),
-
1
)];
const
[
fromDate
,
toDate
]
=
plan
.
period
;
const
[
key
,
{
name
}]
=
Object
.
entries
(
TABLE
).
find
((
item
)
=>
item
[
1
].
uri
===
uri
);
let
tasks
=
await
createTasks
(
uri
,
period
);
let
tasks
=
await
createTasks
(
uri
,
fromDate
,
toDate
);
tasks
=
sn
?
[
tasks
.
at
(
sn
)]
:
tasks
;
// 在季度周期过滤掉月度任务
// tasks = tasks.filter((x)=>!x.isMonthly);
...
...
@@ -1292,10 +1298,15 @@
for
(
const
task
of
tasks
)
{
const
pf
=
`
${
++
idx
}
/
${
len
}
`
;
addLog
(
`
${
name
}
运行中
${
pf
}
`
);
if
((
task
?.
options
||
task
?.
task0
.
options
||
{}).
isMmonthly
&&
!
plan
.
isMmonthly
)
{
console
.
log
(
`
${
pf
}
skip1`
);
continue
;
}
console
.
log
(
`
${
pf
}
start:
${
JSON
.
stringify
(
task
)}
`
);
let
data
=
await
task
.
send
();
if
(
data
===
true
||
data
===
false
)
{
continue
;
console
.
log
(
`
${
pf
}
skip2`
);
continue
;
}
let
fn
=
task
.
getFileName
();
...
...
plugin/dist/js/popup.js
View file @
5ac648ae
...
...
@@ -6,7 +6,7 @@
[
`11
${
hour
}
:`
,
[
"01"
,
"10"
]],
[
`21
${
hour
}
:`
,
[
'11'
,
'20'
]],
[
`01
${
hour
}
:`
,
[
'21'
,
0
]],
[
`05 00:`
,
[
'01'
,
0
]]
[
`05 00:`
,
[
'01'
,
0
]
,
true
]
];
// const p2 = [
// [`11 ${hour}:`, ["01", "10"]],
...
...
@@ -180,8 +180,7 @@
};
}
get
(
day
=
null
)
{
const
it
=
day
?
this
.
table
[
day
]
:
this
.
table
[
this
.
dt
.
date
()];
return
it
?.
period
;
return
(
day
?
this
.
table
[
day
]
:
this
.
table
[
this
.
dt
.
date
()])
??
{};
}
next
()
{
let
dt
=
this
.
dt
;
...
...
@@ -199,12 +198,12 @@
.
set
(
"month"
,
month
);
return
new
Plan
(
dt
,
this
.
params
);
}
_addParam
(
execTime
,
period
)
{
_addParam
(
execTime
,
period
,
isMmonthly
=
false
)
{
// MM-dd HH:mm:ss
const
dt
=
dayjs
.
tz
(
new
Date
(),
CST
)
.
set
(
"date"
,
+
execTime
.
substring
(
0
,
2
))
.
set
(
"hour"
,
+
execTime
.
substring
(
3
,
5
));
this
.
table
[
dt
.
date
()]
=
{
period
,
dt
};
this
.
table
[
dt
.
date
()]
=
{
period
,
dt
,
isMmonthly
};
this
.
params
.
push
(
arguments
);
}
}
...
...
@@ -252,20 +251,20 @@
// const period = [fromInput.value, toInput.value];
// const period = ['2025-01-01', '2025-02-01'];
const
p
eriod
=
new
Plan
(
null
,
params
).
get
();
if
(
period
===
undefined
)
{
const
p
lan
=
new
Plan
(
null
,
params
).
get
();
if
(
p
lan
.
p
eriod
===
undefined
)
{
addLog
(
`
${
name
}
未到指定时间`
,
true
);
return
;
}
// Deprecated
const
diff
=
getTimeDiff
(
period
[
1
],
1
);
const
diff
=
getTimeDiff
(
p
lan
.
p
eriod
[
1
],
1
);
if
(
-
12
<
diff
&&
diff
<
0
)
{
const
select
=
confirm
(
"时间未到, 是否确认继续"
);
if
(
!
select
)
return
;
}
chrome
.
storage
.
local
.
get
([
'isRunning'
],
({
isRunning
})
=>
{
if
(
!
isRunning
)
{
chrome
.
runtime
.
sendMessage
({
type
:
"run"
,
data
:
{
p
eriod
,
uri
}
});
chrome
.
runtime
.
sendMessage
({
type
:
"run"
,
data
:
{
p
lan
,
uri
}
});
}
});
});
...
...
plugin/dist/manifest.json
View file @
5ac648ae
{
"name"
:
"WalmartExports"
,
"description"
:
"导出沃尔玛报表"
,
"version"
:
"3.4.6"
,
"manifest_version"
:
3
,
"background"
:{
"service_worker"
:
"./js/background.js"
},
"permissions"
:[
"tabs"
,
"activeTab"
,
"scripting"
,
"notifications"
,
"storage"
,
"alarms"
],
"action"
:{
"default_title"
:
"WalmartExports"
,
"default_popup"
:
"popup.html"
,
"default_icon"
:{
"16"
:
"icon.png"
,
"32"
:
"icon.png"
,
"48"
:
"icon.png"
,
"128"
:
"icon.png"
}},
"icons"
:{
"16"
:
"icon.png"
,
"32"
:
"icon.png"
,
"48"
:
"icon.png"
,
"128"
:
"icon.png"
},
"web_accessible_resources"
:[{
"resources"
:[
"src/main.js"
],
"matches"
:[
"<all_urls>"
]}],
"host_permissions"
:[
"https://seller.walmart.com/*"
,
"https://advertising.walmart.com/*"
,
"https://login.account.wal-mart.com/*"
,
"https://marketplace.walmartapis.com/*"
,
"https://walmart.meinuosha.com/*"
],
"content_scripts"
:[{
"matches"
:[
"https://seller.walmart.com/*"
,
"https://advertising.walmart.com/*"
,
"https://login.account.wal-mart.com/*"
,
"https://marketplace.walmartapis.com/*"
,
"https://walmart.meinuosha.com/*"
],
"js"
:[
"./js/main.js"
]}]}
\ No newline at end of file
{
"name"
:
"WalmartExports"
,
"description"
:
"导出沃尔玛报表"
,
"version"
:
"3.4.8"
,
"manifest_version"
:
3
,
"background"
:{
"service_worker"
:
"./js/background.js"
},
"permissions"
:[
"tabs"
,
"activeTab"
,
"scripting"
,
"notifications"
,
"storage"
,
"alarms"
],
"action"
:{
"default_title"
:
"WalmartExports"
,
"default_popup"
:
"popup.html"
,
"default_icon"
:{
"16"
:
"icon.png"
,
"32"
:
"icon.png"
,
"48"
:
"icon.png"
,
"128"
:
"icon.png"
}},
"icons"
:{
"16"
:
"icon.png"
,
"32"
:
"icon.png"
,
"48"
:
"icon.png"
,
"128"
:
"icon.png"
},
"web_accessible_resources"
:[{
"resources"
:[
"src/main.js"
],
"matches"
:[
"<all_urls>"
]}],
"host_permissions"
:[
"https://seller.walmart.com/*"
,
"https://advertising.walmart.com/*"
,
"https://login.account.wal-mart.com/*"
,
"https://marketplace.walmartapis.com/*"
,
"https://walmart.meinuosha.com/*"
],
"content_scripts"
:[{
"matches"
:[
"https://seller.walmart.com/*"
,
"https://advertising.walmart.com/*"
,
"https://login.account.wal-mart.com/*"
,
"https://marketplace.walmartapis.com/*"
,
"https://walmart.meinuosha.com/*"
],
"js"
:[
"./js/main.js"
]}]}
\ No newline at end of file
plugin/src/main.js
View file @
5ac648ae
...
...
@@ -30,7 +30,7 @@ async function run(options = {}) {
for
(
const
task
of
tasks
)
{
const
pf
=
`
${
++
idx
}
/
${
len
}
`
;
addLog
(
`
${
name
}
运行中
${
pf
}
`
);
if
(
task
.
options
.
isMmonthly
&&
!
plan
.
isMmonthly
)
{
if
(
(
task
?.
options
||
task
?.
task0
.
options
||
{})
.
isMmonthly
&&
!
plan
.
isMmonthly
)
{
console
.
log
(
`
${
pf
}
skip1`
);
continue
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment