淘宝广告屏蔽助手

尝试去除淘宝搜索结果中的动态加载广告以及掌柜热卖。

安装此脚本?
作者推荐脚本

您可能也喜欢删除淘宝/天猫默认评论

安装此脚本
  1. // ==UserScript==
  2. // @name 淘宝广告屏蔽助手
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.3
  5. // @description 尝试去除淘宝搜索结果中的动态加载广告以及掌柜热卖。
  6. // @author oldip
  7. // @match https://s.taobao.com/search*
  8. // @grant none
  9. // @license MIT
  10. // @run-at document-end
  11. // ==/UserScript==
  12.  
  13. (function() {
  14. 'use strict';
  15.  
  16. // const updateMarginLeft = () => {
  17. // // 修正搜寻栏的位置和宽度
  18. // document.querySelectorAll('.PageHeader--suggestWarp--vDSivG5').forEach(el => {
  19. // el.style.marginLeft = 'auto';
  20. // });
  21. // };
  22.  
  23. const removeAdElements = () => {
  24. // 移除搜寻页面内的广告,根据新的元素样式进行更新
  25. document.querySelectorAll('img.mainP4pPic--jbnK3QAX').forEach(el => {
  26. let parent = el.closest('a.doubleCardWrapperAdapt--mEcC7olq');
  27. parent.remove();
  28. });
  29.  
  30. // // 移除右侧掌柜热卖的广告
  31. // document.querySelectorAll('.RightLay--rightWrap--OxNNeu6').forEach(el => {
  32. // el.style.display = 'none';
  33. // });
  34.  
  35. // // 移除下方掌柜热卖的广告
  36. // document.querySelectorAll('.BottomLay--bottomWrap--YBah2VM').forEach(el => {
  37. // el.style.display = 'none';
  38. // });
  39.  
  40. // // 更新页面头部样式
  41. // updateMarginLeft();
  42. };
  43.  
  44. const observer = new MutationObserver(mutations => {
  45. mutations.forEach(mutation => {
  46. if (mutation.addedNodes.length) removeAdElements();
  47. });
  48. });
  49.  
  50. const config = { childList: true, subtree: true };
  51.  
  52. observer.observe(document.body, config);
  53.  
  54. // 初始调用以立即移除广告和修改样式
  55. removeAdElements();
  56.  
  57. // // 监听窗口调整大小事件,动态更新样式
  58. // window.addEventListener('resize', updateMarginLeft);
  59.  
  60. // // 确保在 DOM 内容加载完毕后也更新样式
  61. // document.addEventListener('DOMContentLoaded', updateMarginLeft);
  62. })();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址