Commit 278da17f authored by edwin's avatar edwin

update popup logic, and indent

parent 0d778427
......@@ -4,40 +4,46 @@ let inputButton = document.getElementById('input');
var idArray;
inputButton.onclick = function(element) {
console.log("hi");
var text = document.querySelector("textarea").value.trim().split('\n');
console.log("Text: ",text ,text.length);
var finalText = [];
for(var i = 0; i < text.length; i++) {
console.log("Text[i] " , text[i]);
finalText.push(text[i]);
var copyText = text[i] + " copy";
finalText.push(copyText);
}
console.log("Final text = ", finalText);
idArray = finalText.join(',');
chrome.tabs.query({active: true, currentWindow: true}, function(tabs) {
chrome.storage.local.set({idArray : idArray}, function () {
console.log("set storage");
});
chrome.runtime.sendMessage({idArray: idArray});
});
console.log("hi");
var text = document.querySelector("textarea").value.trim().split('\n');
console.log("Text: ",text ,text.length);
var finalText = [];
for(var i = 0; i < text.length; i++) {
console.log("Text[i] " , text[i]);
finalText.push(text[i]);
var copyText = text[i] + " copy";
finalText.push(copyText);
}
console.log("Final text = ", finalText);
idArray = finalText.join(',');
chrome.tabs.query({active: true, currentWindow: true}, function(tabs) {
chrome.storage.local.set({idArray : idArray}, function () {
console.log("set storage");
});
chrome.runtime.sendMessage({idArray: idArray});
});
}
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.query({active: true, currentWindow: true}, function(tabs) {
let url = "";
chrome.storage.local.get('idArray', function (items) {
var a = items.idArray.split(',');
url = "https://digitallibrary-external.fastretailing.com/asset?t=datacategory%2Fasset&w="+ a[0] + "&r=north";
chrome.tabs.executeScript(tabs[0].id,{
code: `document.location.href = "${url}";`
});
});
});
};
// 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");
// });
// chrome.runtime.sendMessage(null);
// });
// }
// if(changeInfo.url) {
// chrome.tabs.query({active: true, currentWindow: true}, function(tabs) {
// chrome.storage.local.set({idArray : idArray}, function () {
// console.log("set storage");
// });
// chrome.runtime.sendMessage(null);
// });
// }
// });
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