您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
card helper
当前为
// ==UserScript== // @name Card Helper // @namespace animestars.org // @version 3.3 // @description card helper // @author bmr // @match https://astars.club/* // @match https://asstars1.astars.club/* // @match https://animestars.org/* // @match https://as1.astars.club/* // @match https://asstars.tv/* // @license bmr // @grant none // @updateURL // @downloadURL // ==/UserScript== const DELAY = 40; const sleep = ms => new Promise(resolve => setTimeout(resolve, ms)); let cardCounter = 0; const cardClasses = '.remelt__inventory-item, .lootbox__card, .anime-cards__item, .trade__inventory-item, .trade__main-item, .card-filter-list__card, .deck__item, .history__body-item, .history__body-item, .card-show__placeholder, .card-pack__card'; async function getCount(cardId, type) { const currentDomain = window.location.origin; let count = 0; let needResponse = await fetch(`${currentDomain}/cards/${cardId}/users/${type}/`); if (needResponse.status === 502) { throw new Error("502 Bad Gateway"); } let needHtml = ''; let needDoc = ''; if (needResponse.ok) { needHtml = await needResponse.text(); needDoc = new DOMParser().parseFromString(needHtml, 'text/html'); count = needDoc.querySelectorAll('.profile__friends-item').length; } else { return count; } const pagination = needDoc.querySelector('.pagination__pages'); if (pagination && count >= 50) { const lastPageNum = pagination.querySelector('a:last-of-type'); const totalPages = lastPageNum ? parseInt(lastPageNum.innerText, 10) : 1; if (totalPages > 1) { count = (totalPages - 1) * 50; } needResponse = await fetch(`${currentDomain}/cards/${cardId}/users/${type}/page/${totalPages}`); if (needResponse.status === 502) { throw new Error("502 Bad Gateway"); } if (needResponse.ok) { needHtml = await needResponse.text(); needDoc = new DOMParser().parseFromString(needHtml, 'text/html'); count += needDoc.querySelectorAll('.profile__friends-item').length; } } return count; } async function iNeedCard(cardId) { await sleep(DELAY * 2); const url = '/engine/ajax/controller.php?mod=trade_ajax'; const data = { action: 'propose_add', type: 0, card_id: cardId, user_hash: dle_login_hash }; try { const response = await fetch(url, { method: 'POST', headers: { 'Content-Type': 'application/x-www-form-urlencoded', }, body: new URLSearchParams(data).toString() }); if (response.status === 502) { throw new Error("502 Bad Gateway"); } if (response.ok) { const data = await response.json(); if (data.error) { if (data.error == 'Слишком часто, подождите пару секунд и повторите действие') { await readyToChargeCard(cardId); return; } else { showNotification(data.error); } } if ( data.status == 'added' ) { cardCounter++; return; } if ( data.status == 'deleted' ) { await iNeedCard(cardId); return; } cardCounter++; } } catch (error) { } } async function loadCard(cardId) { const cacheKey = 'cardId: ' + cardId; let card = await getCard(cacheKey) ?? {}; if (Object.keys(card).length) { return card; } const currentDomain = window.location.origin; await sleep(DELAY); let needCount = await getCount(cardId, 'need'); await sleep(DELAY); let tradeCount = await getCount(cardId, 'trade'); await sleep(DELAY); const popularityResponse = await fetch(`${currentDomain}/cards/${cardId}/users/`); if (popularityResponse.status === 502) { throw new Error("502 Bad Gateway"); } let likes = 0; let dislikes = 0; let popularityCount = 0; let rankText = ''; if (popularityResponse.ok) { const popularityHtml = await popularityResponse.text(); const popularityDoc = new DOMParser().parseFromString(popularityHtml, 'text/html'); const rankElement = popularityDoc.querySelector('.anime-cards__rank'); if (rankElement) { rankText = rankElement.textContent.trim(); } await checkGiftCard(popularityDoc); popularityCount = popularityDoc.querySelectorAll('.card-show__owner').length; const pagination = popularityDoc.querySelector('.pagination__pages'); if (pagination) { const lastPageNum = pagination.querySelector('a:last-of-type'); const totalPages = lastPageNum ? parseInt(lastPageNum.innerText, 10) : 1; if (totalPages > 1) { if (totalPages > 20) { await sleep(DELAY); const secondPageResponse = await fetch(`${currentDomain}/cards/${cardId}/users/page/2`); if (secondPageResponse.ok) { const secondPageHtml = await secondPageResponse.text(); const secondPageDoc = new DOMParser().parseFromString(secondPageHtml, 'text/html'); const secondPageCount = secondPageDoc.querySelectorAll('.card-show__owner').length; await sleep(DELAY); const lastPageResponse = await fetch(`${currentDomain}/cards/${cardId}/users/page/${totalPages}`); if (lastPageResponse.ok) { const lastPageHtml = await lastPageResponse.text(); const lastPageDoc = new DOMParser().parseFromString(lastPageHtml, 'text/html'); const lastPageCount = lastPageDoc.querySelectorAll('.card-show__owner').length; const avgCountPerPage = secondPageCount; popularityCount = popularityCount + avgCountPerPage * (totalPages - 2) + lastPageCount; } } } else { for(let page = 2; page <= totalPages; page++) { await sleep(DELAY); const pageResponse = await fetch(`${currentDomain}/cards/${cardId}/users/page/${page}`); if (pageResponse.ok) { const pageHtml = await pageResponse.text(); const pageDoc = new DOMParser().parseFromString(pageHtml, 'text/html'); const pageCount = pageDoc.querySelectorAll('.card-show__owner').length; popularityCount += pageCount; } } } } } const animeUrl = popularityDoc.querySelector('.card-show__placeholder')?.href; if (animeUrl) { try { const response = await fetch(animeUrl); if (!response.ok) { throw new Error(`Ошибка HTTP: ${response.status}`); } const htmlText = await response.text(); const parser = new DOMParser(); const doc = parser.parseFromString(htmlText, 'text/html'); likes = parseInt(doc.querySelector('[data-likes-id]')?.textContent?.trim(), 10); dislikes = parseInt(doc.querySelector('[data-dislikes-id]')?.textContent?.trim(), 10); checkGiftCard(doc); } catch (error) { } } } card = {likes: likes, dislikes: dislikes, rankText: rankText, popularityCount: popularityCount, needCount: needCount, tradeCount: tradeCount}; if (card.likes || card.dislikes) { await cacheCard(cacheKey, card) } return card; } async function updateCardInfo(cardId, element) { if (!cardId || !element) { return; } try { const card = await loadCard(cardId); // Удаляем старую статистику, если она есть element.querySelector('.card-stats')?.remove(); const stats = document.createElement('div'); stats.className = 'card-stats'; stats.innerHTML = ` <span title="Владельцев"> <i class="fas fa-users"></i> ${card.popularityCount} </span> <span title="Хотят получить"> <i class="fas fa-heart"></i> ${card.needCount} </span> <span title="Готовы обменять"> <i class="fas fa-sync-alt"></i> ${card.tradeCount} </span> `; // Добавляем статистику под карточку element.appendChild(stats); } catch (error) { throw error; } } function clearMarkFromCards() { cleanByClass('div-marked'); } function removeAllLinkIcons() { cleanByClass('link-icon'); } function cleanByClass(className) { const list = document.querySelectorAll('.' + className); list.forEach(item => item.remove()); } function getCardsOnPage() { return Array.from( document.querySelectorAll(cardClasses) ).filter(card => card.offsetParent !== null); } async function processCards() { if (isCardRemeltPage()) { const storedData = JSON.parse(localStorage.getItem('animeCardsData')) || {}; if (Object.keys(storedData).length < 1) { await readyRemeltCards(); return; } } removeMatchingWatchlistItems(); removeAllLinkIcons(); clearMarkFromCards(); const cards = getCardsOnPage(); let counter = cards.length; if (!counter) { return; } let buttonId = 'processCards'; startAnimation(buttonId); updateButtonCounter(buttonId, counter); showNotification('Проверяю спрос на ' + counter + ' карточек'); for (const card of cards) { if (card.classList.contains('trade__inventory-item--lock') || card.classList.contains('remelt__inventory-item--lock')) { continue; } card.classList.add('processing-card'); let cardId = await getCardId(card); if (cardId) { await updateCardInfo(cardId, card).catch(error => { return; }); counter--; updateButtonCounter(buttonId, counter); } card.classList.remove('processing-card'); if (card.classList.contains('lootbox__card')) { card.addEventListener('click', removeAllLinkIcons); } } showNotification('Проверка спроса завершена'); stopAnimation(buttonId); } function removeMatchingWatchlistItems() { const watchlistItems = document.querySelectorAll('.watchlist__item'); if (watchlistItems.length == 0) { return; } watchlistItems.forEach(item => { const episodesText = item.querySelector('.watchlist__episodes')?.textContent.trim(); if (episodesText) { const matches = episodesText.match(/[\d]+/g); if (matches) { const currentEpisode = parseInt(matches[0], 10); const totalEpisodes = parseInt(matches.length === 4 ? matches[3] : matches[1], 10); if (currentEpisode === totalEpisodes) { item.remove(); } } } }); if (watchlistItems.length) { showNotification('Из списка удалены просмотренные аниме. В списке осталось ' + document.querySelectorAll('.watchlist__item').length + ' записей.'); } } function startAnimation(id) { $('#' + id + ' span:first').css('animation', 'pulseIcon 1s ease-in-out infinite'); } function stopAnimation(id) { $('#' + id + ' span:first').css('animation', ''); } function getButton(id, className, percent, text, clickFunction) { const button = document.createElement('button'); button.id = id; button.style.position = 'fixed'; button.style.top = percent + '%'; button.style.right = '1%'; button.style.zIndex = '1000'; button.style.backgroundColor = '#6c5ce7'; button.style.color = '#fff'; button.style.border = 'none'; button.style.borderRadius = '50%'; button.style.width = '45px'; button.style.height = '45px'; button.style.padding = '0'; button.style.cursor = 'pointer'; button.style.boxShadow = '0 2px 5px rgba(0, 0, 0, 0.2)'; button.style.transition = 'all 0.3s ease'; button.onmouseover = function() { this.style.backgroundColor = '#5f51e3'; tooltip.style.opacity = '1'; tooltip.style.transform = 'translateX(0)'; }; button.onmouseout = function() { this.style.backgroundColor = '#6c5ce7'; tooltip.style.opacity = '0'; tooltip.style.transform = 'translateX(10px)'; }; const icon = document.createElement('span'); icon.className = 'fal fa-' + className; icon.style.display = 'inline-block'; icon.style.fontSize = '20px'; button.appendChild(icon); const tooltip = document.createElement('div'); tooltip.style.cssText = ` position: fixed; right: calc(1% + 55px); background-color: #2d3436; color: #fff; padding: 8px 12px; border-radius: 4px; font-size: 14px; opacity: 0; transition: all 0.3s ease; white-space: nowrap; top: ${percent}%; transform: translateX(10px); z-index: 999; pointer-events: none; `; switch(id) { case 'processCards': tooltip.textContent = 'Узнать спрос'; break; case 'readyToCharge': tooltip.textContent = 'Отметить всё как "Готов обменять"'; break; case 'iNeedAllThisCards': tooltip.textContent = 'Отметить всё как "Хочу карту"'; break; case 'readyRemeltCards': tooltip.textContent = 'Кешировать карточки'; break; default: tooltip.textContent = text; } button.addEventListener('click', function(e) { e.stopPropagation(); clickFunction(e); }); const container = document.createElement('div'); container.appendChild(tooltip); container.appendChild(button); button.classList.add('action-button'); return container; } function updateButtonCounter(id, counter) { return; } function addUpdateButton() { // Проверяем, находимся ли мы на странице сообщений if (window.location.pathname.includes('/pm/')) { // Если на странице сообщений, не добавляем кнопки return; } if (!document.querySelector('#fetchLinksButton')) { let cards = getCardsOnPage(); document.body.appendChild(getButton('processCards', 'star', 37, 'Сравнить карточки', processCards)); if (!cards.length) { return } if (isMyCardPage()) { document.body.appendChild(getButton('readyToCharge', 'handshake', 50, '"Готов поменять" на все карточки', readyToCharge)); } if (isAnimePage()) { document.body.appendChild(getButton('iNeedAllThisCards', 'search', 50, '"Хочу карту" на все карточки', iNeedAllThisCards)); } if (isCardRemeltPage()) { document.body.appendChild(getButton('readyRemeltCards', 'yin-yang', 50, 'закешировать карточки', readyRemeltCards)); const storedData = JSON.parse(localStorage.getItem('animeCardsData')) || {}; updateButtonCounter('readyRemeltCards', Object.keys(storedData).length); } } } function isMyCardPage() { return (/^\/user\/(.*)\/cards(\/page\/\d+\/)?/).test(window.location.pathname) } function isCardRemeltPage() { return (/^\/cards_remelt\//).test(window.location.pathname) } function isAnimePage() { return $('#anime-data').length > 0; } async function readyRemeltCards() { showNotification('Кеширую все карты так как иначе на этой странице не получится их определить рейтинги'); const linkElement = document.querySelector('a.button.button--left-icon.mr-3'); const href = linkElement ? linkElement.href : null; if (!href) { return; } removeMatchingWatchlistItems(); removeAllLinkIcons(); clearMarkFromCards(); const cards = getCardsOnPage(); let counter = cards.length; if (!counter) { return; } let buttonId = 'readyRemeltCards'; startAnimation(buttonId); await scrapeAllPages(href, buttonId); stopAnimation(buttonId); } async function scrapeAllPages(firstPageHref, buttonId) { const response = await fetch(firstPageHref); if (!response.ok) { throw new Error(`Ошибка HTTP: ${response.status}`); } const firstPageDoc = new DOMParser().parseFromString(await response.text(), 'text/html'); const pagination = firstPageDoc.querySelector('#pagination'); if (!pagination) { return; } let storedData = JSON.parse(localStorage.getItem('animeCardsData')) || {}; const titleElement = firstPageDoc.querySelector('h1.secondary-title.text-center'); if (titleElement) { const match = titleElement.textContent.match(/\((\d+)\s*шт\.\)/); const cardsCount = match ? parseInt(match[1], 10) : -1; if (cardsCount == Object.keys(storedData).length) { showNotification('На данный момент в кеше карточек ровно столько же сколько в профиле пользователя'); return; } } const lastPageLink = pagination.querySelector('a:last-of-type'); if (!lastPageLink) { return; } const lastPageNumber = parseInt(lastPageLink.textContent.trim(), 10); if (isNaN(lastPageNumber)) { return; } async function processCardsToLocalstorage(doc, pageNum) { const cards = doc.querySelectorAll('.anime-cards__item'); cards.forEach(card => { const cardId = card.getAttribute('data-id'); const ownerId = card.getAttribute('data-owner-id'); const name = card.getAttribute('data-name'); const rank = card.getAttribute('data-rank'); const animeLink = card.getAttribute('data-anime-link'); const image = card.getAttribute('data-image'); const ownerKey = 'o_' + ownerId; if (!ownerId || !cardId) return; if (!storedData[ownerKey]) { storedData[ownerKey] = []; } storedData[ownerKey].push({ cardId, name, rank, animeLink, image, ownerId }); }); } async function fetchPage(url) { try { const response = await fetch(url); if (!response.ok) throw new Error(`Ошибка загрузки страницы ${url}`); return await response.text(); } catch (error) { return null; } } processCardsToLocalstorage(firstPageDoc, 1); if (lastPageNumber > 1) { const parser = new DOMParser(); for (let i = 2; i <= lastPageNumber; i++) { const pageUrl = lastPageLink.href.replace(/page\/\d+/, `page/${i}`); const pageHTML = await fetchPage(pageUrl); if (pageHTML) { processCardsToLocalstorage(parser.parseFromString(pageHTML, 'text/html'), i); } await new Promise(resolve => setTimeout(resolve, 3000)); } } localStorage.setItem('animeCardsData', JSON.stringify(storedData)); document.body.appendChild(getButton('processCards', 'star', 37, 'Сравнить карточки', processCards)); await processCards(); } async function iNeedAllThisCards() { let cards = getCardsOnPage(); showNotification('Отметить "Хочу карточку" на все ' + cards.length + ' карточек на странице'); clearMarkFromCards(); cardCounter = 0; for (const card of cards) { if (card.classList.contains('anime-cards__owned-by-user')) { continue; } let cardId = await getCardId(card); if (cardId) { await iNeedCard(cardId).catch(error => { return; }); } } } async function getCardId(card) { let cardId = card.getAttribute('card-id') || card.getAttribute('data-card-id') || card.getAttribute('data-id'); const href = card.getAttribute('href'); if (href) { let cardIdMatch = href.match(/\/cards\/(\d+)\/users\//); if (cardIdMatch) { cardId = cardIdMatch[1]; } } if (cardId) { const cardByOwner = await getFirstCardByOwner(cardId); if (cardByOwner) { cardId = cardByOwner.cardId; } } return cardId; } async function getFirstCardByOwner(ownerId) { const storedData = JSON.parse(localStorage.getItem('animeCardsData')) || {}; const key = 'o_' + ownerId; return storedData[key] && storedData[key].length > 0 ? storedData[key][0] : null; } async function readyToCharge() { showNotification('Отмечаем все карты на странице как: "Готов обменять" кроме тех что на обмене и заблокированных'); let cards = getCardsOnPage(); let counter = cards.length; let buttonId = 'readyToCharge'; startAnimation(buttonId); updateButtonCounter(buttonId, counter); clearMarkFromCards(); // Создаем прогресс-бар const progressBar = createProgressBar(); cardCounter = 0; // Считаем только карты, которые не заблокированы const totalCards = cards.filter(card => !card.classList.contains('trade__inventory-item--lock')).length; let processedCards = 0; for (const card of cards) { if (card.classList.contains('trade__inventory-item--lock')) { continue; } let cardId = await getCardId(card); if (cardId) { await readyToChargeCard(cardId); processedCards++; // Обновляем прогресс-бар progressBar.update(processedCards, totalCards); counter--; updateButtonCounter(buttonId, counter); } } // Задержка перед удалением прогресс-бара setTimeout(() => { progressBar.remove(); }, 1000); showNotification('Отправили на обмен ' + cardCounter + ' карточек на странице'); stopAnimation(buttonId); } const readyToChargeCard = async (cardId) => { await sleep(DELAY * 2); const url = '/engine/ajax/controller.php?mod=trade_ajax'; const data = { action: 'propose_add', type: 1, card_id: cardId, user_hash: dle_login_hash }; try { const response = await fetch(url, { method: 'POST', headers: { 'Content-Type': 'application/x-www-form-urlencoded', }, body: new URLSearchParams(data).toString() }); if (response.status === 502) { throw new Error("502 Bad Gateway"); } if (response.ok) { const data = await response.json(); if (data.error) { if (data.error == 'Слишком часто, подождите пару секунд и повторите действие') { await readyToChargeCard(cardId); return; } } if ( data.status == 'added' ) { cardCounter++; return; } if ( data.status == 'deleted' ) { await readyToChargeCard(cardId); return; } cardCounter++; } } catch (error) { } }; const style = document.createElement('style'); style.textContent = ` @keyframes pulseIcon { 0% { transform: scale(1); } 50% { transform: scale(1.2); } 100% { transform: scale(1); } } @keyframes slideDown { from { transform: translate(-50%, -20px); opacity: 0; } to { transform: translate(-50%, 0); opacity: 1; } } @keyframes fadeOut { from { opacity: 1; } to { opacity: 0; } } @keyframes glowEffect { 0% { box-shadow: 0 0 5px #6c5ce7; } 50% { box-shadow: 0 0 20px #6c5ce7; } 100% { box-shadow: 0 0 5px #6c5ce7; } } .processing-card { animation: glowEffect 1.5s infinite; position: relative; z-index: 1; } .trade-history .card-preview { width: 180px; height: auto; margin: 5px; } .history__body-item img { width: 180px !important; height: auto !important; } .history__body-item { margin: 5px !important; } .progress-bar { position: fixed; top: 0; left: 0; width: 100%; height: 3px; background: #ddd; z-index: 10000; } .progress-bar__fill { width: 0%; height: 100%; background: linear-gradient(to right, #6c5ce7, #a367dc); transition: width 0.3s ease; } .action-button { position: relative; overflow: hidden; transition: background-color 0.3s ease; } .action-button::after { content: ''; position: absolute; top: 50%; left: 50%; width: 0; height: 0; background: rgba(255,255,255,0.2); border-radius: 50%; transform: translate(-50%, -50%); transition: width 0.6s ease, height 0.6s ease; } .action-button:active::after { width: 200px; height: 200px; } .card-stats { position: relative; background: linear-gradient(45deg, #6c5ce7, #a367dc); padding: 8px; color: white; font-size: 12px; margin-top: 5px; border-radius: 5px; display: flex; justify-content: space-between; align-items: center; text-shadow: 1px 1px 2px rgba(0,0,0,0.3); animation: fadeInUp 0.3s ease; } .card-stats span { display: flex; align-items: center; gap: 4px; } .card-stats span i { font-size: 14px; } @keyframes fadeInUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } } *:hover > .card-stats { opacity: 1; } .lootbox__card { position: relative; display: inline-block; width: fit-content; } .lootbox__card img { display: block; width: 100%; height: auto; } .lootbox__card .card-stats { position: relative; width: 100%; margin-top: 5px; } `; document.head.appendChild(style); function clearIcons() { $('.card-notification:first')?.click(); } function autoRepeatCheck() { clearIcons(); checkGiftCard(document); Audio.prototype.play = function() { return new Promise(() => {}); }; } async function checkGiftCard(doc) { const button = doc.querySelector('#gift-icon'); if (!button) return; const giftCode = button.getAttribute('data-code'); if (!giftCode) return false; try { const response = await fetch('/engine/ajax/controller.php?mod=gift_code_game', { method: 'POST', headers: { 'Content-Type': 'application/x-www-form-urlencoded' }, body: new URLSearchParams({ code: giftCode, user_hash: dle_login_hash }) }); const data = await response.json(); if (data.status === 'ok') { showNotification(data.text); button.remove(); } } catch (error) { } } function startPing() { const userHash = window.dle_login_hash; if (!userHash) { return; } const currentDomain = window.location.origin; const url = `${currentDomain}/engine/ajax/controller.php?mod=user_count_timer&user_hash=${userHash}`; fetch(url) .then(response => { if (!response.ok) { throw new Error(`HTTP error! Status: ${response.status}`); } return response.json(); }) .then(data => { }) .catch(error => { }); } function checkNewCard() { const currentDateTime = new Date(); const userHash = window.dle_login_hash; if (!userHash) { return; } const localStorageKey = 'checkCardStopped' + window.dle_login_hash; if (localStorage.getItem(localStorageKey) === currentDateTime.toISOString().slice(0, 13)) { return; } const currentDomain = window.location.origin; const url = `${currentDomain}/engine/ajax/controller.php?mod=reward_card&action=check_reward&user_hash=${userHash}`; fetch(url) .then(response => { if (!response.ok) { throw new Error(`HTTP error! Status: ${response.status}`); } return response.json(); }) .then(data => { if (data.stop_reward === "yes") { localStorage.setItem(localStorageKey, currentDateTime.toISOString().slice(0, 13)); return; } if (!data.cards || !data.cards.owner_id) { return; } const ownerId = data.cards.owner_id; if (data.cards.name) { showNotification('Получена новая карта "' + data.cards.name + '"'); } const url = `${currentDomain}/engine/ajax/controller.php?mod=cards_ajax`; const postData = new URLSearchParams({ action: "take_card", owner_id: ownerId }); fetch(url, { method: "POST", headers: { "Content-Type": "application/x-www-form-urlencoded" }, body: postData.toString() }) .then(response => { if (!response.ok) { throw new Error(`HTTP error! Status: ${response.status}`); } return response.json(); }) .then(data => { }) .catch(error => { }); }) .catch(error => { }); } async function setCache(key, data, ttlInSeconds) { const expires = Date.now() + ttlInSeconds * 1000; const cacheData = { data, expires }; localStorage.setItem(key, JSON.stringify(cacheData)); } async function getCache(key) { const cacheData = JSON.parse(localStorage.getItem(key)); if (!cacheData) return null; if (Date.now() > cacheData.expires) { localStorage.removeItem(key); return null; } return cacheData.data; } async function cacheCard(key, data) { await setCache(key, data, 3600); } async function getCard(key) { return await getCache(key); } function addClearButton() { const filterControls = document.querySelector('.card-filter-form__controls'); if (!filterControls) { return; } const inputField = filterControls.querySelector('.card-filter-form__search'); if (!inputField) { return; } const searchButton = filterControls.querySelector('.tabs__search-btn'); if (!searchButton) { return; } inputField.addEventListener('keydown', function (event) { if (event.key === 'Enter') { event.preventDefault(); searchButton.click(); } }); const clearButton = document.createElement('button'); clearButton.innerHTML = '<i class="fas fa-times"></i>'; clearButton.classList.add('clear-search-btn'); clearButton.style.margin = '5px'; clearButton.style.position = 'absolute'; clearButton.style.padding = '10px'; clearButton.style.background = 'red'; clearButton.style.color = 'white'; clearButton.style.border = 'none'; clearButton.style.cursor = 'pointer'; clearButton.style.boxShadow = '0 2px 5px rgba(0, 0, 0, 0.2)'; clearButton.style.fontSize = '14px'; clearButton.style.borderRadius = '5px'; clearButton.addEventListener('click', function () { inputField.value = ''; searchButton.click(); }); inputField.style.marginLeft = '30px'; inputField.parentNode.insertBefore(clearButton, inputField); } function showNotification(message) { const notification = document.createElement('div'); notification.style.cssText = ` position: fixed; top: 20px; left: 50%; transform: translateX(-50%); background: linear-gradient(45deg, #6c5ce7, #a367dc); color: white; padding: 12px 24px; border-radius: 8px; box-shadow: 0 4px 15px rgba(0,0,0,0.2); z-index: 9999; animation: slideDown 0.5s ease, fadeOut 0.5s ease 2.5s forwards; font-size: 14px; `; notification.textContent = message; document.body.appendChild(notification); setTimeout(() => notification.remove(), 3000); } function createProgressBar() { const progressBar = document.createElement('div'); progressBar.className = 'progress-bar'; const progress = document.createElement('div'); progress.className = 'progress-bar__fill'; progressBar.appendChild(progress); document.body.appendChild(progressBar); return { update: (current, total) => { const percentage = (current / total) * 100; progress.style.width = percentage + '%'; }, remove: () => { progressBar.remove(); } }; } (function() { 'use strict'; setInterval(autoRepeatCheck, 2000); setInterval(startPing, 31000); setInterval(checkNewCard, 10000); addUpdateButton(); addClearButton(); $('#tg-banner').remove(); localStorage.setItem('notify18', 'closed'); localStorage.setItem('hideTelegramAs', 'true'); $('div .pmovie__related a.glav-s:first')?.click()?.remove(); const tradePagePattern = /\/trades\/(\d+|history|offers\/\d+)|\/cards\/\d+\/trade\/|\/cards\/pack\//; if (tradePagePattern.test(window.location.pathname)) { document.querySelectorAll('.trade__main-item, .history__body-item, .trade__inventory-item, .card-show__placeholder, .card-pack__card').forEach(cardLink => { const wrapper = document.createElement('div'); const cardImage = cardLink.querySelector('.card-show__image, img'); const isTradeCard = window.location.pathname.includes('/cards/'); if (cardImage) { wrapper.style.display = 'inline-block'; wrapper.style.verticalAlign = 'top'; wrapper.style.position = 'relative'; wrapper.style.zIndex = '1'; if (isTradeCard) { wrapper.style.width = cardImage.offsetWidth + 'px'; wrapper.style.left = '50%'; wrapper.style.transform = 'translateX(-50%)'; } cardLink.parentNode.insertBefore(wrapper, cardLink); wrapper.appendChild(cardLink); const linkIcon = cardLink.nextElementSibling; if (linkIcon && linkIcon.classList.contains('link-icon')) { wrapper.appendChild(linkIcon); Object.assign(linkIcon.style, { position: 'relative', display: 'block', width: isTradeCard ? cardImage.offsetWidth + 'px' : '100%', backgroundColor: 'rgba(0, 128, 0, 0.8)', color: 'rgb(255, 255, 255)', padding: '2px 5px', borderRadius: '3px', fontSize: '12px', marginTop: '2px', boxSizing: 'border-box', zIndex: '2' }); } } }); const nameWrapper = document.querySelector('.card-show__name-wrapper'); if (nameWrapper) { nameWrapper.style.position = 'relative'; nameWrapper.style.zIndex = '0'; } } })();