// ==UserScript== // @name 拼多多跨境(Temu)弹窗屏蔽-测试版 // @version 0.5.4 // @description 用于屏蔽拼多多跨境卖家平台的弹窗 // @author linying // @match *://kuajing.pinduoduo.com/* // @match *://seller.kuajingmaihuo.com/* // @match *://kuajingboss.com/* // @match *://agentseller.temu.com/* // @exclude */login* // @exclude */settle/site-main* // @exclude */questionnaire?surveyId=* // @exclude */settle/seller-login?redirectUrl=* // @exclude */agentseller*.temu.com/main/authentication?redirectUrl=* // @exclude */agentseller*.temu.com/mmsos/online-shipping-result.html* // @supportURL https://github.com/linying23333 // @homepage https://github.com/linying23333 // @run-at document-idle // @grant none // ==/UserScript== // @require http://ajax.googleapis.com/ajax/libs/jquery/3.7.1/jquery.min.js // @note (预留的jQuery库,以便未来引用) // @grant GM_setValue // @grant GM_getValue // @grant GM_deleteValue // @grant GM.setValue // @grant GM.getValue // @grant GM.deleteValue // @note (预留的数据库加载,以便未来引用) // @icon 来自 https://www.iconfont.cn/ 如果侵犯您的权利请与我沟通 // @note 更新日志&常见问题解决: // @note 本js用户脚本版权归linying所有,仅供研究学习,禁止以任何形式倒卖 //这些参数只能输入数字,否则会导致错误. //时间需要根据您的电脑加载速度而定,切勿无脑调低或者调高 //设置执行等待时间 let WaitTime = 0; // 单位毫秒,1秒 = 1000毫秒 //设置为 1 不启用,推荐值为3800 //是否展示调价菜单 let ShowPriceMenu = 1; // 默认为"1",设置为"0"则为不展示 //快速删除间隔时间 let FastIntervalTime = 100; // 单位毫秒,1秒 = 1000毫秒 //快速删除持续删除时间 let FastDuration = 8000; // 单位毫秒,1秒 = 1000毫秒 //两个设置为 1 不启用,推荐值为8000 //是否弹出快速输出结束提示框 let FastShow = 0; // 默认为"0",设置为"1"则为展示 //设置手动清除按钮 let AddButton = true; //是否添加手动清除按钮,默认true(开启),使用false(关闭) let buttonX = 30; //按钮的Y轴(纵向)百分比值 let buttonY = 92; //按钮的X轴(横向)百分比值 //位置从浏览器屏幕左上角开始计算,X轴+1则向下移动移动百分之1,Y轴+1则向右移动移动百分之1 let debugMode = true; // 控制是否打印日志的开关,默认false(关闭),使用true(开启) 'use strict'; /* 防止代码因其他原因被执行多次 这段代码出自 Via轻插件,作者谷花泰 */ const key = encodeURIComponent('我 是 _拼多多跨境(Temu)弹窗屏蔽-正式白名单版_:({<校验内容>}).'); if (window[key]) return; window[key] = true; // 全局定义是否打印日志调用函数 function log(message) { if (debugMode) { console.log('来自 拼多多跨境(Temu)弹窗屏蔽 js用户脚本提示:\n' + message); } } // 提示调试模式是否开启 (function() { log(`您的 Debug 模式值为 ${debugMode} ,调试模式打印日志已经启用`) })(); //按钮处理部分 //检查是否启用该部分 if (AddButton) { (function() { // 创建一个新的按钮元素 var button = document.createElement('button'); button.id = 'js_button'; button.textContent = '清除弹窗!'; button.style.cssText = ` z-index: 2147483648 !important; position: fixed; top: ${buttonY}%; left: ${buttonX}%; cursor: pointer; /* 鼠标悬停时显示手型 */ `; // 使用了变量 // 为按钮添加点击事件监听器 button.onclick = function() { log('手动清除按钮被点击'); removeElements(); alert('已经执行清除'); }; // 将按钮添加到
外 document.body.insertAdjacentElement("afterend", button); })(); } // 简单粗暴直接对所有都添加样式(显示为空)以屏蔽弹窗 //GM_addStyle("div[data-testid='beast-core-modal-mask']{display:none !important}"); //GM_addStyle("div[data-testid='beast-core-modal']{display:none !important}"); // 已弃用 // 提示用户js用户脚本将会等待变量值 WaitTime 毫秒 // alert(`将会等待 ${WaitTime / 1000} 秒后开始执行`); // 已弃用 insertModalDivs(`将会等待 ${WaitTime / 1000} 秒后开始执行删除`); setTimeout(function() { // insertModalDivs 函数已经定义,并且接收文本参数来插入模态框 insertModalDivs('开始操作'); // 使用你想要显示的文本作为参数 setTimeout(function() { // 直接在setTimeout回调中调用remove函数 remove(); }, 0); // 延迟0毫秒 }, WaitTime); // 延迟WaitTime毫秒 // remove 函数的定义 function remove() { // 检查 document.readyState 是否为 'loading' if (document.readyState === 'loading') { // 如果还在加载中,等待 DOMContentLoaded 事件 document.addEventListener('DOMContentLoaded', startInterval); } else { // 如果 DOM 已经加载完成,则直接执行删除操作 startInterval(); } } // 定义一个变量来存储interval ID,以便稍后清除它 let intervalId; // 启动interval的函数 function startInterval() { // 设置interval来每X毫秒执行removeElements intervalId = setInterval(removeElements, FastIntervalTime); // 这里的单位是毫秒,你可以根据需要调整 // 设置timeout来在 FastDuration 毫秒后退出执行 setTimeout(() => { clearInterval(intervalId); // 检查两个值是否不同,则弹出提示 if (FastIntervalTime !== FastDuration) { log(`${FastDuration} 毫秒已过,停止删除操作。`); // 如果FastShow为1,则弹出提示框 if (FastShow === 1) { alert(`设置的循环时间 ${FastDuration} 毫秒到了,您可以继续操作了 `); } } else { log('快速模式未启用'); // 注意:分号应该在括号外面 } }, FastDuration); // 这里的单位是毫秒,你可以根据需要调整 } function removeElements() { // 移除具有特定id属性的div元素(js_info) const elementsWithTestId0 = document.querySelectorAll('div[id="js_info"]'); elementsWithTestId0.forEach(element => element.remove()); // 查找并删除具有特定data-testid属性的div元素 const elementsWithTestId = document.querySelectorAll('div[data-testid="beast-core-modal"]'); elementsWithTestId.forEach(element => { let shouldRemoveParent = true; // 初始化变量 // 查找 modalDiv 之前的具有 data-testid="beast-core-modal-mask" 的 div 元素 let maskDiv = element.previousElementSibling; while (maskDiv && !maskDiv.matches('div[data-testid="beast-core-modal-mask"]')) { maskDiv = maskDiv.previousElementSibling; } // 如果ShowPriceMenu为0,则直接删除元素,不检查子结构 if (ShowPriceMenu === 0) { element.remove(); return; // 跳出当前循环,因为已经删除了元素 } // 查找包含“切换店铺”文本的div const switchShopDiv = element.querySelector('.layout_title__1eHi_'); if (switchShopDiv && switchShopDiv.textContent.trim().includes('切换店铺')) { shouldRemoveParent = false; // 如果找到,不删除父元素 } // 在当前element中查找所有匹配的