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
a3696193
Commit
a3696193
authored
Sep 01, 2020
by
ronald
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
wont download poster and >1MB product image, download 2 list of images
parent
b4746e9a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
56 additions
and
3 deletions
+56
-3
contentScript.js
contentScript.js
+46
-2
popup.js
popup.js
+10
-1
No files found.
contentScript.js
View file @
a3696193
var
link
=
document
.
location
.
href
;
var
logined
=
false
;
//If at login site, fill in login infos
if
(
link
.
match
(
/login/g
)){
window
.
onload
=
function
()
{
document
.
querySelector
(
"#login_input_user_name"
).
value
=
"myra@documentonready.com"
;
document
.
querySelector
(
"#login_input_password"
).
value
=
"GUmyra12345"
;
document
.
querySelector
(
".jss70"
).
click
();
}
//If logined, get the idArray and go to the first asset page
}
else
if
(
link
==
"https://digitallibrary-external.fastretailing.com/"
&&
!
logined
)
{
logined
=
true
;
chrome
.
storage
.
local
.
get
(
'idArray'
,
function
(
items
)
{
var
a
=
items
.
idArray
.
split
(
','
);
document
.
location
.
href
=
(
"https://digitallibrary-external.fastretailing.com/asset?t=datacategory%2Fasset&w="
+
a
[
0
]
+
"&r=north"
);
});
//If at asset page, automate scrollDown and fliter process
}
else
if
(
link
.
match
(
/asset
\?
/g
))
{
var
index
;
var
a
;
//Get back the current sku's index from idArray
chrome
.
storage
.
local
.
get
(
'idArray'
,
function
(
items
)
{
a
=
items
.
idArray
.
split
(
','
);
var
sku
=
document
.
location
.
href
.
match
(
/
[
0-9
]{6}
/g
).
toString
();
index
=
a
.
indexOf
(
sku
);
});
window
.
onload
=
function
()
{
var
currentSku
=
document
.
location
.
href
.
match
(
/w=.*&/g
);
currentSku
=
currentSku
.
toString
().
replace
(
/
(
w=|&
)
/g
,
""
);
var
el
=
document
.
querySelector
(
".jsx-334935779 .asset-list"
);
var
count
;
//Scroll down every 4 second, if 3 times no scroll change, download images
var
scroll
=
setInterval
(
function
()
{
var
currentScrollTop
=
el
.
scrollTop
;
el
.
scrollBy
(
0
,
5000
);
...
...
@@ -36,19 +43,56 @@ if (link.match(/login/g)){
clearInterval
(
scroll
);
var
downloadlist
=
document
.
querySelectorAll
(
".panel-inner"
);
downloadlist
.
forEach
(
function
(
a
)
{
//Must be jpg / gif
if
(
a
.
innerText
.
match
(
/
(
jpg|gif
)
/g
))
{
a
.
click
();
//Unselect >1MB Product images
if
(
a
.
innerText
.
match
(
/PDP
\(
Product Cut
\)
/g
))
{
if
(
a
.
innerText
.
match
(
/MB/g
))
a
.
click
();
}
//Unselect posters
if
(
a
.
innerText
.
match
(
/Poster/g
))
a
.
click
();
//If images names start with "G" but it isnt a model image, unselect
if
(
a
.
innerText
.
match
(
/^G/g
))
{
if
(
!
a
.
innerText
.
match
(
/Model/g
))
a
.
click
();
}
//If images doesnt have sku, unselect
if
(
!
a
.
querySelector
(
".name"
).
innerText
.
match
(
currentSku
))
a
.
click
();
}
});
downloadlist
=
document
.
querySelectorAll
(
".panel-inner .is-checked"
);
// To prevent file loss for duplicate images name in zip file, will download twice for one sku
// Duplicated files download at second file "sku(copy).zip"
var
nameList
=
[];
var
secondList
=
[];
downloadlist
.
forEach
(
function
(
a
)
{
var
fileType
=
a
.
innerText
.
match
(
/
(
jpg|gif
)
/g
);
var
name
=
a
.
querySelector
(
".name"
).
innerText
;
name
=
name
+
fileType
;
if
(
nameList
.
indexOf
(
name
)
==
-
1
)
{
nameList
.
push
(
name
);
}
else
{
a
.
click
();
secondList
.
push
(
a
);
}
});
downloadlist
=
document
.
querySelectorAll
(
".panel-inner .is-checked"
);
document
.
querySelector
(
"#assets_btn_download_asset"
).
click
();
if
(
index
+
1
!=
a
.
length
)
window
.
open
(
"https://digitallibrary-external.fastretailing.com/asset?t=datacategory%2Fasset&w="
+
a
[
index
+
1
]
+
"&r=north"
);
//After first list download, download second list 5s later
setTimeout
(
function
(){
secondList
.
forEach
(
function
(
a
)
{
a
.
click
();
});
document
.
querySelector
(
"#assets_btn_download_asset"
).
click
();
setTimeout
(
function
(){
if
(
index
+
2
!=
a
.
length
)
window
.
open
(
"https://digitallibrary-external.fastretailing.com/asset?t=datacategory%2Fasset&w="
+
a
[
index
+
2
]
+
"&r=north"
);
},
5000
);
},
5000
);
}
},
4000
);
}
...
...
popup.js
View file @
a3696193
...
...
@@ -6,7 +6,16 @@ var idArray;
inputButton
.
onclick
=
function
(
element
)
{
console
.
log
(
"hi"
);
var
text
=
document
.
querySelector
(
"textarea"
).
value
.
trim
().
split
(
'
\
n'
);
idArray
=
text
.
join
(
','
);
console
.
log
(
"Text: "
,
text
,
text
.
length
);
var
finalText
=
[];
for
(
var
i
=
0
;
i
<
text
.
length
;
i
++
)
{
console
.
log
(
"Text[i] "
,
text
[
i
]);
finalText
.
push
(
text
[
i
]);
var
copyText
=
text
[
i
]
+
" copy"
;
finalText
.
push
(
copyText
);
}
console
.
log
(
"Final text = "
,
finalText
);
idArray
=
finalText
.
join
(
','
);
chrome
.
tabs
.
query
({
active
:
true
,
currentWindow
:
true
},
function
(
tabs
)
{
chrome
.
storage
.
local
.
set
({
idArray
:
idArray
},
function
()
{
console
.
log
(
"set storage"
);
...
...
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