您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Removes ads in Yandex search results.
当前为
// ==UserScript== // @name No Yandex Ads // @namespace lainverse_no_yandex_ads // @description Removes ads in Yandex search results. // @author lainverse // @license CC BY-SA // @version 5.8 // @include /^https?://(news\.yandex\.|(www\.)?yandex\.[^/]+/(yand)?search[/?])/ // @grant none // ==/UserScript== /* jshint -W084, esnext: true*/ (function(){ 'use strict'; // Generic ads removal and fixes (function(s){ if (s) s.style.marginTop='0'; })(document.querySelector('.serp-header')); (function(s){ while(s = document.querySelector('.serp-adv__head+.serp-item')) s.parentNode.removeChild(s); })(); (function(s){ for (var l = 0; l < s.length; l++) s[l].parentNode.removeChild(s[l]); })(document.querySelectorAll(['#adbanner', '.serp-adv', '.b-spec-adv', 'div[class*="serp-adv__"]'].join(','))); // Search ads function removeAds() { var s = document.querySelectorAll(['.serp-block', '.serp-item', '.search-item'].join(',')); for (var l = 0; l < s.length; l++) { var i = s[l].querySelector(['.label', '.serp-item__label', '.document__provider-name'].join(',')); if (!i) continue; if (i.textContent.indexOf('Реклама') > -1 || i.textContent.indexOf('Яндекс.Директ') > -1){ s[l].parentNode.removeChild(s[l]); console.log('Ads removed.'); } } } // News ads function removeNewsAds() { var s = document.querySelectorAll(['.story[id]', '.document[id]', '.story__group[id]'].join(',')); for (var l = 0; l < s.length; l++) if (window.getComputedStyle(s[l]).position === 'absolute') { s[l].parentNode.removeChild(s[l]); console.log('Ads removed.'); } } // News fixes function removePageAdsClass() { if (document.body.classList.contains("b-page_ads_yes")){ document.body.classList.remove("b-page_ads_yes"); console.log('Page ads class removed.'); } } // Attaches observer to the page elements which Yandex updates via AJAX to display new search or news results function pageUpdateObserver(func, obj, params) { if (obj) new MutationObserver(func).observe(obj,(params?params:{childList:true})); } if (window.location.hostname.search(/^news\./i) === 0) { pageUpdateObserver(removeNewsAds, document.querySelector('BODY')); pageUpdateObserver(removePageAdsClass, document.body, {attributes:true, attributesFilter:['class']}); removeNewsAds(); removePageAdsClass(); } else { pageUpdateObserver(removeAds, document.querySelector('.main__content')); removeAds(); } })();
QingJ © 2025
镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址