Commit 3db277f6 authored by ronald's avatar ronald

add existing files

parent 55734f95
'use strict';
chrome.runtime.onInstalled.addListener(function() {
chrome.storage.sync.set({color: '#3aa757'}, function() {
console.log("The color is green.");
});
});
chrome.declarativeContent.onPageChanged.removeRules(undefined, function() {
chrome.declarativeContent.onPageChanged.addRules([{
conditions: [new chrome.declarativeContent.PageStateMatcher({
pageUrl: {schemes: ['http','https','www']},
})
],
actions: [new chrome.declarativeContent.ShowPageAction()]
}]);
});
var link = document.location.href;
var logined = false;
if (link.match(/login/g)){
window.onload = function() {
console.log("matched");
document.querySelector("#login_input_user_name").value="myra@documentonready.com";
document.querySelector("#login_input_password").value="MYra12345";
document.querySelector(".jss70").click();
}
} else if (link == "https://digitallibrary-external.fastretailing.com/" && !logined) {
logined = true;
console.log("Logined" + link);
chrome.storage.local.get('idArray', function (items) {
var a = items.idArray.split(',');
console.log(a.length);
for(var i = 0; i < a.length; i++)
window.open("https://digitallibrary-external.fastretailing.com/asset?t=datacategory%2Fasset&w="+ a[i] + "&r=north");
});
} else if (link.match(/asset\?/g)) {
console.log("At asset page");
window.onload = function() {
var el = document.querySelector(".jsx-334935779 .asset-list");
var count;
var scroll = setInterval(function() {
var currentScrollTop = el.scrollTop;
console.log("Current Top: ", currentScrollTop);
el.scrollBy(0,5000);
var scrolledTop = el.scrollTop;
console.log("Scrolled Top: ", scrolledTop);
console.log("Scroll diff : ", scrolledTop - currentScrollTop);
if(scrolledTop - currentScrollTop == 0) {
count +=1;
} else {
count = 0;
}
if(count == 3) {
console.log("Difference = 0");
clearInterval(scroll);
var downloadlist = document.querySelectorAll(".panel-inner");
console.log(downloadlist);
downloadlist.forEach(function(a) {
if(a.innerText.match(/(jpg|gif)/g)) {
a.click();
}
document.querySelector("#assets_btn_download_asset").click();
});
}
},3000);
console.log("exited");
}
}
\ No newline at end of file
This diff is collapsed.
{
"name" : "Image Downloader",
"version" : "1.0",
"description" : "The extension for downloading images",
"background" : {
"scripts" : ["background.js"],
"persistent" : false
},
"manifest_version" : 2,
"permissions" : ["tabs","*://*/*","activeTab","<all_urls>","declarativeContent","storage"],
"page_action": {
"default_popup": "popup.html",
"default_icon": {
"128": "images/Emoji-Nervous-icon.png"
}
},
"icons": {
"128": "images/Emoji-Nervous-icon.png"
},
"content_scripts": [
{
"matches": ["<all_urls>"],
"js": ["contentScript.js"]
}
]
}
\ No newline at end of file
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="style.css">
<script src="jquery.min.js"></script>
<script src="require.js"></script>
</head>
<body>
<div class= "main">
<h1>Image Downloader</h1>
<form>
<label>SKU to download: </label>
<textarea row="5",cols="6"></textarea>
</form>
<button id ="input">Input</button>
<button id="go-to-google">Go to Library</button>
<script src="popup.js"></script>
</div>
</body>
</html>
\ No newline at end of file
let toGoogle = document.getElementById('go-to-google');
let inputButton = document.getElementById('input');
var idArray;
inputButton.onclick = function(element) {
console.log("hi");
var text = document.querySelector("textarea").value.trim().split('\n');
idArray = text.join(',');
}
toGoogle.onclick = function(element) {
chrome.tabs.query({active: true, currentWindow: true}, function(tabs) {
const execute = chrome.tabs.executeScript(tabs[0].id,
{code: `document.location.href = "https://digitallibrary-external.fastretailing.com/";`});
});
};
chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab) {
if(changeInfo.url) {
chrome.tabs.query({active: true, currentWindow: true}, function(tabs) {
chrome.storage.local.set({idArray : idArray}, function () {
console.log("set storage");
});
});
}
});
\ No newline at end of file
This diff is collapsed.
* {
margin: 0;
padding: 0;
}
html{
background-color: black;
overflow: hidden;
font-family: Arial, Helvetica, sans-serif;
border: 2px solid grey;
}
body {
padding-bottom: 20px;
}
h1 {
font-size: 15px;
padding: 2px 5px;
color: white;
white-space: nowrap;
border-bottom: 1px solid white;
margin-bottom: 10px;
}
form {
padding: 0 5px;
}
label {
color: white;
}
#go-to-google {
padding: 10px 5px ;
margin-top: 20px;
outline: none;
position: relative;
left: 50%;
transform: translateX(-50%);
border-radius: 17px;
font-weight: 700;
background-color: purple;
color: white;
box-shadow: 0 0 11px 6px grey;
}
\ 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