// ==UserScript== // @name 抖店后台操作增强脚本 // @namespace vip4pt // @version 1.5 // @description 为抖店后台添加一些有用的功能,包括获取Cookie、复制目标信息和隐藏商家助手等选项。单击按钮打开功能菜单,点击菜单以外区域可关闭菜单。 // @author vip4pt // @match https://fxg.jinritemai.com/ffa/* // @match https://im.jinritemai.com/* // @grant GM_setClipboard // @license zh-cn // @downloadURL none // ==/UserScript== (function() { 'use strict'; var menuVisible = false; // 创建按钮容器 var buttonContainer = document.createElement('div'); buttonContainer.style.position = 'fixed'; buttonContainer.style.left = '10px'; buttonContainer.style.bottom = '60px'; buttonContainer.style.zIndex = '9999'; // 创建菜单按钮 var menuButton = document.createElement('button'); menuButton.innerHTML = '打开菜单'; menuButton.style.display = 'block'; menuButton.style.marginBottom = '10px'; buttonContainer.appendChild(menuButton); // 创建菜单内容 var menuContent = document.createElement('div'); menuContent.style.display = 'none'; menuContent.style.backgroundColor = 'white'; menuContent.style.border = '1px solid black'; menuContent.style.padding = '10px'; buttonContainer.appendChild(menuContent); // 创建获取Cookie按钮 var cookieButton = document.createElement('button'); cookieButton.innerHTML = '获取Cookie'; cookieButton.style.display = 'block'; cookieButton.style.marginBottom = '5px'; menuContent.appendChild(cookieButton); // 创建获取目标信息按钮 var targetInfoButton = document.createElement('button'); targetInfoButton.innerHTML = '获取目标信息'; targetInfoButton.style.display = 'block'; targetInfoButton.style.marginBottom = '5px'; menuContent.appendChild(targetInfoButton); // 创建选择框 var toggleDivButton = document.createElement('input'); toggleDivButton.type = 'checkbox'; toggleDivButton.style.marginRight = '5px'; var toggleDivLabel = document.createElement('label'); toggleDivLabel.innerHTML = '隐藏商家助手'; toggleDivLabel.appendChild(toggleDivButton); menuContent.appendChild(toggleDivLabel); // 菜单按钮点击事件处理程序 menuButton.addEventListener('click', function() { toggleMenu(); }); // 获取Cookie按钮点击事件处理程序 cookieButton.addEventListener('click', function() { var cookie = document.cookie; console.log('Cookie:', cookie); GM_setClipboard(cookie); showNotification('Cookie已复制到剪贴板'); }); // 获取目标信息按钮点击事件处理程序 targetInfoButton.addEventListener('click', function() { var targetElements = document.evaluate("//div[contains(text(), 'ID:')]", document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null); var targetInfoArray = []; for (var i = 0; i < targetElements.snapshotLength; i++) { var targetElement = targetElements.snapshotItem(i); var targetInfo = targetElement.textContent; targetInfoArray.push(targetInfo); } if (targetInfoArray.length > 0) { console.log('目标信息:', targetInfoArray); GM_setClipboard(targetInfoArray.join('\n')); showNotification('目标信息已复制到剪贴板'); } else { console.log('未找到目标信息'); } }); // 选择框点击事件处理程序 toggleDivButton.addEventListener('change', function() { if (toggleDivButton.checked) { hideAssistant(); } else { showAssistant(); } }); // 点击页面其他区域收起菜单 document.addEventListener('click', function(event) { if (menuVisible && !buttonContainer.contains(event.target)) { toggleMenu(); } }); // 切换菜单的显示状态 function toggleMenu() { menuVisible = !menuVisible; if (menuVisible) { menuButton.innerHTML = '关闭菜单'; menuContent.style.display = 'block'; } else { menuButton.innerHTML = '打开菜单'; menuContent.style.display = 'none'; } } // 隐藏元素 function hideAssistant() { var targetClass = 'index_DragController__'; var elements = document.querySelectorAll('body > div[class*="' + targetClass + '"]'); elements.forEach(function(element) { element.style.display = 'none'; }); localStorage.setItem('hideAssistant', 'hidden'); } // 显示元素 function showAssistant() { var targetClass = 'index_DragController__'; var elements = document.querySelectorAll('body > div[class*="' + targetClass + '"]'); elements.forEach(function(element) { element.style.display = ''; }); localStorage.removeItem('hideAssistant'); } // 创建提示框 function showNotification(message) { var alertBox = document.createElement('div'); alertBox.innerHTML = message; alertBox.style.position = 'fixed'; alertBox.style.left = '50%'; alertBox.style.bottom = '10px'; alertBox.style.transform = 'translateX(-50%)'; alertBox.style.padding = '10px'; alertBox.style.backgroundColor = 'white'; alertBox.style.border = '1px solid black'; alertBox.style.zIndex = '9999'; document.body.appendChild(alertBox); setTimeout(function() { document.body.removeChild(alertBox); }, 3000); } // 将容器添加到页面 document.body.appendChild(buttonContainer); })();