Commit cce8427c authored by edwin's avatar edwin

not longer trigger content script if sku not found on idArray

parent 5405186a
......@@ -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});
......
......@@ -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;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment