diff --git a/common_content_script.js b/common_content_script.js index 95dc29d..332c840 100644 --- a/common_content_script.js +++ b/common_content_script.js @@ -2,21 +2,31 @@ function getElementByXpath(path) { return document.evaluate(path, document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null); } +function twitterXPath(nth, sendResponse) { + let a = getElementByXpath(`(//article[contains(@role,'article')])[${nth}]//a[contains(@href,'/photo/')]//img/@src`); + let arr = []; + for (i=0; i +
+ + + diff --git a/popup.js b/popup.js index f8c25a1..694ab62 100644 --- a/popup.js +++ b/popup.js @@ -1,19 +1,17 @@ let downloadBtn = document.getElementById('download'); +let download2Btn = document.getElementById('download2'); +let download3Btn = document.getElementById('download3'); +let download4Btn = document.getElementById('download4'); // // chrome.storage.sync.get('color', function(data) { // changeColor.style.backgroundColor = data.color; // changeColor.setAttribute('value', data.color); // }); -downloadBtn.onclick = function(element) { - -// chrome.tabs.query({currentWindow: true, active: true}, function(tabs) { -// console.log(tabs[0].url); -// }); - +function sendActionAndResponse(actionStr) { chrome.tabs.getSelected(null, function(tab) { // Send a request to the content script. - chrome.tabs.sendRequest(tab.id, {action: "requestPics"}, function(response) { + chrome.tabs.sendRequest(tab.id, {action: actionStr}, function(response) { console.log(response); if (response.dataType == "urlList") { const data = new URLSearchParams(); @@ -29,6 +27,15 @@ downloadBtn.onclick = function(element) { } }); }); +} + +downloadBtn.onclick = function(element) { + +// chrome.tabs.query({currentWindow: true, active: true}, function(tabs) { +// console.log(tabs[0].url); +// }); + + sendActionAndResponse("requestPics"); // let color = element.target.value; // chrome.tabs.query({active: true, currentWindow: true}, function(tabs) { @@ -37,3 +44,7 @@ downloadBtn.onclick = function(element) { // {code: 'document.body.style.backgroundColor = "' + color + '";'}); // }); }; + +download2Btn.onclick = function(element) { sendActionAndResponse("requestPics2"); } +download3Btn.onclick = function(element) { sendActionAndResponse("requestPics3"); } +download4Btn.onclick = function(element) { sendActionAndResponse("requestPics4"); } \ No newline at end of file