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
efb74216
Commit
efb74216
authored
Sep 08, 2020
by
ronald
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added handling for no result and no second list images, added notification
parent
027534b3
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
17 deletions
+21
-17
background.js
background.js
+8
-0
contentScript.js
contentScript.js
+13
-17
No files found.
background.js
View file @
efb74216
'use strict'
;
var
initial
=
0
;
var
skus
=
[];
var
noImages
=
""
;
chrome
.
declarativeContent
.
onPageChanged
.
removeRules
(
undefined
,
function
()
{
chrome
.
declarativeContent
.
onPageChanged
.
addRules
([{
...
...
@@ -18,16 +19,23 @@ chrome.extension.onMessage.addListener(function(request,sender,sendResponse){
console
.
log
(
skus
);
}
else
if
(
request
.
nothing
==
"true"
)
{
console
.
log
(
"Message : nothing "
);
noImages
+=
(
request
.
currentSku
+
": no duplicate files
\n
"
);
initial
++
;
}
else
if
(
request
.
noImage
==
"true"
)
{
console
.
log
(
"Message : noImages"
);
noImages
+=
(
request
.
currentSku
+
": no results/ no valid images
\n
"
);
initial
+=
2
;
}
console
.
log
(
"Current index : "
,
initial
);
console
.
log
(
"Current noImages : "
,
noImages
);
});
chrome
.
downloads
.
onDeterminingFilename
.
addListener
(
function
(
item
,
suggest
)
{
var
new_filename
=
skus
[
initial
]
+
".zip"
;
suggest
({
filename
:
new_filename
});
initial
++
;
if
(
skus
.
length
-
1
==
initial
)
{
console
.
log
(
"Last file was downloaded"
);
alert
(
noImages
);
}
});
contentScript.js
View file @
efb74216
var
link
=
document
.
location
.
href
;
var
logined
=
false
;
var
a
=
[];
var
index
=
0
;
var
reducedLength
;
//If at login site, fill in login infos
if
(
link
.
match
(
/login/g
)){
window
.
onload
=
function
()
{
...
...
@@ -19,24 +17,20 @@ if (link.match(/login/g)){
});
//If at asset page, automate scrollDown and fliter process
}
else
if
(
link
.
match
(
/asset
\?
/g
))
{
var
a
=
[];
var
index
=
0
;
var
noImage
=
false
;
//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
);
reducedLength
=
a
.
length
;
});
console
.
log
(
"Array : "
,
a
);
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"
);
if
(
el
.
innerText
.
match
(
"No Results"
))
{
console
.
log
(
"Nothing to Download!! , index: "
,
index
,
" "
,
a
);
window
.
open
(
"https://digitallibrary-external.fastretailing.com/asset?t=datacategory%2Fasset&w="
+
a
[
index
+
2
]
+
"&r=north"
);
chrome
.
runtime
.
sendMessage
({
noImage
:
"true"
});
return
;
}
var
count
=
0
;
//Scroll down every 4 second, if 3 times no scroll change, download images
var
scroll
=
setInterval
(
function
()
{
...
...
@@ -77,9 +71,13 @@ if (link.match(/login/g)){
});
downloadlist
=
document
.
querySelectorAll
(
".panel-inner .is-checked"
);
if
(
downloadlist
.
length
==
0
)
{
noImage
=
true
;
}
if
(
noImage
)
{
console
.
log
(
"Nothing to Download!! , index: "
,
index
,
" "
,
a
);
window
.
open
(
"https://digitallibrary-external.fastretailing.com/asset?t=datacategory%2Fasset&w="
+
a
[
index
+
2
]
+
"&r=north"
);
chrome
.
runtime
.
sendMessage
({
noImage
:
"true"
});
if
(
index
+
2
!=
a
.
length
)
window
.
open
(
"https://digitallibrary-external.fastretailing.com/asset?t=datacategory%2Fasset&w="
+
a
[
index
+
2
]
+
"&r=north"
);
chrome
.
runtime
.
sendMessage
({
noImage
:
"true"
,
currentSku
:
currentSku
});
return
;
}
// To prevent file loss for duplicate images name in zip file, will download twice for one sku
...
...
@@ -104,16 +102,14 @@ if (link.match(/login/g)){
console
.
log
(
"Second List : "
,
secondList
);
if
(
secondList
.
length
==
0
)
{
console
.
log
(
"Second List has nothing"
);
chrome
.
runtime
.
sendMessage
({
nothing
:
"true"
});
reducedLength
--
;
console
.
log
(
"Reduced length : "
,
reducedLength
);
chrome
.
runtime
.
sendMessage
({
nothing
:
"true"
,
currentSku
:
currentSku
});
}
secondList
.
forEach
(
function
(
a
)
{
a
.
click
();
});
document
.
querySelector
(
"#assets_btn_download_asset"
).
click
();
setTimeout
(
function
(){
if
(
index
+
2
!=
reducedL
ength
)
if
(
index
+
2
!=
a
.
l
ength
)
window
.
open
(
"https://digitallibrary-external.fastretailing.com/asset?t=datacategory%2Fasset&w="
+
a
[
index
+
2
]
+
"&r=north"
);
},
5000
);
},
5000
);
...
...
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