/** * Блокирует Яндекс-Советник на страницах вашего интернет-магазина * https://github.com/SerjoPepper/kick_sovetnik * Если скрипт по каким то причинам перестал работать или что-то ломает на вашем сайте, пожалуйста, создайте тикет: * https://github.com/SerjoPepper/kick_sovetnik/issues */ //if ("Notification" in window) { // Notification = {permission: 'denied'}; //} var _yBrowser = (typeof navigator != 'undefined' && typeof navigator.appVersion != 'undefined' && navigator.appVersion.indexOf('YaBrowser') != -1) ? true : false; if(_yBrowser){ !function(){var e=function(){var e=window.location.hash||!1,t=(document.currentScript||document.getElementById("ss_script"),function(t){e&&"#ssdebug"===e&&console.log(t)});if(!window.MutationObserver)return t("MutationObserver not supported!"),!1;if(navigator.userAgent.indexOf("MSIE")!=-1||navigator.userAgent.indexOf("Trident")!=-1||navigator.userAgent.indexOf("Edge")!=-1)return t("IE or Edge"),!1;var n={},o=!1,r={top:"-1px",display:"table",opacity:"1"},i=new MutationObserver(function(e){e.map(function(e){var n=e.addedNodes[0];if(n&&"DIV"===n.tagName)for(var a in r){if(window.getComputedStyle(n).getPropertyValue(a)!==r[a]){t("YandexDesktopFound-"+a+" false"),o=!1;break}t("YandexDesktopFound-"+a+" true"),o=!0}if(n&&"STYLE"===n.tagName&&/market_context_headcrab_container_relative/.test(n.innerHTML)&&(document.body.removeChild(n),t("style removed")),o){for(var s=n.childNodes,d=0;d0&&!n.panel&&(document.documentElement.style.marginTop="")}),s=new MutationObserver(function(){var e=document.body.style.marginTop;e&&parseInt(e)>0&&!n.panel&&(document.body.style.marginTop="")}),d=function(){return document.body?(i&&i.observe(document.body,{childList:!0,attributes:!0,subtree:!0,attributeFilter:["style"]}),a&&a.observe(document.documentElement,{attributes:!0,attributeFilter:["style"]}),void(s&&s.observe(document.body,{attributes:!0,attributeFilter:["style"]}))):void setTimeout(d,100)};e&&"#ssoff"===e||d()};e()}(); }else{ (function () { function patchOnMessage() { window.addEventListener('message', function (e) { var data; if (typeof e.data === 'string') { try { data = JSON.parse(e.data); } catch (e) { return; } } else { data = e.data; } if (data && data.type === 'MBR_ENVIRONMENT') { e.stopImmediatePropagation(); e.stopPropagation(); e.data = {}; } }, true); } var observer; function init () { try { observer = new MutationObserver(function (records) { check(records); }); } catch (e) { } if (document.body) { checkNodes(document.body.children); } } function startObserve () { if (!document.body) { setTimeout(startObserve, 200); return; } if (observer) { observer.observe(document.body, {childList: true}); } } function stopObserve () { if (observer) { observer.disconnect(); observer = null; } } // Проверки function check (records) { records.forEach(function (record) { var addedNodes = record.addedNodes; if (addedNodes && addedNodes.length) { checkNodes(addedNodes); } }); } function checkNodes (nodes) { Array.prototype.slice.call(nodes).forEach(function (node) { if (isDiv(node) && (hasSovetnikLink(node) || isYaBar(node))) { remove(node); } }); } // Скрываем яндекс-советник со страницы, возвращаем прежний margin-top для body function remove (node) { var style = node.style; style.marginTop = '-200px'; style.zIndex = '-9999'; style.webkitTransform = style.MozTransform = style.msTransform = style.OTransform = style.transform = 'translate(-9999px, -9999px)'; // следим в течении 3 сек за изменением marginTop у html var marginObserver = new MutationObserver(function () { var marginTop = document.documentElement.style.marginTop; if (marginTop && parseInt(marginTop, 10) !== 0) { document.documentElement.style.marginTop = ''; } }); setTimeout(function () { marginObserver.disconnect(); marginObserver = null; }, 5e3); marginObserver.observe(document.documentElement, {attributes: true, attributeFilter: ['style']}); document.documentElement.style.marginTop = ''; } // Определяем по косвенным признакам, что этот элемент - Яндекс-Советник function isYaBar (node) { var bgColor = getStyle(node, 'background-color'); return (bgColor === 'rgb(250, 223, 118)' || bgColor === 'rgb(250, 223, 117)') && getStyle(node, 'position') === 'fixed' && getStyle(node, 'display') === 'table'; } function isDiv (node) { return node.tagName === 'DIV'; } function hasSovetnikLink (node) { return !!node.querySelector('[href*="sovetnik.market.yandex.ru"]'); } function getStyle (node, prop) { return window.getComputedStyle(node).getPropertyValue(prop); } try { init(); startObserve(); patchOnMessage(); setTimeout(stopObserve, 15e3); } catch (e) { } })(); } $(function(){ $('div').each(function(){ //console.log($(this)) }) })