Warning: fopen(/www/sites/update.greasyfork.icu/index/store/temp/49bbe4adf8d347d05bd73b2d07c424f3.js): failed to open stream: No space left on device in /www/sites/update.greasyfork.icu/index/scriptControl.php on line 65
// ==UserScript== // @name 美团券搜索 // @license MIT // @version 1.4 // @description 注意需要请求手机页面,先登录账户后,获取列表 // @author Bingo95 // @match https://offsiteact.meituan.com/web/hoae/collection_waimai_v8/index.html* // @grant none // @namespace https://greasyfork.org/users/1312821 // @downloadURL https://update.greasyfork.icu/scripts/497642/%E7%BE%8E%E5%9B%A2%E5%88%B8%E6%90%9C%E7%B4%A2.user.js // @updateURL https://update.greasyfork.icu/scripts/497642/%E7%BE%8E%E5%9B%A2%E5%88%B8%E6%90%9C%E7%B4%A2.meta.js // ==/UserScript== (function() { 'use strict'; // 创建UI元素 function createUI() { // 创建搜索框 const searchBox = document.createElement('input'); searchBox.type = 'search'; searchBox.placeholder = '输入商家名称搜索...'; searchBox.style.cssText = ` position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); width: 80%; height: 40px; padding: 5px 15px; border: 1px solid #ccc; border-radius: 20px; z-index: 9999; background: rgba(255, 255, 255, 0.95); box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1); `; // 创建加载按钮 const loadButton = document.createElement('button'); loadButton.textContent = '加载更多'; loadButton.style.cssText = ` position: fixed; top: 40px; right: 20px; padding: 0 20px; height: 40px; border: none; border-radius: 20px; background: #FFC107; color: #fff; font-size: 16px; cursor: pointer; z-index: 9999; box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2); `; // 创建计数器 const counter = document.createElement('div'); counter.id = 'shop-counter'; counter.style.cssText = ` position: fixed; top: 40px; left: 20px; padding: 0 15px; height: 40px; line-height: 40px; font-size: 14px; color: #666; background: rgba(255, 255, 255, 0.95); border-radius: 20px; z-index: 9999; box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1); `; document.body.appendChild(searchBox); document.body.appendChild(loadButton); document.body.appendChild(counter); return { searchBox, loadButton, counter }; } // 加载更多数据 function loadMoreData(loadButton) { let lastCount = 0; let sameCountTimes = 0; const loadInterval = setInterval(() => { const scrollHeight = document.documentElement.scrollHeight; window.scrollTo(0, scrollHeight); const currentCount = document.querySelectorAll('.index-module__poiCardContainer___L28Xd').length; // 如果连续3次数量没变化,认为加载完成 if (currentCount === lastCount) { sameCountTimes++; if (sameCountTimes >= 3) { clearInterval(loadInterval); loadButton.disabled = true; loadButton.textContent = '加载完成'; loadButton.style.background = '#ccc'; } } else { sameCountTimes = 0; lastCount = currentCount; } }, 1000); } // 搜索商家 function searchShops(keyword) { const shops = document.querySelectorAll('.index-module__poiCardContainer___L28Xd'); let visibleCount = 0; shops.forEach(shop => { const name = shop.querySelector('.name').textContent.trim(); if (keyword && !name.toLowerCase().includes(keyword.toLowerCase())) { shop.style.display = 'none'; } else { shop.style.display = 'block'; visibleCount++; } }); // 更新计数器 const counter = document.getElementById('shop-counter'); if (counter) { counter.textContent = `${visibleCount}/${shops.length}`; } } // 监听列表是否加载完成 function observeListLoading(loadButton) { const observer = new MutationObserver((mutations) => { mutations.forEach(mutation => { const nodes = Array.from(mutation.addedNodes); nodes.forEach(node => { if (node.nodeType === 1 && node.textContent.includes('没有更多了')) { loadButton.disabled = true; loadButton.textContent = '已加载完成'; loadButton.style.background = '#ccc'; observer.disconnect(); console.log('列表加载完成'); } }); }); }); observer.observe(document.body, { childList: true, subtree: true }); } // 初始化 function init() { const { searchBox, loadButton, counter } = createUI(); // 添加搜索事件 searchBox.addEventListener('input', (e) => { searchShops(e.target.value.trim()); }); // 添加加载按钮事件 loadButton.addEventListener('click', loadMoreData); // 监听列表加载状态 observeListLoading(loadButton); // 初始计数 searchShops(''); } // 等待页面加载完成后执行 if (document.readyState === 'complete') { init(); } else { window.addEventListener('load', init); } })();