Исправил, теперь получает цену с баннера.со ценами дороже 999 стало всё ок, с распродажными ценниками по-прежнему не работает:
Посмотреть вложение 363728
кнопка "получить айди" на нажатия никак не реагирует.
Ссылка на гитхаб
Исправил, теперь получает цену с баннера.со ценами дороже 999 стало всё ок, с распродажными ценниками по-прежнему не работает:
Посмотреть вложение 363728
кнопка "получить айди" на нажатия никак не реагирует.
В новой версии стало формировать в столбик. Мне же удобнее было в строчку, чтобы заносить в таблицы. Немного переделал скрипт, заменив перенос строки на табуляцию
// ==UserScript==
// ==UserScript==
// @name Aliexpress item getter
// @namespace http://tampermonkey.net/
// @version 1.2
// @description Получает ID, название, цену и конфигурацию
// @author Andronio
// @homepage https://github.com/Andronio2/Aliexpress-item-getter
// @supportURL https://github.com/Andronio2/Aliexpress-item-getter/issues
// @updateURL https://github.com/Andronio2/Aliexpress-item-getter/raw/master/Aliexpress%20item%20getter.user.js
// @downloadURL https://github.com/Andronio2/Aliexpress-item-getter/raw/master/Aliexpress%20item%20getter.user.js
// @match https://aliexpress.ru/item/*
// @match https://aliexpress.com/item/*
// @match https://www.aliexpress.com/item/*
// @match https://www.aliexpress.ru/item/*
// @grant none
// ==/UserScript==
(function() {
'use strict';
/*
* price - Цена товара
* ship - Если есть, то будут цифры, иначе пусто
* item_name - Название товара, укороченное до 80 символов
* item_id - Ссылка на товар
* item_conf - Конфигурация выбранного товара
* newstr - новая строка
* ' ' - пробел
*/
let outString = `price + ship + tab + item_name + tab + item_id + tab + item_conf + tab + tab`;
/*
* Дальше не трогать
*/
let tab = '\t';
let productPrice = document.querySelector('.Product_Price__container__1uqb8, .Product_UniformBanner__uniformBanner__o5qwb');
if (!productPrice) {
// Старая страница
productPrice = document.querySelector('.product-price-current');
if (!productPrice) productPrice = document.querySelector('.product-price');
if (productPrice) {
let div = document.createElement('div');
div.innerHTML = '<button type="button" id="user-get-item" class="old-btn next-btn next-small next-btn-primary">Получить ID</button>';
div.style.display = 'inline-block';
productPrice.append(div);
div.addEventListener('click', btnHandler);
}
} else {
// Новая страница
let div = document.createElement('div');
div.id = 'user-get-item';
productPrice.append(div);
let observer = new MutationObserver(() => {
if (document.getElementById('user-get-item')) return; // Смотрим, есть ли наша кнопка
observer.disconnect(); // Если нет, то создаем заново
div = document.createElement('div');
div.innerHTML = '<button type="button" id="user-get-item" class="new-btn contained ali-kit_Button__button__ngexmt ali-kit_Button__size-m__ngexmt ali-kit_Button__primary__ngexmt">Получить ID</button>';
div.style.display = 'block';
productPrice.append(div);
div.addEventListener('click', btnHandler);
});
let config = {
childList: true, // наблюдать за непосредственными детьми
subtree: true, // и более глубокими потомками
characterDataOldValue: true // передавать старое значение в колбэк
}
observer.observe(productPrice, config);
}
function btnHandler(e){
if (e.target.tagName !== "BUTTON") return;
const mybtn = e.target;
let redClass;
let str = getItemString();
redClass = e.target.classList.contains('old-btn') ? 'next-btn-primary' : 'ali-kit_Button__primary__ngexmt';
if (str !== undefined) {
navigator.clipboard.writeText(str).then(function () {
console.log('Async: Copying to clipboard was successful!');
e.target.classList.remove(redClass);
setTimeout(() => e.target.classList.add(redClass), 500);
}, function (err) {
console.error('Async: Could not copy text: ', err);
});
}
}
function getItemString(){
let itemProps = document.querySelectorAll('.sku-property, .Product_SkuValuesBar__container__6ryfe');
let massProps = [];
// Находим только те, что содержат выбор, иначе пропускаем
for (let i = 0; i < itemProps.length; i++) {
if (itemProps[i].querySelector('.sku-property-list, .Product_SkuValueBaseItem__item__o90dx')) massProps.push(itemProps[i]);
}
let item_conf = '';
for (let i = 0; i < massProps.length; i++) {
let item = massProps[i].querySelectorAll('.sku-property-item, .Product_SkuValueBaseItem__item__o90dx');
let hasSelect = false
for (let j = 0; j < item.length; j++) {
if (item[j].classList.contains("selected") || item[j].classList.contains("Product_SkuValueBaseItem__active__o90dx")) {
hasSelect = true;
item_conf += (j + 1) + ' ';
break;
}
}
if (!hasSelect) {
alert("Не выбрана конфигурация");
return null;
}
}
item_conf = item_conf.slice(0, -1);
let price = document.querySelector('.product-price-value, .uniform-banner-box-price, .product-price-current').textContent;
price = price.match(/\d{1,3}\s\d{3},\d{2}|\d{1,3},\d{3}\.\d{2}|\d{1,3}[\.,]\d{2}/);
if (price && price.length === 0) {
console.log('Не нашел цену');
return null;
} else {
price = price[0].replace(/(\d{1,3})\s(\d{3},\d{2})/, '$1$2').replace(/(\d{1,3}),(\d{3}\.\d{2})/, '$1$2');
}
let ship = document.querySelector('.Product_NewFreight__freight__vd1kn, .dynamic-shipping-line').textContent;
ship = ship.match(/\d{1,3}\s\d{3},\d{2}|\d{1,3},\d{3}\.\d{2}|\d{1,3}[\.,]\d{2}/);
if (ship && ship.length > 0) {
ship = "+ " + ship[0].replace(/(\d{1,3})\s(\d{3},\d{2})/, '$1$2').replace(/(\d{1,3}),(\d{3}\.\d{2})/, '$1$2') + ' ';
} else ship = "";
let item_name = document.querySelector('.product-title, .Product_Name__container__hntp3').textContent.substring(0, 80); // Укороченное имя;
let item_id = location.href.match(/.+\.html/)[0];
let item_string = eval(outString);
return item_string;
}
})();
Для совсем ленивых надо было уже сделать нажатие на кнопку Verify now )))))Обновил скрипт для верификации. Скрипт проходит телеверку до ввода заданного номер телефона, включительно.
Ссылка.
*** Скрытый текст не может быть процитирован. ***
// ==UserScript==
// @name Aliexpress coupon diff calc
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Вычисляет разность купона и текущей цены
// @author Andronio
// @match https://www.aliexpress.com/item/*
// @match https://www.aliexpress.ru/item/*
// @match https://aliexpress.ru/item/*
// @icon https://www.google.com/s2/favicons?domain=aliexpress.com
// @grant none
// @run-at document-idle
// ==/UserScript==
(function() {
'use strict';
const fixCouponPrice = '';
let fixed = fixCouponPrice !== '';
let mainWindow = document.createElement('div');
mainWindow.className = 'coupon_diff_calc-window-main';
mainWindow.innerHTML = `
<input type="text" id="coupon_diff_calc-input">
<p id="coupon_diff_calc-output">0</p>
`;
let styles = `
.coupon_diff_calc-window-main {
position: fixed;
top: 0;
left: 10px;
background: white;
box-shadow: 1px -1px 4px 1px;
width: 200px;
height: 75px;
padding: 10px 20px;
z-index: 100;
}
#coupon_diff_calc-input {
border: solid black 2px;
border-radius: 5px;
padding: 5px;
width: 100%;
font-size: 15px;
margin-bottom: 5px;
}
#coupon_diff_calc-output {
font-size: 15px;
}
`;
let styleSheet = document.createElement("style");
styleSheet.type = "text/css";
styleSheet.innerText = styles;
document.head.append(styleSheet)
document.body.append(mainWindow);
const input = document.getElementById('coupon_diff_calc-input');
if (!fixed) {
let restoreValue = localStorage.getItem('coupon_diff_calc-value');
if (restoreValue) input.value = restoreValue;
input.addEventListener('change', () => {
localStorage.setItem('coupon_diff_calc-value', input.value);
});
} else {
input.value = fixCouponPrice;
}
setInterval(() => {
let price = document.querySelector('.product-price-value, .product-price-current');
if (!price) document.querySelector('.uniform-banner-box-price, .Product_UniformBanner__uniformBannerBoxPrice__o5qwb');
if (!price) {
console.log('не нашел цену');
return;
}
let itemPrice = price.textContent.match(/\d{1,3}\s\d{3},\d{2}|\d{1,3},\d{3}\.\d{2}|\d{1,3}[\.,]\d{2}/);
if (itemPrice && itemPrice.length === 0) {
console.log('цена товара не верная');
return;
}
itemPrice = +itemPrice[0].replace(/(\d{1,3})\s(\d{3},\d{2})/, '$1$2').replace(/(\d{1,3}),(\d{3}\.\d{2})/, '$1$2');
if (isNaN(itemPrice)) {
console.log('цена товара не верная2');
return;
}
const output = document.getElementById('coupon_diff_calc-output');
const input = document.getElementById('coupon_diff_calc-input');
if (!output || !input) {
console.log('нет вывода');
return;
}
let couponPrice = +input.value.replace(',','.');
if (isNaN(couponPrice)) {
console.log('ввели не число');
return;
}
output.textContent = `${couponPrice} - ${itemPrice} = ${(couponPrice - itemPrice).toFixed(2)}`;
}, 500);
})();
Чую вещь полезная , но не очень понял что куда вводить, что бы заработало ? Установил (в скрипте нич не вписывал), на странице появляется окошка ввода, какую бы цифру не вписывал, все равно НОЛЬ снизу. Разьясните плиз. Спасибо.Скрипт для вычисления разницы купона и текущей цены. Если порог купона фиксированный, то можно забить в скрипт, тогда в поле всегда будет подставляться фиксированная граница. Если в фиксированную границу установить пустую строку, то значение из поля будет сохраняться и при открытии страницы восстанавливаться.
JavaScript:// ==UserScript== // @name Aliexpress coupon diff calc // @namespace http://tampermonkey.net/ // @version 0.1 // @description Вычисляет разность купона и текущей цены // @author Andronio // @match https://www.aliexpress.com/item/* // @match https://www.aliexpress.ru/item/* // @match https://aliexpress.ru/item/* // @icon https://www.google.com/s2/favicons?domain=aliexpress.com // @grant none // @run-at document-idle // ==/UserScript== (function() { 'use strict'; const fixCouponPrice = ''; let fixed = fixCouponPrice !== ''; let mainWindow = document.createElement('div'); mainWindow.className = 'coupon_diff_calc-window-main'; mainWindow.innerHTML = ` <input type="text" id="coupon_diff_calc-input"> <p id="coupon_diff_calc-output">0</p> `; let styles = ` .coupon_diff_calc-window-main { position: fixed; top: 0; left: 10px; background: white; box-shadow: 1px -1px 4px 1px; width: 200px; height: 75px; padding: 10px 20px; z-index: 100; } #coupon_diff_calc-input { border: solid black 2px; border-radius: 5px; padding: 5px; width: 100%; font-size: 15px; margin-bottom: 5px; } #coupon_diff_calc-output { font-size: 15px; } `; let styleSheet = document.createElement("style"); styleSheet.type = "text/css"; styleSheet.innerText = styles; document.head.append(styleSheet) document.body.append(mainWindow); const input = document.getElementById('coupon_diff_calc-input'); if (!fixed) { let restoreValue = localStorage.getItem('coupon_diff_calc-value'); if (restoreValue) input.value = restoreValue; input.addEventListener('change', () => { localStorage.setItem('coupon_diff_calc-value', input.value); }); } else { input.value = fixCouponPrice; } setInterval(() => { let price = document.querySelector('.product-price-value, .product-price-current'); if (!price) document.querySelector('.uniform-banner-box-price, .Product_UniformBanner__uniformBannerBoxPrice__o5qwb'); if (!price) { console.log('не нашел цену'); return; } let itemPrice = price.textContent.match(/\d{1,3}\s\d{3},\d{2}|\d{1,3},\d{3}\.\d{2}|\d{1,3}[\.,]\d{2}/); if (itemPrice && itemPrice.length === 0) { console.log('цена товара не верная'); return; } itemPrice = +itemPrice[0].replace(/(\d{1,3})\s(\d{3},\d{2})/, '$1$2').replace(/(\d{1,3}),(\d{3}\.\d{2})/, '$1$2'); if (isNaN(itemPrice)) { console.log('цена товара не верная2'); return; } const output = document.getElementById('coupon_diff_calc-output'); const input = document.getElementById('coupon_diff_calc-input'); if (!output || !input) { console.log('нет вывода'); return; } let couponPrice = +input.value.replace(',','.'); if (isNaN(couponPrice)) { console.log('ввели не число'); return; } output.textContent = `${couponPrice} - ${itemPrice} = ${(couponPrice - itemPrice).toFixed(2)}`; }, 500); })();
у меня это выглядит так, возможно нужно выбрать цвет и размер, тогда отработаетЧую вещь полезная , но не очень понял что куда вводить, что бы заработало ? Установил (в скрипте нич не вписывал), на странице появляется окошка ввода, какую бы цифру не вписывал, все равно НОЛЬ снизу. Разьясните плиз. Спасибо.
Как выше показано на рисунке, так и должно быть. Дай ссылку товара и какая валюта и язык установлены, может какая ошибка появляется. И покажи консоль, туда выводятся ошибки.Чую вещь полезная , но не очень понял что куда вводить, что бы заработало ? Установил (в скрипте нич не вписывал), на странице появляется окошка ввода, какую бы цифру не вписывал, все равно НОЛЬ снизу. Разьясните плиз. Спасибо.
// ==UserScript==
// @name Aliexpress coupon diff calc
// @namespace http://tampermonkey.net/
// @version 0.2
// @description Вычисляет разность купона и текущей цены
// @author Andronio
// @match https://www.aliexpress.com/item/*
// @match https://www.aliexpress.ru/item/*
// @match https://aliexpress.ru/item/*
// @icon https://www.google.com/s2/favicons?domain=aliexpress.com
// @grant none
// @run-at document-idle
// ==/UserScript==
(function() {
'use strict';
const fixCouponPrice = '';
let fixed = fixCouponPrice !== '';
let mainWindow = document.createElement('div');
mainWindow.className = 'coupon_diff_calc-window-main';
mainWindow.innerHTML = `
<input type="text" id="coupon_diff_calc-input">
<p id="coupon_diff_calc-output">0</p>
`;
let styles = `
.coupon_diff_calc-window-main {
position: fixed;
top: 0;
left: 10px;
background: white;
box-shadow: 1px -1px 4px 1px;
width: 200px;
height: 75px;
padding: 10px 20px;
z-index: 100;
}
#coupon_diff_calc-input {
border: solid black 2px;
border-radius: 5px;
padding: 5px;
width: 100%;
font-size: 15px;
margin-bottom: 5px;
}
#coupon_diff_calc-output {
font-size: 15px;
}
`;
let styleSheet = document.createElement("style");
styleSheet.type = "text/css";
styleSheet.innerText = styles;
document.head.append(styleSheet)
document.body.append(mainWindow);
const input = document.getElementById('coupon_diff_calc-input');
if (!fixed) {
let restoreValue = localStorage.getItem('coupon_diff_calc-value');
if (restoreValue) input.value = restoreValue;
input.addEventListener('change', () => {
localStorage.setItem('coupon_diff_calc-value', input.value);
});
} else {
input.value = fixCouponPrice;
}
setInterval(() => {
let price = document.querySelector('.product-price-value, .product-price-current');
if (!price) document.querySelector('.uniform-banner-box-price, .Product_UniformBanner__uniformBannerBoxPrice__o5qwb');
if (!price) {
console.log('не нашел цену');
return;
}
let itemPrice = price.textContent.match(/\d{1,3}\s\d{3},\d{2}|\d{1,3},\d{3}\.\d{2}|\d{1,3}[\.,]\d{2}/);
if (itemPrice && itemPrice.length === 0) {
console.log('цена товара не верная');
return;
}
itemPrice = +itemPrice[0].replace(/(\d{1,3})\s(\d{3},\d{2})/, '$1$2').replace(/(\d{1,3}),(\d{3}\.\d{2})/, '$1$2').replace(',','.');
if (isNaN(itemPrice)) {
console.log('цена товара не верная2');
return;
}
const output = document.getElementById('coupon_diff_calc-output');
const input = document.getElementById('coupon_diff_calc-input');
if (!output || !input) {
console.log('нет вывода');
return;
}
let couponPrice = +input.value.replace(',','.');
if (isNaN(couponPrice)) {
console.log('ввели не число');
return;
}
output.textContent = `${couponPrice} - ${itemPrice} = ${(couponPrice - itemPrice).toFixed(2)}`;
}, 500);
})();
СПАСИБО ТОВАРИЩ ! Все заработало, до этого вообще ничего не работало, хоть какую валюту выбирай.Как выше показано на рисунке, так и должно быть. Дай ссылку товара и какая валюта и язык установлены, может какая ошибка появляется. И покажи консоль, туда выводятся ошибки.
ps: с юбилейчиком! 1000 дней---------Двойное сообщение соединено: ---------Разобрался, рубли с запятой идут, исправил
JavaScript:// ==UserScript== // @name Aliexpress coupon diff calc // @namespace http://tampermonkey.net/ // @version 0.2 // @description Вычисляет разность купона и текущей цены // @author Andronio // @match https://www.aliexpress.com/item/* // @match https://www.aliexpress.ru/item/* // @match https://aliexpress.ru/item/* // @icon https://www.google.com/s2/favicons?domain=aliexpress.com // @grant none // @run-at document-idle // ==/UserScript== (function() { 'use strict'; const fixCouponPrice = ''; let fixed = fixCouponPrice !== ''; let mainWindow = document.createElement('div'); mainWindow.className = 'coupon_diff_calc-window-main'; mainWindow.innerHTML = ` <input type="text" id="coupon_diff_calc-input"> <p id="coupon_diff_calc-output">0</p> `; let styles = ` .coupon_diff_calc-window-main { position: fixed; top: 0; left: 10px; background: white; box-shadow: 1px -1px 4px 1px; width: 200px; height: 75px; padding: 10px 20px; z-index: 100; } #coupon_diff_calc-input { border: solid black 2px; border-radius: 5px; padding: 5px; width: 100%; font-size: 15px; margin-bottom: 5px; } #coupon_diff_calc-output { font-size: 15px; } `; let styleSheet = document.createElement("style"); styleSheet.type = "text/css"; styleSheet.innerText = styles; document.head.append(styleSheet) document.body.append(mainWindow); const input = document.getElementById('coupon_diff_calc-input'); if (!fixed) { let restoreValue = localStorage.getItem('coupon_diff_calc-value'); if (restoreValue) input.value = restoreValue; input.addEventListener('change', () => { localStorage.setItem('coupon_diff_calc-value', input.value); }); } else { input.value = fixCouponPrice; } setInterval(() => { let price = document.querySelector('.product-price-value, .product-price-current'); if (!price) document.querySelector('.uniform-banner-box-price, .Product_UniformBanner__uniformBannerBoxPrice__o5qwb'); if (!price) { console.log('не нашел цену'); return; } let itemPrice = price.textContent.match(/\d{1,3}\s\d{3},\d{2}|\d{1,3},\d{3}\.\d{2}|\d{1,3}[\.,]\d{2}/); if (itemPrice && itemPrice.length === 0) { console.log('цена товара не верная'); return; } itemPrice = +itemPrice[0].replace(/(\d{1,3})\s(\d{3},\d{2})/, '$1$2').replace(/(\d{1,3}),(\d{3}\.\d{2})/, '$1$2').replace(',','.'); if (isNaN(itemPrice)) { console.log('цена товара не верная2'); return; } const output = document.getElementById('coupon_diff_calc-output'); const input = document.getElementById('coupon_diff_calc-input'); if (!output || !input) { console.log('нет вывода'); return; } let couponPrice = +input.value.replace(',','.'); if (isNaN(couponPrice)) { console.log('ввели не число'); return; } output.textContent = `${couponPrice} - ${itemPrice} = ${(couponPrice - itemPrice).toFixed(2)}`; }, 500); })();
Нашел ошибку в скрипте, не находилась цена в баннере. Есть идея для развития скрипта, поэтому выложил на гитхабРазобрался, рубли с запятой идут, исправил
Нашел ошибку в скрипте, не находилась цена в баннере. Есть идея для развития скрипта, поэтому выложил на гитхаб
Ссылка на гитхаб
Ссылка на файл
Обновлённый скрипт для авторизации на Скидка.ру
Баги или пожелания по скрипту в лс.
p.s. код не смотреть, сделано лишь бы работало.
Здравствуйте. Опять у меня кривые руки? или не работает на данный момент скрипт?Скрипт заполняет случайными данными адрес США для игры пистолет
ссылка на гитхаб
Страница адреса менялась, может и перестал скрипт работать. Но править его нет смысла, есть более лучший скриптЗдравствуйте. Опять у меня кривые руки? или не работает на данный момент скрипт?
У некоторых стран, в том числе и Таиланд, новая форма адреса, скрипт с ней не работает. Если заполнять при оформлении и использовать этот скрипт (второй), то будет старая формаПриветствую!
Существует скрипт рабочий, который заполняет по шаблонам адреса, не только UA,RU,RB,USA но и другие, а именно Таиланд
когда в этих скриптах версий 1.0.3-1.1.7 выбрать страну Таиланд, скрипты совсем не запускаются, шаблоны настроенные на страну Тай, не появляются совсем в адресной.
Подправить ни как не получится в ближайшее время??У некоторых стран, в том числе и Таиланд, новая форма адреса, скрипт с ней не работает. Если заполнять при оформлении и использовать этот скрипт (второй), то будет старая форма
Неа, там поля без идентификаторов и у разных стран форма разнаяПодправить ни как не получится в ближайшее время??