Last active
September 14, 2021 09:26
-
-
Save and-rom/464344eef243825e097646b009406d7d to your computer and use it in GitHub Desktop.
AliExpress Feedback pictures sildeshow
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // ==UserScript== | |
| // @name AliExpress Feedback pictures sildeshow | |
| // @namespace https://gist.github.com/and-rom/464344eef243825e097646b009406d7d | |
| // @version 0.2.13 | |
| // @author and-rom | |
| // @description Press Alt+S to start slideshow, press Alt+C to show number of feedbacks with pictures. | |
| // @homepage https://gist.github.com/and-rom/464344eef243825e097646b009406d7d | |
| // @icon https://ae01.alicdn.com/images/eng/wholesale/icon/aliexpress.ico | |
| // @icon64 https://ae01.alicdn.com/images/eng/wholesale/icon/aliexpress.ico | |
| // @updateURL https://gist.github.com/and-rom/464344eef243825e097646b009406d7d/raw/aliitemslideshow.meta.js | |
| // @downloadURL https://gist.github.com/and-rom/464344eef243825e097646b009406d7d/raw/aliitemslideshow.user.js | |
| // @match https://*.aliexpress.com/item/* | |
| // @match https://*.aliexpress.ru/item/* | |
| // @match https://*.aliexpress.com/store/product/* | |
| // @match https://*.aliexpress.ru/store/product/* | |
| // @grant none | |
| // ==/UserScript== |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // ==UserScript== | |
| // @name AliExpress Feedback pictures sildeshow | |
| // @namespace https://gist.github.com/and-rom/464344eef243825e097646b009406d7d | |
| // @version 0.2.13 | |
| // @author and-rom | |
| // @description Press Alt+S to start slideshow, press Alt+C to show number of feedbacks with pictures. | |
| // @homepage https://gist.github.com/and-rom/464344eef243825e097646b009406d7d | |
| // @icon https://ae01.alicdn.com/images/eng/wholesale/icon/aliexpress.ico | |
| // @icon64 https://ae01.alicdn.com/images/eng/wholesale/icon/aliexpress.ico | |
| // @updateURL https://gist.github.com/and-rom/464344eef243825e097646b009406d7d/raw/aliitemslideshow.meta.js | |
| // @downloadURL https://gist.github.com/and-rom/464344eef243825e097646b009406d7d/raw/aliitemslideshow.user.js | |
| // @match https://*.aliexpress.com/item/* | |
| // @match https://*.aliexpress.ru/item/* | |
| // @match https://*.aliexpress.com/store/product/* | |
| // @match https://*.aliexpress.ru/store/product/* | |
| // @grant none | |
| // ==/UserScript== | |
| (function() { | |
| 'use strict'; | |
| var feedback = { | |
| feedbacks: [], | |
| currentFeedback: 0, | |
| currentImage: 0, | |
| currentSlide: 1, | |
| totalSlides: null, | |
| currentPage: 1, | |
| totalPages: null | |
| } | |
| var parser; | |
| var ui = false; | |
| function show(n) { | |
| var status; | |
| if (n > 0) { | |
| if (feedback.currentImage > 0) { | |
| feedback.currentImage--;feedback.currentSlide--; | |
| status = true; | |
| } else { | |
| if (feedback.currentFeedback > 0) { | |
| feedback.currentFeedback--; | |
| feedback.currentImage=feedback.feedbacks[feedback.currentFeedback].pics.length-1;feedback.currentSlide--; | |
| status = true; | |
| } else { | |
| status = false; | |
| } | |
| } | |
| } else { | |
| if (feedback.currentImage < feedback.feedbacks[feedback.currentFeedback].pics.length-1) { | |
| feedback.currentImage++;feedback.currentSlide++; | |
| status = true; | |
| } else { | |
| if (feedback.currentFeedback < feedback.feedbacks.length-1) { | |
| feedback.currentFeedback++; | |
| feedback.currentImage=0;feedback.currentSlide++; | |
| status = true; | |
| } | |
| else { | |
| status = false; | |
| } | |
| } | |
| if (feedback.currentFeedback > feedback.feedbacks.length-5 && feedback.currentPage != feedback.totalPages) { | |
| feedback.currentPage++; | |
| request(); | |
| } | |
| } | |
| if (status) { | |
| display(); | |
| } | |
| } | |
| function display(n) { | |
| document.getElementById('OSS-slideshow-img').innerHTML = ""; | |
| document.getElementById('OSS-slideshow-img').appendChild(feedback.feedbacks[feedback.currentFeedback].pics[feedback.currentImage]); | |
| document.getElementById('OSS-slideshow-text').innerHTML = "" + | |
| /*"slides: " +*/ | |
| (feedback.currentSlide) + "/" + feedback.totalSlides/* + "<br>" + | |
| "pics: " + | |
| (feedback.currentImage+1) + "/" + feedback.feedbacks[feedback.currentFeedback].pics.length + "<br>" + | |
| "feedbacks: " + | |
| (feedback.currentFeedback+1) + "/" + feedback.feedbacks.length + "<br>" + | |
| "pages: " + | |
| feedback.currentPage + "/" + feedback.totalPages*/; | |
| var dummy = document.createElement('span'); | |
| dummy.innerHTML = feedback.feedbacks[feedback.currentFeedback].msg; | |
| document.getElementById('OSS-slideshow-feedback').innerHTML = ""; | |
| document.getElementById('OSS-slideshow-feedback').appendChild(feedback.feedbacks[feedback.currentFeedback].country); | |
| document.getElementById('OSS-slideshow-feedback').appendChild(dummy); | |
| document.getElementById('OSS-slideshow-order-info').innerHTML = ""; | |
| document.getElementById('OSS-slideshow-order-info').appendChild(feedback.feedbacks[feedback.currentFeedback].orderInfo); | |
| } | |
| function close(n) { | |
| document.getElementById('OSS-slideshow-container').remove(); | |
| ui = false; | |
| } | |
| function createSlideshow() { | |
| if (!ui) { | |
| var sl_cont = document.createElement( 'div' ); | |
| sl_cont.id = 'OSS-slideshow-container'; | |
| var sl_txt = document.createElement( 'div' ); | |
| sl_txt.id = 'OSS-slideshow-text'; | |
| var sl_msg = document.createElement( 'div' ); | |
| sl_msg.id = 'OSS-slideshow-message'; | |
| var sl_fb = document.createElement( 'div' ); | |
| sl_fb.id = 'OSS-slideshow-feedback'; | |
| var sl_oi = document.createElement( 'div' ); | |
| sl_oi.id = 'OSS-slideshow-order-info'; | |
| var sl = document.createElement( 'div' ); | |
| sl.id = 'OSS-slideshow-img'; | |
| var a_c = document.createElement( 'a' ); | |
| a_c.id = "OSS-close"; | |
| a_c.onclick = function () { close(); }; | |
| a_c.innerHTML = "✕"; | |
| var a_p = document.createElement( 'a' ); | |
| a_p.id = "OSS-prev"; | |
| a_p.onclick = function () { show(1); }; | |
| a_p.innerHTML = "❮"; | |
| var a_n = document.createElement( 'a' ); | |
| a_n.id = "OSS-next"; | |
| a_n.onclick = function () { show(-1); }; | |
| a_n.innerHTML = "❯"; | |
| sl_msg.appendChild(sl_fb); | |
| sl_msg.appendChild(sl_oi); | |
| sl_cont.appendChild(sl); | |
| sl_cont.appendChild(sl_txt); | |
| sl_cont.appendChild(sl_msg); | |
| sl_cont.appendChild(a_c); | |
| sl_cont.appendChild(a_p); | |
| sl_cont.appendChild(a_n); | |
| document.body.appendChild(sl_cont); | |
| sl_cont.addEventListener("dblclick", function(e) { close() }); | |
| sl_cont.addEventListener("click", function(e) { | |
| var e = window.event || e; | |
| e.stopPropagation(); | |
| e.preventDefault(); | |
| var x = document.getElementById("OSS-slideshow-text"); | |
| if (x.style.display === "none") { | |
| x.style.display = "block"; | |
| } else { | |
| x.style.display = "none"; | |
| } | |
| x = document.getElementById("OSS-slideshow-message"); | |
| if (x.style.display === "none") { | |
| x.style.display = "block"; | |
| } else { | |
| x.style.display = "none"; | |
| } | |
| }, false); | |
| sl_cont.addEventListener("mousewheel", function(e) { | |
| var e = window.event || e; | |
| e.stopPropagation(); | |
| e.preventDefault(); | |
| show(parseInt(e.wheelDelta || - e.detail)); | |
| }, false); | |
| ui = true; | |
| display(); | |
| } | |
| } | |
| function call() { | |
| if (document.getElementById('OSS-with-pics-val').innerHTML != 0) { | |
| request(); | |
| } else { | |
| document.getElementById('OSS-with-pics').className = "OSS-flashit"; | |
| setTimeout(function() { | |
| document.getElementById('OSS-with-pics').className = ""; | |
| }, 600); | |
| } | |
| } | |
| function getInfo () { | |
| var css = "#OSS-slideshow-container {position: fixed; top: 0; left: 0; width: 100%;height: 100%; background-color: #000c; z-index: 1000; margin: auto;}"+ | |
| "#OSS-slideshow-text, #OSS-slideshow-message { padding: 8px 12px; position: absolute; top: 0; width: 100%; color: #fff; background-color: #000c; }"+ | |
| "#OSS-slideshow-text { font-size: x-large; text-align: center; }"+ | |
| "#OSS-slideshow-message { top: initial; bottom: 0; font-size: larger; }"+ | |
| "#OSS-slideshow-img {width: 100%;height: 100%; display: flex; justify-content: center; align-items: center;}"+ | |
| "#OSS-slideshow-img img { /*max-width: 100%; max-height: 100%;*/ height: 100%; width: 100%; object-fit: contain; }"+ | |
| "#OSS-slideshow-order-info { margin-top: .5vw; font-size: smaller; filter: brightness(0.5); }"+ | |
| "#OSS-slideshow-order-info > * { margin-right: 0.5vw; }"+ | |
| "#OSS-close, #OSS-prev, #OSS-next {position: absolute; top:50%; width: auto; padding: 10px; margin-top: -22px; font-size: x-large; user-select: none; cursor: pointer; color: #fff;}"+ | |
| "#OSS-next {right: 0;}"+ | |
| "#OSS-close {top: 0; right: 0; margin-top: 0px;}"+ | |
| "#OSS-prev:hover,#OSS-next:hover,#OSS-close:hover {text-decoration:none; background-color: #000c;}"+ | |
| "#OSS-with-pics { float: left; position: relative; margin-right: 1em; cursor: pointer;}"+ | |
| "#OSS-with-pics:hover { text-decoration:none; }"+ | |
| ".OSS-flashit { animation: OSS-flash linear .2s infinite; }"+ | |
| "@keyframes OSS-flash { 50% { background-color:#f00; } }"; | |
| var style = document.createElement('style'); | |
| if (style.styleSheet) { style.styleSheet.cssText = css; } else { style.appendChild(document.createTextNode(css)); } | |
| document.getElementsByTagName('head')[0].appendChild(style); | |
| var src = document.getElementById('feedback').querySelector("iframe").getAttribute('src'); | |
| var thesrc = document.getElementById('feedback').querySelector("iframe").getAttribute('thesrc'); | |
| if (src == null) { | |
| if ( thesrc != null) { | |
| src = thesrc | |
| } | |
| } | |
| parser = document.createElement('a'); | |
| parser.href = src; | |
| var xhr = new XMLHttpRequest(); | |
| xhr.open('POST', parser.origin+parser.pathname, true); | |
| xhr.setRequestHeader('Content-type', 'application/x-www-form-urlencoded'); | |
| xhr.onload = function () { | |
| var el = document.createElement( 'html' ); | |
| el.innerHTML = this.responseText; | |
| var link = document.createElement('a'); | |
| link.id = 'OSS-with-pics' | |
| link.addEventListener("click", function(e) { | |
| var e = window.event || e; | |
| e.stopPropagation(); | |
| e.preventDefault(); | |
| call(); | |
| }); | |
| link.insertAdjacentHTML('beforeend','🖻 <span id="OSS-with-pics-val">'+(el.querySelector('#cb-withPictures-filter+em') != null ? el.querySelector('#cb-withPictures-filter+em').innerHTML : '0' )+'</span>'); | |
| document.getElementsByClassName('product-reviewer')[0].insertBefore(link, document.getElementsByClassName('product-reviewer')[0].firstChild); | |
| } | |
| xhr.send(parser.search.replace('?','') + '&qkbug_getInfo=1'); | |
| } | |
| function request () { | |
| var xhr = new XMLHttpRequest(); | |
| xhr.open('POST', parser.origin+parser.pathname, true); | |
| xhr.setRequestHeader('Content-type', 'application/x-www-form-urlencoded'); | |
| xhr.onload = function () { | |
| console.log("request onload"); | |
| var el = document.createElement( 'html' ); | |
| el.innerHTML = this.responseText; | |
| feedback.totalPages = el.querySelector('#simple-pager label.ui-label').innerHTML.split('/')[1]; | |
| el.querySelectorAll('div#transction-feedback div.feedback-list-wrap div.feedback-item').forEach(function(feedbackItem){ | |
| var buyerCountry = feedbackItem.querySelector('div.fb-user-info div.user-country b');buyerCountry.innerHTML=" "; | |
| var userOrderInfo = feedbackItem.querySelector('div.user-order-info'); | |
| var buyerFeedback = feedbackItem.querySelector('dl.buyer-review dt.buyer-feedback'); | |
| var buyerFeedbackPics = feedbackItem.querySelectorAll('dl.buyer-review dd.r-photo-list li.pic-view-item img'); | |
| var buyerAdditionFeedback = feedbackItem.querySelector('dl.buyer-additional-review dt.buyer-addition-feedback'); | |
| var buyerAdditionFeedbackPics = feedbackItem.querySelectorAll('dl.buyer-additional-review dd.r-photo-list li.pic-view-item img'); | |
| var msg = ""; | |
| if (buyerFeedbackPics.length != 0) { | |
| feedback.feedbacks.push({ | |
| //msg: (buyerFeedback.innerText != null ? buyerFeedback.innerText : ''), | |
| msg: (buyerFeedback != null ? ( buyerFeedback.innerText != null ? buyerFeedback.innerText : '') : ''), | |
| country: buyerCountry, | |
| orderInfo: userOrderInfo, | |
| pics: Array.from(buyerFeedbackPics) | |
| }); | |
| feedback.totalSlides += Array.from(buyerFeedbackPics).length; | |
| } else { | |
| //msg = (buyerFeedback.innerText != null ? buyerFeedback.innerText + "<br>" : ''); | |
| msg = (buyerFeedback != null ? ( buyerFeedback.innerText != null ? buyerFeedback.innerText + "<br>" : '') : ''); | |
| } | |
| if (buyerAdditionFeedbackPics.length != 0) { | |
| feedback.feedbacks.push({ | |
| //msg: msg + (buyerAdditionFeedback.innerText != null ? buyerAdditionFeedback.innerText : ''), | |
| msg: msg + (buyerAdditionFeedback != null ? ( buyerAdditionFeedback.innerText != null ? buyerAdditionFeedback.innerText : '') : ''), | |
| country: buyerCountry, | |
| orderInfo: userOrderInfo, | |
| pics: Array.from(buyerAdditionFeedbackPics) | |
| }); | |
| feedback.totalSlides += Array.from(buyerAdditionFeedbackPics).length; | |
| } | |
| }); | |
| if (feedback.feedbacks.length != 0) { | |
| createSlideshow(); | |
| } | |
| }; | |
| //&evaSortValue=sortlarest%40feedback | |
| xhr.send(parser.search.replace('?','') + '&translate=+N+&withPictures=true' + (feedback.currentPage != 1 ? '&page=' + feedback.currentPage + '¤tPage=' + (feedback.currentPage-1) : '') + '&qkbug_request=1'); | |
| } | |
| document.addEventListener('readystatechange', function(e) { | |
| if(document.readyState == "complete") { | |
| setTimeout(function(e) { | |
| //window.scrollTo(0, 300); | |
| document.querySelector("#product-detail .tab-content > div:nth-child(2) > .lazy-load").scrollIntoView(); | |
| //document.querySelector("#product-detail > div.product-detail-tab > div.detail-extend-tab > div.detail-tab-bar > ul > li:nth-child(2) > div.tab-inner").click(); | |
| }, 1500); | |
| setTimeout(function(e) { | |
| //document.querySelector("#product-detail > div.product-detail-tab > div.detail-extend-tab > div.detail-tab-bar > ul > li:nth-child(1) > div.tab-inner").click(); | |
| window.scrollTo(0, 0); | |
| }, 2000); | |
| setTimeout(function(e) { | |
| getInfo(); | |
| }, 2500); | |
| } | |
| }); | |
| document.addEventListener('keydown', function(e) { | |
| if (e.altKey) { | |
| var code = (e.keyCode ? e.keyCode : e.which); | |
| if (code == 83) { call(); } // Alt + S | |
| if (code == 67) { getInfo(); } // Alt + C | |
| } | |
| }); | |
| })(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment