闲鱼自动监控个人卖家上新:诺瓦 Appia 意大利商用咖啡机,自动刷新+弹窗+声音提醒
// ==UserScript==
// @name 闲鱼商用咖啡机监控(仅个人卖家)
// @namespace https://greasyfork.org/users/123456
// @version 1.0
// @description 闲鱼自动监控个人卖家上新:诺瓦 Appia 意大利商用咖啡机,自动刷新+弹窗+声音提醒
// @author white ss
// @match *://s.2.taobao.com/*
// @grant GM_notification
// @grant GM_addStyle
// @run-at document-end
// @license MIT
// ==/UserScript==
(function() {
'use strict';
const KEYWORDS = ['诺瓦', 'appia', 'Appia', 'APPIA', '咖啡机', '商用', '意大利', '咖啡店'];
const REFRESH_SEC = 30;
const ALARM_URL = 'https://assets.mixkit.co/sfx/preview/mixkit-software-interface-start-2574.mp3';
let notifiedIds = new Set();
let isFirstLoad = true;
let running = true;
GM_addStyle(`
#xy-coffee-monitor{position:fixed;top:10px;right:10px;background:#fff;padding:10px 14px;border-radius:8px;box-shadow:0 0 10px rgba(0,0,0,0.2);z-index:999999;font-size:14px;}
#xy-coffee-monitor button{margin-left:8px;padding:4px 8px;background:#ff6a00;color:#fff;border:none;border-radius:4px;cursor:pointer;}
`);
const panel = document.createElement('div');
panel.id = 'xy-coffee-monitor';
panel.innerHTML = `咖啡机监控(仅个人) 暂停`;
document.body.appendChild(panel);
document.getElementById('xy-toggle').onclick = function() {
running = !running;
panel.innerHTML = running
? '咖啡机监控(仅个人) 暂停'
: '已暂停 继续';
};
function playAlert() {
const audio = new Audio(ALARM_URL);
audio.volume = 0.7;
audio.play().catch(() => {});
}
function isPersonalSeller(el) {
const text = el.textContent || '';
return /个人|个人卖家|个人闲置|自用/.test(text) && !/商家|店铺|批发|回收|租赁/.test(text);
}
function titleMatch(title) {
if (!title) return false;
return KEYWORDS.some(k => title.includes(k));
}
function scanItems() {
const items = [];
document.querySelectorAll('.item-wrapper').forEach(el => {
const id = el.dataset.id;
const title = el.querySelector('.item-title')?.textContent?.trim() || '';
const sellerEl = el.querySelector('.seller-type, .user-type');
if (id && titleMatch(title) && sellerEl && isPersonalSeller(sellerEl)) {
items.push({ id, title });
}
});
return items;
}
function checkNewItems() {
if (!running) return;
const items = scanItems();
if (isFirstLoad) {
items.forEach(i => notifiedIds.add(i.id));
isFirstLoad = false;
return;
}
let hasNew = false;
items.forEach(item => {
if (!notifiedIds.has(item.id)) {
notifiedIds.add(item.id);
hasNew = true;
}
});
if (hasNew) {
playAlert();
GM_notification({
title: "个人卖家上新!",
text: "诺瓦/Appia/商用咖啡机",
timeout: 10000
});
}
}
setInterval(function() {
if (running) location.reload();
}, REFRESH_SEC * 1000);
window.addEventListener('load', function() {
setTimeout(checkNewItems, 2000);
});
})();