diff --git a/package.json b/package.json index 475607e..7b8cec5 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,6 @@ }, "dependencies": { "@antv/g2plot": "^2.4.31", - "@toast-ui/vue-image-editor": "^3.15.2", "axios": "^1.4.0", "core-js": "^3.8.3", "dayjs": "^1.11.9", diff --git a/public/js/download.js b/public/js/download.js index bfc15c5..9b08258 100644 --- a/public/js/download.js +++ b/public/js/download.js @@ -33,42 +33,160 @@ function init() { baseList.push({type: 1, index: j+1, src: obj.imageComponent.imagePathList[j]}) } + var video = document.querySelector('video') + if (video) { + baseList.push({type: 2, index: 1, src: video.src}) + } + var zip = new JSZip(); - var imgsBanner = zip.folder("轮插图"); + var imgsBanner = zip.folder("轮播图"); var imgsDetail = zip.folder("详情图"); + var videos = zip.folder("视频"); for (var k = 0; k < baseList.length; k++) { let type = baseList[k].type let index = baseList[k].index - let image = new Image(); - // 解决跨域 Canvas 污染问题 - image.setAttribute("crossOrigin", "anonymous"); - image.onload = function () { - let canvas = document.createElement("canvas"); - canvas.width = image.width; - canvas.height = image.height; - let context = canvas.getContext("2d"); - context.drawImage(image, 0, 0, image.width, image.height); - let url = canvas.toDataURL(); // 得到图片的base64编码数据 - canvas.toDataURL("image/png"); - downloadList.push({type: type, index: index, data: url.substring(22)}); // 去掉base64编码前的 data:image/png;base64, - if (downloadList.length === baseList.length && downloadList.length > 0) { - for (let l = 0; l < downloadList.length; l++) { - if (downloadList[l].type == '0') { - imgsDetail.file(`详情图${downloadList[l].index}.png`, downloadList[l].data, { base64: true }); - } else if (downloadList[l].type == '1') { - imgsBanner.file(`轮播图${downloadList[l].index}.png`, downloadList[l].data, { base64: true }); - } + if (type == 2) { + let x = new XMLHttpRequest() + x.open('GET', baseList[k].src, true) + x.responseType = 'blob' + x.onload = (e) => { + downloadList.push({type: type, index: index, data: x.response}); + if (downloadList.length === baseList.length && downloadList.length > 0) { + for (let l = 0; l < downloadList.length; l++) { + if (downloadList[l].type == '0') { + imgsDetail.file(`详情图${downloadList[l].index}.png`, downloadList[l].data, { base64: true }); + } else if (downloadList[l].type == '1') { + imgsBanner.file(`轮播图${downloadList[l].index}.png`, downloadList[l].data, { base64: true }); + } else if (downloadList[l].type == '2') { + videos.file(`视频.mp4`, downloadList[l].data, { Blob: true }); + } + } + zip.generateAsync({ type: "blob" }).then(function (content) { + // see FileSaver.js + saveAs(content, "aliexpress_" + id + ".zip"); + }); + } } - zip.generateAsync({ type: "blob" }).then(function (content) { - // see FileSaver.js - saveAs(content, "aliexpress_" + id + ".zip"); - }); - } - }; - image.src = baseList[k].src; + x.send() + } else { + let image = new Image(); + // 解决跨域 Canvas 污染问题 + image.setAttribute("crossOrigin", "anonymous"); + image.onload = function () { + let canvas = document.createElement("canvas"); + canvas.width = image.width; + canvas.height = image.height; + let context = canvas.getContext("2d"); + context.drawImage(image, 0, 0, image.width, image.height); + let url = canvas.toDataURL(); // 得到图片的base64编码数据 + canvas.toDataURL("image/png"); + downloadList.push({type: type, index: index, data: url.substring(22)}); // 去掉base64编码前的 data:image/png;base64, + if (downloadList.length === baseList.length && downloadList.length > 0) { + for (let l = 0; l < downloadList.length; l++) { + if (downloadList[l].type == '0') { + imgsDetail.file(`详情图${downloadList[l].index}.png`, downloadList[l].data, { base64: true }); + } else if (downloadList[l].type == '1') { + imgsBanner.file(`轮播图${downloadList[l].index}.png`, downloadList[l].data, { base64: true }); + } else if (downloadList[l].type == '2') { + videos.file(`视频.mp4`, downloadList[l].data, { Blob: true }); + } + } + zip.generateAsync({ type: "blob" }).then(function (content) { + // see FileSaver.js + saveAs(content, "aliexpress_" + id + ".zip"); + }); + } + }; + image.src = baseList[k].src; + } } }) document.body.appendChild(popup) + } else if (window.location.href.startsWith('https://www.amazon.com/')) { + var content = document.getElementById('ATFCriticalFeaturesDataContainer').innerHTML + content = content.substring(content.indexOf('jQuery.parseJSON(')) + content = content.substring(content.indexOf("(")) + content = content.substring(2, content.indexOf("');")) + let obj = JSON.parse(content) + let colorImages = obj.colorImages + if (colorImages) { + const popup = document.createElement("div") + popup.innerText = "下载图片" + const styles = { + position: "fixed", + right: '10px', + top: '60px', + zIndex: 9999, + padding: "8px", + background: "#409EFF", + color: "#fff", + borderRadius: "8px", + cursor: "pointer" + } + for (const e in styles) { + popup.style[e] = styles[e] + } + + popup.addEventListener('click', async () => { + var baseList = []; + var downloadList = [] + + var zip = new JSZip(); + var imgsBanner = zip.folder("轮播图"); + var imgsDetail = zip.folder("详情图"); + // var videos = zip.folder("视频"); + + for (let i in colorImages) { + let folderName = imgsBanner.folder(i) + let item1 = colorImages[i] + let index = 0 + for (let j in item1) { + let item2 = item1[j] + baseList.push({type: 1, index: ++index, src: item2.hiRes, folder: folderName}) + } + } + + var imgObjList = document.querySelectorAll('div.aplus-v2 img') + for (var i = 0; i < imgObjList.length; i++) { + baseList.push({type: 0, index: i+1, src: imgObjList[i].getAttribute('data-src'), folder: imgsDetail}) + } + + for (var k = 0; k < baseList.length; k++) { + let type = baseList[k].type + let index = baseList[k].index + let folder = baseList[k].folder + + let image = new Image(); + // 解决跨域 Canvas 污染问题 + image.setAttribute("crossOrigin", "anonymous"); + image.onload = function () { + let canvas = document.createElement("canvas"); + canvas.width = image.width; + canvas.height = image.height; + let context = canvas.getContext("2d"); + context.drawImage(image, 0, 0, image.width, image.height); + let url = canvas.toDataURL(); // 得到图片的base64编码数据 + canvas.toDataURL("image/png"); + downloadList.push({type: type, index: index, folder: folder, data: url.substring(22)}); // 去掉base64编码前的 data:image/png;base64, + if (downloadList.length === baseList.length && downloadList.length > 0) { + for (let l = 0; l < downloadList.length; l++) { + if (downloadList[l].type == '0') { + downloadList[l].folder.file(`详情图${downloadList[l].index}.png`, downloadList[l].data, { base64: true }); + } else if (downloadList[l].type == '1') { + downloadList[l].folder.file(`轮播图${downloadList[l].index}.png`, downloadList[l].data, { base64: true }); + } + } + zip.generateAsync({ type: "blob" }).then(function (content) { + // see FileSaver.js + saveAs(content, "amazon.zip"); + }); + } + }; + image.src = baseList[k].src; + } + }) + document.body.appendChild(popup) + } } } diff --git a/src/assets/logo.png b/src/assets/logo.png deleted file mode 100644 index f3d2503..0000000 Binary files a/src/assets/logo.png and /dev/null differ diff --git a/src/assets/qrcode.jpg b/src/assets/qrcode.jpg deleted file mode 100644 index df52adc..0000000 Binary files a/src/assets/qrcode.jpg and /dev/null differ diff --git a/src/manifest.development.json b/src/manifest.development.json index c30cdd7..2a94a45 100644 --- a/src/manifest.development.json +++ b/src/manifest.development.json @@ -16,7 +16,8 @@ "host_permissions": [ "*://*.pinduoduo.com/", "*://*.temu.com/", - "*://*.aliexpress.us/" + "*://*.aliexpress.us/", + "*://*.amazon.com/" ], "permissions": [ "cookies", @@ -39,7 +40,8 @@ "content_scripts": [ { "matches": [ - "*://*.aliexpress.us/item/*" + "*://*.aliexpress.us/item/*", + "*://*.amazon.com/*" ], "js": [ "/content.js" @@ -49,7 +51,7 @@ "web_accessible_resources": [ { "resources": [ "js/download.js","js/jszip.min.js","js/FileSaver.js" ], - "matches": [ "*://*.aliexpress.us/*" ] + "matches": [ "*://*.aliexpress.us/*", "*://*.amazon.com/*" ] } ] } diff --git a/src/manifest.production.json b/src/manifest.production.json index 7c5ab27..b7d7355 100644 --- a/src/manifest.production.json +++ b/src/manifest.production.json @@ -16,7 +16,8 @@ "host_permissions": [ "*://*.pinduoduo.com/", "*://*.temu.com/", - "*://*.aliexpress.us/" + "*://*.aliexpress.us/", + "*://*.amazon.com/" ], "permissions": [ "cookies", @@ -39,7 +40,8 @@ "content_scripts": [ { "matches": [ - "*://*.aliexpress.us/item/*" + "*://*.aliexpress.us/item/*", + "*://*.amazon.com/*" ], "js": [ "/content.js" @@ -49,7 +51,7 @@ "web_accessible_resources": [ { "resources": [ "js/download.js","js/jszip.min.js","js/FileSaver.js" ], - "matches": [ "*://*.aliexpress.us/*" ] + "matches": [ "*://*.aliexpress.us/*", "*://*.amazon.com/*" ] } ] } diff --git a/src/view/login/Register.vue b/src/view/login/Register.vue index 1ef77b4..977e0a5 100644 --- a/src/view/login/Register.vue +++ b/src/view/login/Register.vue @@ -27,6 +27,10 @@ :rules="[{ required: true, message: '请再次输入密码', trigger: 'blur' }]"> + + +
@@ -56,6 +60,7 @@ password: '', repassword: '', code: '', + inviteCode: '', phone: '' }, phoneReg: (rule, value, callback) => { diff --git a/src/view/product/NiubiCopy.vue b/src/view/product/NiubiCopy.vue index efc51f3..b8e36eb 100644 --- a/src/view/product/NiubiCopy.vue +++ b/src/view/product/NiubiCopy.vue @@ -12,11 +12,11 @@ @@ -56,7 +61,7 @@ customFooter @close="handleClose"> - + TEMU @@ -89,163 +94,8 @@