// ==UserScript== // @name 立创商城自动领券 // @version 0.6 // @license MIT // @namespace http://tampermonkey.net/ // @description 立创商城自动领券~~~ // @author Clistery // @match https://www.szlcsc.com/huodong.html* // @icon https://www.google.com/s2/favicons?sz=64&domain=szlcsc.com // @grant none // @downloadURL none // ==/UserScript== ;(function () { 'use strict' // 添加通知样式 const style = document.createElement('style') style.textContent = ` .notification { position: fixed; top: 50px; right: 20px; padding: 15px; background-color: #444; color: white; border-radius: 5px; box-shadow: 0 0 10px rgba(0, 0, 0, 0.1); opacity: 0; transition: opacity 0.5s ease, right 0.5s ease; z-index: 9999; transform: translate(0%, -50%); } .notification.show { opacity: 1; top: 50%; right: 50px; } .notification.hide { opacity: 0; top: 50%; right: 20px; } #get-tickets-btn { background-image: linear-gradient(0deg, #558b2f, #7cb342); cursor: pointer; position: fixed; width: 20px; display: flex; top: 50%; right: 0px; writing-mode: vertical-lr; text-orientation: upright; padding: 5px 10px; z-index: 100001; border-radius: 10px; opacity: 0.7; box-shadow: 0 2px 2px 0 rgba(0,0,0,0.14), 0 1px 5px 0 rgba(0,0,0,0.12), 0 3px 1px -2px rgba(0,0,0,0.2); overflow: hidden; transform: translate(0%, -50%); user-select: none; } ` document.head.appendChild(style) // 显示通知函数 function showNotification(message, duration = 3000) { const notification = document.createElement('div') notification.className = 'notification' notification.textContent = message document.body.appendChild(notification) // 显示通知 setTimeout(() => { notification.classList.add('show') }, 100) // 隐藏通知 setTimeout(() => { notification.classList.remove('show') notification.classList.add('hide') setTimeout(() => { document.body.removeChild(notification) }, 500) }, duration) } if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', (event) => { loadTickets() }) } else { loadTickets() } function loadTickets() { if (window.getTicketElements) { console.warn('ticket elements loaded!') } console.log('load ticket elements') let allTicketContainer = document.querySelectorAll('.coupon-item') if (allTicketContainer.length <= 0) { console.error('优惠券元素查询失败') return } window.getTicketElements = [] for (let e of allTicketContainer) { if (e.classList.contains('coupon-item-plus')) { continue } let btn = e.querySelector('.coupon-item-btn') if (btn) { if (!e.textContent.includes('新人专享') && btn.textContent.includes('立即抢券')) { if (e.textContent.includes('满16可用') || e.textContent.includes('满1可用')) { let ellipsisE = e.querySelector('.ellipsis') console.log(ellipsisE.textContent) window.getTicketElements.push({ title: ellipsisE.textContent, ele: btn, }) } } else if (btn.textContent.includes('立即使用')) { let dataset = btn.dataset if (dataset.url) { btn.innerHTML = ` ${btn.innerHTML} ` btn.dataset.isdone = true // 禁止触发点击 delete dataset.url } } } } if (window.getTicketElements.length > 0) { showNotification(`可领 ${window.getTicketElements.length} 张券`) } } let getTicketBtn = document.createElement('div') getTicketBtn.innerHTML = `