Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
G
gu imageworks extension
Project
Project
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
joetsuihk
gu imageworks extension
Commits
a3c5daa4
Commit
a3c5daa4
authored
Jan 18, 2022
by
edwin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remove cookie section since discover that it will already send the session data
parent
9539e807
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
86 deletions
+20
-86
fetch.js
fetch/fetch.js
+6
-46
lightbox.css
fetch/lightbox.css
+10
-11
lightbox.html
fetch/lightbox.html
+4
-29
No files found.
fetch/fetch.js
View file @
a3c5daa4
...
...
@@ -20,8 +20,8 @@
});
// operation
document
.
querySelector
(
"#saveSession"
).
addEventListener
(
"click"
,
saveSession
);
document
.
querySelector
(
"#loadSession"
).
addEventListener
(
"click"
,
loadSession
);
//
document.querySelector("#saveSession").addEventListener("click",saveSession);
//
document.querySelector("#loadSession").addEventListener("click",loadSession);
document
.
querySelector
(
"#searchSKUs"
).
addEventListener
(
"click"
,
startFetching
);
document
.
querySelector
(
"#downloadSelectedSKUs"
).
addEventListener
(
"click"
,
downloadFetching
);
...
...
@@ -57,52 +57,14 @@
}
}
function
generateCookie
(){
let
cookie
=
document
.
cookie
;
// HTTPOnly cookie require manual input
cookie
+=
"; digitallibrary-session="
+
document
.
getElementById
(
"session-string"
).
value
;
cookie
+=
"; digitallibrary-session.sig="
+
document
.
getElementById
(
"session-sig-string"
).
value
;
return
cookie
;
}
function
getHeader
(){
var
header
=
new
Headers
();
header
.
append
(
"authority"
,
"digitallibrary-external.fastretailing.com"
);
header
.
append
(
"pragma"
,
"no-cache"
);
header
.
append
(
"cache-control"
,
"no-cache"
);
header
.
append
(
"user-agent"
,
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.110 Safari/537.36"
);
header
.
append
(
"accept"
,
"*/*"
);
header
.
append
(
"accept-language"
,
"en-US,en;q=0.9,zh-TW;q=0.8,zh;q=0.7,zh-CN;q=0.6,ja;q=0.5"
);
header
.
append
(
"cookie"
,
generateCookie
());
return
header
;
}
function
getConfig
(
header
){
function
getConfig
(){
return
{
"method"
:
"GET"
,
"headers"
:
header
,
"mode"
:
"cors"
,
"redirect"
:
"follow"
};
}
function
saveSession
(){
let
sessionString
=
document
.
getElementById
(
"session-string"
).
value
;
let
sessionSigString
=
document
.
getElementById
(
"session-sig-string"
).
value
;
chrome
.
storage
.
local
.
set
({
"sessionString"
:
sessionString
,
"sessionSigString"
:
sessionSigString
});
}
function
loadSession
(){
chrome
.
storage
.
local
.
get
([
"sessionString"
,
"sessionSigString"
],
function
(
result
){
document
.
getElementById
(
"session-string"
).
value
=
result
.
sessionString
;
document
.
getElementById
(
"session-sig-string"
).
value
=
result
.
sessionSigString
});
}
/* End of utility function */
/* Start of main function */
...
...
@@ -215,8 +177,7 @@
let
currentms
=
new
Date
().
getTime
();
let
url
=
`
${
baseurl
}
api/asset?time=
${
currentms
}
&t=datacategory%2Fasset&w=
${
SKU
}
&r=north&z=
${
fetchNumber
}
&c=DEFAULT`
;
let
header
=
getHeader
();
let
config
=
getConfig
(
header
);
let
config
=
getConfig
();
addDebugMessage
(
`Start fetching SKU=
${
SKU
}
`
);
...
...
@@ -313,7 +274,7 @@
console
.
log
(
json
);
// prepare header for POST request
let
postheader
=
getHeader
();
let
postheader
=
new
Headers
();
postheader
.
append
(
"Content-Type"
,
"application/json"
);
postheader
.
append
(
"csrf-token"
,
document
.
querySelector
(
'meta[name="csrf-token"]'
).
content
);
postheader
.
append
(
"origin"
,
"https://digitallibrary-external.fastretailing.com"
);
...
...
@@ -333,7 +294,7 @@
});
// send GET request for downloading the zip file
fetch
(
`/api/asset/download/
${
response
.
token
}
`
,
getConfig
(
getHeader
()
))
fetch
(
`/api/asset/download/
${
response
.
token
}
`
,
getConfig
())
.
then
(
response
=>
response
.
blob
())
.
then
(
blob
=>
{
...
...
@@ -372,5 +333,4 @@
}
addLightBox
();
})();
\ No newline at end of file
fetch/lightbox.css
View file @
a3c5daa4
...
...
@@ -37,7 +37,7 @@
background-color
:
white
;
display
:
grid
;
grid-template-columns
:
150px
1
fr
250px
;
grid-template-columns
:
200px
1
fr
;
grid-template-rows
:
1
fr
2
fr
;
}
...
...
@@ -61,7 +61,7 @@
}
#fetch-lightbox
input
{
flex-grow
:
1
;
width
:
100%
;
height
:
30px
;
margin-bottom
:
15px
;
}
...
...
@@ -71,16 +71,10 @@
margin-right
:
5px
;
}
#fetch-lightbox
.cookie-remark
{
font-size
:
0.8em
;
margin-top
:
0
;
margin-bottom
:
15px
;
}
#fetch-lightbox
.info-box
{
grid-column-start
:
1
;
grid-
column-end
:
4
;
grid-row-
start
:
2
;
grid-column-start
:
2
;
grid-
row-start
:
1
;
grid-row-
end
:
3
;
border
:
2px
solid
#cccccc
;
border-radius
:
5px
;
...
...
@@ -89,6 +83,11 @@
position
:
relative
;
}
#fetch-lightbox
.operation-box
{
grid-column-start
:
1
;
grid-row-start
:
2
;
}
#fetch-lightbox
.info-message
{
position
:
absolute
;
top
:
10px
;
...
...
fetch/lightbox.html
View file @
a3c5daa4
...
...
@@ -11,30 +11,13 @@
<textarea
id=
"sku-list"
cols=
"20"
></textarea>
</div>
<div
class=
"cookie-box"
>
<h6>
Cookie
</h6>
<div
class=
"input-box"
>
<label>
digitallibrary-session:
</label>
<input
type=
"text"
id=
"session-string"
name=
"session"
autocomplete=
"off"
/>
</div>
<div
class=
"input-box"
>
<label>
digitallibrary-session.sig:
</label>
<input
type=
"text"
id=
"session-sig-string"
name=
"session-sig"
autocomplete=
"off"
/>
</div>
<p
class=
"cookie-remark"
>
Manuel input required because session cannot obtain from javascript
<br
/>
To copy the cookie string, go to:
Web Inspector > Application > Storage > Cookie
<div>
<button
id=
"saveSession"
>
Save Session
</button>
<button
id=
"loadSession"
>
Load Saved Session
</button>
</div>
</p>
<div
class=
"info-box"
>
<div
class=
"info-message"
></div>
<div
class=
"debug-box"
></div>
</div>
<div
class=
"operation-box"
>
<h6>
Search and Download
</h6>
<div
class=
"input-box"
>
<label>
Date:
</label>
...
...
@@ -45,15 +28,7 @@
<h6>
Download All SKUs
</h6>
<button
id=
"downloadAllSKUs"
>
Download
</button>
<a
id=
"download-trigger"
href=
"#"
download
hidden
>
Download
</a>
</div>
<div
class=
"info-box"
>
<div
class=
"info-message"
></div>
<div
class=
"debug-box"
></div>
</div>
</div>
...
...
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