// ==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.7 // @grant none // @downloadURL 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_position { margin-left: 10px; color: white; font-size: 12px; }' ); let cartList; let unavailableFrame = $('
').appendTo(document.body); let innerDiv = $('
').appendTo(unavailableFrame); $('').appendTo(innerDiv).text('К недоступному') .on('click', function(event) { let listExists = (cartList && cartList.length > 0); let viewRow = (listExists) ? cartList[0].row : $('#module-cart .row').last(); //viewRow.get(0).scrollIntoView(); $('body, html').stop().animate({ scrollTop: viewRow.offset().top }, 300); }); $('').appendTo(innerDiv).text('Открыть 3') .on('click', function(event) { let period = 500; 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 position = { auto: { timer: 0, index: 0, length: 0 }, cart: { index: 0, length: 0 }, postponed: { page: 0, length: 0 } }; let autoClickInCart = function() { if (position.auto.index >= position.auto.length) { clearInterval(position.auto.timer); return; } $('.postpone_frame .nbtn', cartList[position.auto.index].row).get(0).click(); position.auto.index++; // Предложим продолжить или прервать if ((position.auto.index < position.auto.length) && (position.auto.index % 3 == 0)) { if (confirm(`Открыто ${position.auto.index} / ${position.auto.length}.\nПрервать?`)) { clearInterval(position.auto.timer); } } }; $('').appendTo(innerDiv).text('Перекликать') .on('click', function(event) { let listExists = (cartList && cartList.length > 0); if (!listExists) { return; } position.auto.length = cartList.length; position.auto.index = 0; position.auto.timer = setInterval(autoClickInCart, 500); }); let productFrame = { clear: function() { this.outer.empty(); this.outer.removeAttr('title'); this.outer.addClass('m-r-10'); }, createAgain: function() { this.clear(); let div = $('
').appendTo(productFrame.outer); this.img = $('').appendTo(div); div = $('
').appendTo(productFrame.outer); this.name = $('
').appendTo(div); this.cartIndex = $('
').appendTo(div); this.postponedPage = $('
').appendTo(div); }, setImg: function(product) { this.img.attr('src', product.img); }, setName: function(product) { this.name.text(product.name.substring(0, 5) + '…'); this.outer.attr('title', product.name); }, setCartIndex: function() { this.cartIndex.text(`товар ${position.cart.index + 1} / ${position.cart.length}`); }, setPostponedPage: function() { this.postponedPage.text(`стр ${position.postponed.page + 1} / ${position.postponed.length}`); } }; let postponedList = []; let findInPostponedList = function(productId) { let postponedPage = 0; }; let currentIndex, maxIndex; let currentPage, maxPage; let requestPostponedItem = function() { let product = cartList[position.cart.index].product; productFrame.createAgain(); productFrame.setImg(product); productFrame.setName(product); productFrame.setCartIndex(); productFrame.setPostponedPage(); return; currentIndex++; if (currentIndex >= maxIndex) return; $.get('/user?personalis=coming&page=' + currentPage, function(data) { let rowList = $('.table.goods .row', data); console.log('AJAX rowList == ', rowList); }); }; $('').appendTo(innerDiv).text('Проверить') .on('click', function(event) { let listExists = (cartList && cartList.length > 0); if (!listExists) { alert('Недоступного нет'); return; } position.cart.length = cartList.length; position.cart.index = 0; // Получить список ожидаемых постранично до тех пор, пока не найдем нужный товар requestPostponedItem(); }); productFrame.outer = $('