// ==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.6 // @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_frame span { margin-left: 10px; color: white; font-size: 12px; }' ); let cartList; let unavailableFrame = $('
').appendTo(document.body); let innerDiv = $('
').appendTo(unavailableFrame); $('').appendTo(innerDiv).text('К недоступному') .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') .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 = { cartIndex: 0, maxCartIndex: 0, postponedPage: 0, maxPostponedPage: 0 }; let productFrame = { outer: null, 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); $('
').appendTo(div); this.cartIndex = $('').appendTo(div); $('
').appendTo(div); this.comingPage = $('').appendTo(div); }, setImg: function(product) { this.img.attr('src', product.img); }, setName: function(product) { this.name.text(product.name.substring(0, 5) + '…'); }, setCartIndex: function() { this.cartIndex.text(`товар ${currentIndex + 1} / ${maxIndex}`); }, setComingPage: function(product) { this.comingPage.text(`стр ${currentPage + 1} / ${maxPage}`); } }; let comingList = []; let findInComingList = function(productId) { let comingPage = 0; }; let currentIndex, maxIndex; let currentPage, maxPage; let requestPostponedItem = function() { currentPage = 0; maxPage = 0; let product = cartList[currentIndex].product; productFrame.createAgain(); productFrame.setImg(product); productFrame.setName(product); productFrame.setCartIndex(); productFrame.setComingPage(); 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('Проверить') .click(function(event) { let listExists = (cartList && cartList.length > 0); if (!listExists) { alert('Недоступных нет'); return; } position.cartIndex = cartList.length; currentIndex = 0; // Получить список ожидаемых постранично до тех пор, пока не найдем нужный товар requestPostponedItem(); }); productFrame.outer = $('