您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Опции для корзины
当前为
// ==UserScript== // @name Cart - Flip // @namespace scriptomatika // @author mouse-karaganda // @description Опции для корзины // @license MIT // @include https://*flip.kz/cart* // @require https://greasyfork.org/scripts/379902-include-tools/code/Include%20Tools.js // @version 1.2 // @grant none // ==/UserScript== (function() { const $ = window.jQuery; const $$ = window.__krokodil; $$.renderStyle( '.unavailable_frame { position: fixed; bottom: 0; right: 0; padding: 5px 0 5px 5px; border-radius: 10px 0 0 0; background-color: rgba(10, 121, 213, 0.9); }', '.product_frame { display: inline-block; }', '.product_frame > div { display: inline-block; }', '.product_frame img { width: 32px; border-radius: 5px; }', '.product_frame span { margin-left: 10px; color: white; font-size: 12px; }' ); let unavailableList, productFrame, comingList = []; let pproductFrame = { setImg: function() { } }; let findInComingList = function(productId) { let comingPage = 0; }; let unavailableFrame = $('<div class="unavailable_frame" />').appendTo(document.body); let div = $('<div />').appendTo(unavailableFrame); $('<a class="nbtn gray small m-r-10" />').appendTo(div).text('К недоступному') .click(function(event) { let listExists = (unavailableList && unavailableList.length > 0); let viewRow = (listExists) ? unavailableList[0].row : $('#module-cart .row').last(); viewRow.get(0).scrollIntoView(); }); $('<a class="nbtn gray small m-r-10" />').appendTo(div).text('Открыть 3') .click(function(event) { let period = 1500; setTimeout(function() { window.open('', 'manual_postpone0', 'width=450,height=300,left=0,top=0'); }, 1); setTimeout(function() { window.open('', 'manual_postpone1', 'width=450,height=300,left=455,top=0'); }, period); setTimeout(function() { window.open('', 'manual_postpone2', 'width=450,height=300,left=910,top=0'); }, period * 2); }); let currentIndex, maxIndex; let currentPage, maxPage; let requestPostponedItem = function() { currentIndex++; if (currentIndex >= maxIndex) return; productFrame.empty(); productFrame.removeAttr('title'); productFrame.addClass('m-r-10'); currentPage = 1; maxPage = 1; let product = unavailableList[currentIndex].product; let div = $('<div />').appendTo(productFrame); $('<img />').appendTo(div).attr('src', product.img); div = $('<div />').appendTo(productFrame); $('<span />').appendTo(div).text(product.name.substring(0, 5) + '…'); $('<br />').appendTo(div); $('<span />').appendTo(div).text(`товар ${currentIndex + 1} / ${maxIndex}`); $('<br />').appendTo(div); $('<span />').appendTo(div).text(`стр ${currentPage} / ${maxPage}`); productFrame.attr('title', product.name); $.get('/user?personalis=coming&page=' + currentPage, function(data) { let rowList = $('.table.goods .row', data); console.log('AJAX rowList == ', rowList); }); }; $('<a class="nbtn gray small m-r-10" />').appendTo(div).text('Проверить') .click(function(event) { let listExists = (unavailableList && unavailableList.length > 0); if (!listExists) { alert('Недоступных нет'); return; } maxIndex = unavailableList.length; currentIndex = -1; // Получить список ожидаемых постранично до тех пор, пока не найдем нужный товар requestPostponedItem(); }); productFrame = $('<div class="product_frame" />').appendTo(div); class ProductRow { constructor(rowElem) { this.row = $(rowElem); if (this.isCartPage) { this.srok = $('label + div + div', rowElem); } } get isCartPage() { return /\/cart\b/.test(location.href); } get isNotAvailable() { if (this.srok) { return this.srok.text().includes('Недоступен для заказа'); } return false; } get product() { if (!this._product) { let catalogElem = $('a[href^="/catalog?"]', this.row); this._product = { id: catalogElem.attr('href').match(/\d+/)[0], img: catalogElem.children('img').attr('src'), name: catalogElem.text() }; } return this._product; } addPostponeFrame(winIndex) { this.row.addClass('add_postpone_row'); let div = $('<div />').appendTo(this.srok).addClass('postpone_frame'); let button = $('<a class="nbtn gray small" />').appendTo(div).text('Отложить') .attr({ target: 'manual_postpone' + winIndex, href: '/subscribe?type=preorder&action=add&id=' + this.product.id }) .click(function(event) { setTimeout(function() { //div.remove(); $('<span />').text(' ✅ ').insertAfter(button); }, 500); }); } } unavailableList = $('#module-cart .row') .filter(function(index) { let prow = new ProductRow(this); return prow.isNotAvailable; }) .map(function(index) { let prow = new ProductRow(this); prow.addPostponeFrame(index % 3); return prow; }) .get(); console.log('unavailableList [%o] == ', unavailableList.length); console.log('Cart - Flip 💬 1.2'); })();