2020-06-09 21:27:28 +08:00
|
|
|
let downloadBtn = document.getElementById('download');
|
2021-03-17 23:44:34 +08:00
|
|
|
let download2Btn = document.getElementById('download2');
|
|
|
|
let download3Btn = document.getElementById('download3');
|
|
|
|
let download4Btn = document.getElementById('download4');
|
2020-06-09 21:27:28 +08:00
|
|
|
//
|
|
|
|
// chrome.storage.sync.get('color', function(data) {
|
|
|
|
// changeColor.style.backgroundColor = data.color;
|
|
|
|
// changeColor.setAttribute('value', data.color);
|
|
|
|
// });
|
|
|
|
|
2021-03-17 23:44:34 +08:00
|
|
|
function sendActionAndResponse(actionStr) {
|
2020-06-09 21:27:28 +08:00
|
|
|
chrome.tabs.getSelected(null, function(tab) {
|
|
|
|
// Send a request to the content script.
|
2021-03-17 23:44:34 +08:00
|
|
|
chrome.tabs.sendRequest(tab.id, {action: actionStr}, function(response) {
|
2020-06-09 21:27:28 +08:00
|
|
|
console.log(response);
|
2020-06-24 17:17:22 +08:00
|
|
|
if (response.dataType == "urlList") {
|
|
|
|
const data = new URLSearchParams();
|
|
|
|
data.append("source", response.source);
|
|
|
|
data.append("urlList", JSON.stringify(response.urlList));
|
|
|
|
|
|
|
|
fetch('http://localhost:1704/urlList', {
|
|
|
|
method: 'post',
|
|
|
|
body: data,
|
|
|
|
}).then(data => {
|
|
|
|
console.log(data);
|
|
|
|
});
|
|
|
|
}
|
2020-06-09 21:27:28 +08:00
|
|
|
});
|
|
|
|
});
|
2021-03-17 23:44:34 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
downloadBtn.onclick = function(element) {
|
|
|
|
|
|
|
|
// chrome.tabs.query({currentWindow: true, active: true}, function(tabs) {
|
|
|
|
// console.log(tabs[0].url);
|
|
|
|
// });
|
|
|
|
|
|
|
|
sendActionAndResponse("requestPics");
|
2020-06-09 21:27:28 +08:00
|
|
|
|
|
|
|
// let color = element.target.value;
|
|
|
|
// chrome.tabs.query({active: true, currentWindow: true}, function(tabs) {
|
|
|
|
// chrome.tabs.executeScript(
|
|
|
|
// tabs[0].id,
|
|
|
|
// {code: 'document.body.style.backgroundColor = "' + color + '";'});
|
|
|
|
// });
|
|
|
|
};
|
2021-03-17 23:44:34 +08:00
|
|
|
|
|
|
|
download2Btn.onclick = function(element) { sendActionAndResponse("requestPics2"); }
|
|
|
|
download3Btn.onclick = function(element) { sendActionAndResponse("requestPics3"); }
|
|
|
|
download4Btn.onclick = function(element) { sendActionAndResponse("requestPics4"); }
|