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
cf92a603
Commit
cf92a603
authored
Dec 24, 2025
by
yexing
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
重试优化
parent
748ce478
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
92 additions
and
34 deletions
+92
-34
plugin/.version
+2
-2
plugin/dist.crx
+0
-0
plugin/dist/js/background.js
+2
-3
plugin/dist/js/main.js
+52
-15
plugin/dist/js/popup.js
+5
-1
plugin/dist/manifest.json
+2
-2
plugin/src/main.js
+23
-8
plugin/src/task.js
+4
-0
plugin/src/upload.js
+2
-3
No files found.
plugin/.version
View file @
cf92a603
3.4.8
\ No newline at end of file
3.4.9
\ No newline at end of file
plugin/dist.crx
View file @
cf92a603
No preview for this file type
plugin/dist/js/background.js
View file @
cf92a603
...
...
@@ -19628,14 +19628,13 @@
}
else
{
url
=
options
.
isLink
?
linkURL
:
fileURL
;
}
if
(
await
checkLog
(
fn
))
{
if
(
options
.
isCheck
&&
!
await
checkLog
(
fn
))
return
;
const
insert
=
await
retry
(
async
()
=>
upload
(
url
,
data
,
options
.
headers
),
{
delayMs
:
1000
*
60
*
1.5
}
{
delayMs
:
1000
*
60
*
1.5
,
retries
:
10
}
);
if
(
insert
)
await
checkLog
(
fn
,
true
);
}
}
const
checkURL
=
(
u1
,
u2
)
=>
{
if
(
!
u1
||
!
u2
)
return
false
;
...
...
plugin/dist/js/main.js
View file @
cf92a603
(
function
(
)
{
var
G
=
(
function
(
exports
)
{
'use strict'
;
var
commonjsGlobal
=
typeof
globalThis
!==
'undefined'
?
globalThis
:
typeof
window
!==
'undefined'
?
window
:
typeof
global
!==
'undefined'
?
global
:
typeof
self
!==
'undefined'
?
self
:
{};
...
...
@@ -144,6 +144,15 @@
compressionOptions
:
{
level
:
9
}
});
}
function
downloadFile
(
fn
,
blob
)
{
const
url
=
URL
.
createObjectURL
(
blob
);
const
a
=
document
.
createElement
(
'a'
);
a
.
href
=
url
;
a
.
download
=
fn
;
a
.
click
();
a
.
remove
();
URL
.
revokeObjectURL
(
url
);
}
function
fmt0
(
d1
,
diff
=
0
)
{
const
dt1
=
new
Date
(
d1
);
dt1
.
setDate
(
d1
.
getDate
()
+
diff
);
...
...
@@ -263,7 +272,11 @@
message
}
};
const
addLog
=
(
message
,
push
)
=>
chrome
.
runtime
.
sendMessage
({
type
:
"addLog"
,
data
:
makeLogEntry
(
message
),
push
});
const
addLog
=
(
message
,
push
)
=>
{
if
(
typeof
chrome
!==
'undefined'
&&
chrome
.
runtime
)
{
chrome
.
runtime
.
sendMessage
({
type
:
"addLog"
,
data
:
makeLogEntry
(
message
),
push
});
}
};
const
checkTime
=
(
time
)
=>
{
if
(
!
time
.
isValid
())
throw
new
Error
(
"无效时间"
);
...
...
@@ -445,6 +458,10 @@
}
return
createZip
([
blob
],
[
fn
]);
}
catch
(
e
)
{
if
(
e
.
message
===
'Failed to fetch'
)
{
console
.
info
(
`重试 fetch`
);
return
this
.
_retry
(
arguments
);
}
console
.
error
(
`send
${
e
.
message
}
${
JSON
.
stringify
(
this
)}
`
);
return
false
;
}
...
...
@@ -1265,14 +1282,13 @@
}
else
{
url
=
options
.
isLink
?
linkURL
:
fileURL
;
}
if
(
await
checkLog
(
fn
))
{
if
(
options
.
isCheck
&&
!
await
checkLog
(
fn
))
return
;
const
insert
=
await
retry
(
async
()
=>
upload
(
url
,
data
,
options
.
headers
),
{
delayMs
:
1000
*
60
*
1.5
}
{
delayMs
:
1000
*
60
*
1.5
,
retries
:
10
}
);
if
(
insert
)
await
checkLog
(
fn
,
true
);
}
}
// fetch("https://advertising.walmart.com/extend-sso")
async
function
webJump
()
{
...
...
@@ -1285,16 +1301,15 @@
).
click
();
}
}
async
function
run
(
options
=
{})
{
const
{
uri
,
plan
,
sn
}
=
options
;
const
{
uri
,
plan
,
sn
,
isDownload
=
false
}
=
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
,
fromDate
,
toDate
);
tasks
=
sn
?
[
tasks
.
at
(
sn
)]
:
tasks
;
// 在季度周期过滤掉月度任务
// tasks = tasks.filter((x)=>!x.isMonthly);
let
moment
=
2000
,
idx
=
0
,
len
=
tasks
.
length
;
const
allData
=
[],
allFn
=
[],
zipFn
=
`
${
Task
.
partnerId
}
#
${
key
}
#
${
fromDate
}
_
${
toDate
}
.zip`
;
const
isSingle
=
uri
==
TABLE
.
PAYMENT
.
uri
;
for
(
const
task
of
tasks
)
{
const
pf
=
`
${
++
idx
}
/
${
len
}
`
;
addLog
(
`
${
name
}
运行中
${
pf
}
`
);
...
...
@@ -1303,26 +1318,41 @@
continue
;
}
console
.
log
(
`
${
pf
}
start:
${
JSON
.
stringify
(
task
)}
`
);
let
fn
=
task
.
getFileName
();
const
isJson
=
fn
.
endsWith
(
'.json'
);
if
(
!
isJson
)
fn
=
fn
.
replace
(
/
\.\w
+$/g
,
".zip"
);
if
((
isSingle
||
isJson
)
&&
!
await
checkLog
(
fn
))
{
console
.
log
(
`
${
pf
}
skip2`
);
continue
;
}
let
data
=
await
task
.
send
();
if
(
data
===
true
||
data
===
false
)
{
console
.
log
(
`
${
pf
}
skip
2
`
);
console
.
log
(
`
${
pf
}
skip
3
`
);
continue
;
}
let
fn
=
task
.
getFileName
();
const
isJson
=
fn
.
endsWith
(
'.json'
);
if
(
isJson
)
{
const
route
=
data
.
__route
;
delete
data
.
__route
;
const
headers
=
{
'Content-Type'
:
'application/json'
};
await
uploadFile
(
fn
,
data
,
{
isJson
,
headers
,
route
});
if
(
isDownload
)
{
// const blob = new Blob([data], { "type": "application/json" });
// downloadFile(fn, blob);
console
.
log
(
data
);
}
}
else
{
if
(
isSingle
)
{
const
zip
=
await
createZip
([
data
],
[
fn
]);
const
form
=
new
FormData
();
form
.
append
(
"zipfile"
,
zip
,
fn
);
await
uploadFile
(
fn
,
form
);
}
else
{
fn
=
fn
.
replace
(
/
\.\w
+$/g
,
".zip"
);
allData
.
push
(
data
);
allFn
.
push
(
fn
);
// downloadFile(fn, data);
}
}
console
.
log
(
`
${
pf
}
end:
${
fn
}
`
);
await
sleep
(
moment
);
...
...
@@ -1331,10 +1361,12 @@
const
zip
=
await
createZip
(
allData
,
allFn
);
const
form
=
new
FormData
();
form
.
append
(
"zipfile"
,
zip
,
zipFn
);
await
uploadFile
(
zipFn
,
form
);
await
uploadFile
(
zipFn
,
form
,
{
isCheck
:
true
});
isDownload
&&
downloadFile
(
zipFn
,
zip
);
}
addLog
(
`
${
name
}
运行完成`
);
}
if
(
typeof
chrome
!==
'undefined'
&&
chrome
.
runtime
)
{
chrome
.
runtime
.
onMessage
.
addListener
((
msg
,
sender
,
sendResponse
)
=>
{
(
async
()
=>
{
try
{
...
...
@@ -1350,5 +1382,10 @@
})();
return
true
;
});
}
exports
.
run
=
run
;
return
exports
;
})();
})(
{}
);
plugin/dist/js/popup.js
View file @
cf92a603
...
...
@@ -213,7 +213,11 @@
message
}
};
const
addLog
=
(
message
,
push
)
=>
chrome
.
runtime
.
sendMessage
({
type
:
"addLog"
,
data
:
makeLogEntry
(
message
),
push
});
const
addLog
=
(
message
,
push
)
=>
{
if
(
typeof
chrome
!==
'undefined'
&&
chrome
.
runtime
)
{
chrome
.
runtime
.
sendMessage
({
type
:
"addLog"
,
data
:
makeLogEntry
(
message
),
push
});
}
};
const
checkTime
=
(
time
)
=>
{
if
(
!
time
.
isValid
())
throw
new
Error
(
"无效时间"
);
...
...
plugin/dist/manifest.json
View file @
cf92a603
{
"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
{
"name"
:
"WalmartExports"
,
"description"
:
"导出沃尔玛报表"
,
"version"
:
"3.4.9"
,
"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 @
cf92a603
...
...
@@ -2,7 +2,7 @@ import { sleep, xpath, createZip, fmt0, downloadFile } from "./util.js";
import
{
addLog
}
from
"./timezone.js"
;
import
{
createTasks
}
from
"./base.js"
;
import
{
Task
}
from
"./task.js"
;
import
{
uploadFile
}
from
"./upload.js"
;
import
{
uploadFile
,
checkLog
}
from
"./upload.js"
;
import
{
TABLE
}
from
"./conf.js"
;
// fetch("https://advertising.walmart.com/extend-sso")
...
...
@@ -25,6 +25,7 @@ export async function run(options = {}) {
tasks
=
sn
?
[
tasks
.
at
(
sn
)]
:
tasks
;
let
moment
=
2000
,
idx
=
0
,
len
=
tasks
.
length
;
const
allData
=
[],
allFn
=
[],
zipFn
=
`
${
Task
.
partnerId
}
#
${
key
}
#
${
fromDate
}
_
${
toDate
}
.zip`
;
const
isSingle
=
uri
==
TABLE
.
PAYMENT
.
uri
;
for
(
const
task
of
tasks
)
{
const
pf
=
`
${
++
idx
}
/
${
len
}
`
;
addLog
(
`
${
name
}
运行中
${
pf
}
`
);
...
...
@@ -33,28 +34,42 @@ export async function run(options = {}) {
continue
;
}
console
.
log
(
`
${
pf
}
start:
${
JSON
.
stringify
(
task
)}
`
);
let
fn
=
task
.
getFileName
();
const
isJson
=
fn
.
endsWith
(
'.json'
);
if
(
!
isJson
)
fn
=
fn
.
replace
(
/
\.\w
+$/g
,
".zip"
);
if
((
isSingle
||
isJson
)
&&
!
await
checkLog
(
fn
))
{
console
.
log
(
`
${
pf
}
skip2`
);
continue
;
}
let
data
=
await
task
.
send
();
if
(
data
===
true
||
data
===
false
)
{
console
.
log
(
`
${
pf
}
skip
2
`
);
console
.
log
(
`
${
pf
}
skip
3
`
);
continue
;
}
let
fn
=
task
.
getFileName
();
const
isJson
=
fn
.
endsWith
(
'.json'
);
if
(
isJson
)
{
const
route
=
data
.
__route
;
delete
data
.
__route
;
const
headers
=
{
'Content-Type'
:
'application/json'
}
await
uploadFile
(
fn
,
data
,
{
isJson
,
headers
,
route
});
if
(
isDownload
)
{
const
blob
=
new
Blob
([
data
],
{
"type"
:
"application/json"
});
downloadFile
(
fn
,
blob
);
// const blob = new Blob([data], { "type": "application/json" });
// downloadFile(fn, blob);
console
.
log
(
data
);
}
}
else
{
fn
=
fn
.
replace
(
/
\.\w
+$/g
,
".zip"
);
if
(
isSingle
)
{
const
zip
=
await
createZip
([
data
],
[
fn
]);
const
form
=
new
FormData
();
form
.
append
(
"zipfile"
,
zip
,
fn
);
await
uploadFile
(
fn
,
form
);
}
else
{
allData
.
push
(
data
);
allFn
.
push
(
fn
);
}
}
console
.
log
(
`
${
pf
}
end:
${
fn
}
`
);
await
sleep
(
moment
);
}
...
...
@@ -62,7 +77,7 @@ export async function run(options = {}) {
const
zip
=
await
createZip
(
allData
,
allFn
);
const
form
=
new
FormData
();
form
.
append
(
"zipfile"
,
zip
,
zipFn
);
await
uploadFile
(
zipFn
,
form
);
await
uploadFile
(
zipFn
,
form
,
{
isCheck
:
true
}
);
isDownload
&&
downloadFile
(
zipFn
,
zip
);
}
addLog
(
`
${
name
}
运行完成`
);
...
...
plugin/src/task.js
View file @
cf92a603
...
...
@@ -134,6 +134,10 @@ export class Task {
}
return
createZip
([
blob
],
[
fn
]);
}
catch
(
e
)
{
if
(
e
.
message
===
'Failed to fetch'
)
{
console
.
info
(
`重试 fetch`
);
return
this
.
_retry
(
arguments
);
}
console
.
error
(
`send
${
e
.
message
}
${
JSON
.
stringify
(
this
)}
`
);
return
false
;
}
...
...
plugin/src/upload.js
View file @
cf92a603
...
...
@@ -40,11 +40,10 @@ export async function uploadFile(fn, data, options = {}) {
}
else
{
url
=
options
.
isLink
?
linkURL
:
fileURL
;
}
if
(
await
checkLog
(
fn
))
{
if
(
options
.
isCheck
&&
!
await
checkLog
(
fn
))
return
;
const
insert
=
await
retry
(
async
()
=>
upload
(
url
,
data
,
options
.
headers
),
{
delayMs
:
1000
*
60
*
1.5
}
{
delayMs
:
1000
*
60
*
1.5
,
retries
:
10
}
);
if
(
insert
)
await
checkLog
(
fn
,
true
);
}
}
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