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
cce8427c
Commit
cce8427c
authored
Jan 17, 2022
by
edwin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
not longer trigger content script if sku not found on idArray
parent
5405186a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
8 deletions
+20
-8
background.js
background.js
+0
-1
contentScript.js
contentScript.js
+20
-7
No files found.
background.js
View file @
cce8427c
...
...
@@ -49,7 +49,6 @@ chrome.downloads.onDeterminingFilename.addListener(function(item, suggest) {
// skus = items.idArray.split(',');
// });
// }
console
.
log
(
item
.
url
);
if
(
item
.
url
.
includes
(
"https://digitallibrary-external.fastretailing.com/api/asset"
)){
var
new_filename
=
skus
[
index
]
+
".zip"
;
suggest
({
filename
:
new_filename
});
...
...
contentScript.js
View file @
cce8427c
...
...
@@ -21,17 +21,30 @@ if (link.match(/login/g)){
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
);
});
window
.
onload
=
function
()
{
window
.
onload
=
async
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
=
0
;
let
getIndex
=
async
function
(){
return
new
Promise
(
resolve
=>
{
chrome
.
storage
.
local
.
get
(
'idArray'
,
function
(
items
)
{
a
=
items
.
idArray
.
split
(
','
);
var
sku
=
document
.
location
.
href
.
match
(
/
[
0-9
]{6}
/g
).
toString
();
resolve
(
a
.
indexOf
(
sku
));
});
});
}
index
=
await
getIndex
();
// if cannot found index from storage
if
(
index
===
-
1
){
return
;
}
//Scroll down every 4 second, if 3 times no scroll change, download images
var
scroll
=
setInterval
(
function
()
{
var
currentScrollTop
=
el
.
scrollTop
;
...
...
@@ -39,7 +52,7 @@ if (link.match(/login/g)){
var
scrolledTop
=
el
.
scrollTop
;
console
.
log
(
scrolledTop
-
currentScrollTop
);
if
(
scrolledTop
-
currentScrollTop
==
0
)
{
count
+=
1
;
count
+=
1
;
}
else
{
count
=
0
;
}
...
...
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