Commit 0d778427 authored by edwin's avatar edwin

push file for api fetch

parent 00e12d50
......@@ -32,24 +32,27 @@ chrome.extension.onMessage.addListener(function(request,sender,sendResponse){
}
console.log("Current index : ", index);
console.log("Current noImages : " , noImages);
if(index >= skus.length-1) {
if(index >= skus.length) {
console.log("Last file was downloaded");
alert(noImages);
index = 0;
noImages = "";
}
});
chrome.downloads.onDeterminingFilename.addListener(function(item, suggest) {
if(!skus.length){
chrome.storage.local.get('idArray', function (items) {
skus = items.idArray.split(',');
});
}
// if(!skus.length){
// chrome.storage.local.get('idArray', function (items) {
// skus = items.idArray.split(',');
// });
// }
var new_filename = skus[index] + ".zip";
suggest({filename: new_filename});
index++;
if(index >= skus.length-1) {
if(index >= skus.length) {
console.log("Last file was downloaded");
alert(noImages);
}
......
......@@ -3,18 +3,18 @@ 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();
}
// 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");
});
// 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 a = [];
......@@ -74,7 +74,7 @@ if (link.match(/login/g)){
if(!a.querySelector(".name").innerText.match(currentSku)) {
a.click();
}
}
}
});
downloadlist = document.querySelectorAll(".panel-inner .is-checked");
if(downloadlist.length == 0) {
......@@ -111,13 +111,13 @@ if (link.match(/login/g)){
document.querySelector("#assets_btn_download_asset").click();
//After first list download, download second list 5s later
setTimeout(function(){
console.log("Second List : ", secondList);
if(secondList.length == 0) {
console.log("Second List has nothing");
chrome.runtime.sendMessage({nothing : "true", currentSku : currentSku});
}
secondList.forEach(function(a) {
a.click();
console.log("Second List : ", secondList);
if(secondList.length == 0) {
console.log("Second List has nothing");
chrome.runtime.sendMessage({nothing : "true", currentSku : currentSku});
}
secondList.forEach(function(a) {
a.click();
});
document.querySelector("#assets_btn_download_asset").click();
setTimeout(function(){
......
This diff is collapsed.
#fetch-lightbox, #fetch-lightbox *{
box-sizing: border-box;
}
#fetch-lightbox{
width: 100%;
height: 100%;
position: fixed;
top: 0;
left: 0;
background-color: rgba(0,0,0,0.5);
padding: 50px;
display: none;
z-index: 2500;
}
#fetch-lightbox.on{
display: block;
}
#fetch-lightbox .close-btn{
width: 30px;
height: 30px;
position: fixed;
right: 15px;
top: 15px;
}
#fetch-lightbox .lightbox-content{
width: 100%;
height: 100%;
padding: 40px;
border-radius: 5px;
background-color: white;
display: grid;
grid-template-columns: 150px 1fr 250px;
grid-template-rows: 1fr 2fr;
}
#fetch-lightbox .lightbox-content > div{
padding: 15px;
}
#fetch-lightbox h6{
margin: 0 0 10px;
font-size: 1.2em;
}
#fetch-lightbox textarea{
width: 100px;
height: 80%;
}
#fetch-lightbox .input-box{
display: flex;
align-items: center;
}
#fetch-lightbox input{
flex-grow: 1;
height: 30px;
margin-bottom: 15px;
}
#fetch-lightbox label{
margin-bottom: 15px;
margin-right: 5px;
}
#fetch-lightbox .cookie-remark{
font-size: 0.8em;
margin-top: 0;
margin-bottom: 15px;
}
#fetch-lightbox .debug-box{
grid-column-start: 1;
grid-column-end: 4;
grid-row-start: 2;
border: 2px solid #cccccc;
border-radius: 5px;
overflow: scroll;
}
#fetch-lightbox .asset-item{
width: 200px;
margin: 3px;
padding: 10px;
display: inline-block;
text-align: center;
}
#fetch-lightbox .asset-item.on{
background-color: #cccccc;
}
#fetch-lightbox .asset-item p{
margin: 5px 0;
font-size: 0.9em;
}
#fetch-lightbox .asset-item > div{
width: 100%;
height: 250px;
display: flex;
align-items: center;
}
#fetch-lightbox .asset-item img{
width: 100%;
max-height: 100%;
object-fit: contain;
}
#searchSKUs, #downloadSelectedSKUs, #downloadAllSKUs{
display: inline-block;
padding: 12px;
margin-bottom: 5px;
border: 2px solid transparent;
border-radius: 5px;
cursor: pointer;
}
#searchSKUs:hover, #downloadSelectedSKUs:hover, #downloadAllSKUs:hover{
border-color: black;
}
#searchSKUs{
background-color: hsl(40, 77%, 83%);
}
#downloadSelectedSKUs{
background-color: hsl(60, 77%, 83%);
}
#downloadAllSKUs{
background-color: hsl(80, 77%, 83%);
}
#lightbox-switch{
position: fixed;
right: 0px;
bottom: 0px;
background-color: white;
padding: 12px;
z-index: 1000;
}
\ No newline at end of file
<div id="fetch-lightbox">
<div class="close-btn">
<svg version="1.1" viewBox="0 0 512 512" xml:space="preserve" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<path fill="white" d="M443.6,387.1L312.4,255.4l131.5-130c5.4-5.4,5.4-14.2,0-19.6l-37.4-37.6c-2.6-2.6-6.1-4-9.8-4c-3.7,0-7.2,1.5-9.8,4 L256,197.8L124.9,68.3c-2.6-2.6-6.1-4-9.8-4c-3.7,0-7.2,1.5-9.8,4L68,105.9c-5.4,5.4-5.4,14.2,0,19.6l131.5,130L68.4,387.1 c-2.6,2.6-4.1,6.1-4.1,9.8c0,3.7,1.4,7.2,4.1,9.8l37.4,37.6c2.7,2.7,6.2,4.1,9.8,4.1c3.5,0,7.1-1.3,9.8-4.1L256,313.1l130.7,131.1 c2.7,2.7,6.2,4.1,9.8,4.1c3.5,0,7.1-1.3,9.8-4.1l37.4-37.6c2.6-2.6,4.1-6.1,4.1-9.8C447.7,393.2,446.2,389.7,443.6,387.1z"/>
</svg>
</div>
<div class="lightbox-content">
<div class="sku-box">
<h6>SKU List:</h6>
<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
</p>
</div>
<div class="operation-box">
<h6>Search and Download</h6>
<div class="input-box">
<label>Date: </label>
<input type="text" id="filter-date" name="filter-date" value="7" >
</div>
<button id="searchSKUs">Search</button>
<button id="downloadSelectedSKUs">Download</button>
<h6>Download All SKUs</h6>
<button id="downloadAllSKUs">Download</button>
<a id="download-trigger" href="#" download hidden >Download</a>
</div>
<div class="debug-box">
</div>
</div>
</div>
<div id="lightbox-switch">Open Fetch Menu</div>
\ No newline at end of file
{
"name" : "Image Downloader",
"version" : "1.0",
"version" : "2.0",
"description" : "The extension for downloading images",
"description" : "The extension for downloading images - NEW",
"background" : {
"scripts" : ["background.js"],
......@@ -29,6 +29,13 @@
{
"matches": ["<all_urls>"],
"js": ["jquery.min.js","contentScript.js"]
},
{
"matches": ["https://digitallibrary-external.fastretailing.com/"],
"js": ["fetch/fetch.js"],
"css": ["fetch/lightbox.css"]
}
]
],
"web_accessible_resources": ["fetch/lightbox.html"]
}
\ No newline at end of file
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