在您安装前,Greasy Fork 希望您知道此脚本包含可能不受欢迎的功能,也许会帮助脚本作者获利,而不能给你带来任何收益。
作者从这份脚本获得佣金,例如透过改写链接或提供优惠券代码以包含推荐或附属代码。
脚本作者的说明:
应GreasyFork代码规范要求:含有优惠券查询功能的脚本必须添加此提示!感谢大家的理解...
优惠查询助手 - 精确获取当前页面的商品 ID
目前为
// ==UserScript== // @name 淘宝天猫优惠查询助手 // @namespace https://www.ishtq.com // @icon https://ae01.alicdn.com/kf/Uc280ab6a71d84b01866aa3546d65bcf9c.png // @version 5.1 // @description 优惠查询助手 - 精确获取当前页面的商品 ID // @author 淘宝天猫优惠查询助手 // @match *://*.tmall.com/* // @match *://*.taobao.com/* // @include http*://chaoshi.tmall.com/* // @include http*://detail.tmall.hk/* // @include http*://chaoshi.detail.tmall.com/* // @antifeature referral-link 应GreasyFork代码规范要求:含有优惠券查询功能的脚本必须添加此提示!感谢大家的理解... // @grant none // ==/UserScript== (function () { 'use strict'; // 创建悬浮按钮 function createFloatingButton() { const button = document.createElement('button'); button.innerText = '查券'; button.style.position = 'fixed'; button.style.bottom = '50px'; button.style.right = '50px'; button.style.zIndex = '9999'; button.style.width = '60px'; button.style.height = '60px'; button.style.backgroundColor = '#ff5000'; button.style.color = '#fff'; button.style.border = 'none'; button.style.borderRadius = '50%'; button.style.cursor = 'pointer'; button.style.boxShadow = '0 4px 8px rgba(0, 0, 0, 0.2)'; button.style.fontSize = '14px'; button.style.fontWeight = 'bold'; button.style.lineHeight = '60px'; button.style.textAlign = 'center'; button.style.transition = 'all 0.3s ease'; // 鼠标悬停样式 button.addEventListener('mouseover', () => { button.style.backgroundColor = '#ff7800'; }); button.addEventListener('mouseout', () => { button.style.backgroundColor = '#ff5000'; }); // 按钮点击事件 button.addEventListener('click', () => { // 获取当前 URL const currentUrl = new URL(window.location.href); // 提取商品 ID const itemId = currentUrl.searchParams.get('id'); if (!itemId) { alert('未找到商品 ID,请确认当前页面是商品详情页!'); return; } // 构造简化 URL const simplifiedUrl = `https://item.taobao.com/item.htm?id=${itemId}`; // 生成查询链接 const queryUrl = `https://tyfnr.yhzu.cn/?r=/l&kw=${encodeURIComponent(simplifiedUrl)}&origin_id=&sort=0`; // 打开查询链接 window.open(queryUrl, '_blank'); }); document.body.appendChild(button); } // 初始化脚本 function init() { if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', createFloatingButton); } else { createFloatingButton(); } } // 启动脚本 init(); })();