RU AdList JS Fixes

try to take over the world!

当前为 2016-11-02 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name RU AdList JS Fixes
  3. // @namespace ruadlist_js_fixes
  4. // @version 20161102.1
  5. // @description try to take over the world!
  6. // @author lainverse & dimisa
  7. // @match *://*/*
  8. // @grant unsafeWindow
  9. // @grant window.close
  10. // @run-at document-start
  11. // ==/UserScript==
  12.  
  13. (function() {
  14. 'use strict';
  15. var win = (unsafeWindow || window),
  16. isFirefox = /firefox/i.test(navigator.userAgent);
  17.  
  18. // NodeList iterator polyfill (mostly for Safari)
  19. // https://jakearchibald.com/2014/iterators-gonna-iterate/
  20. if (!NodeList.prototype[Symbol.iterator]) {
  21. NodeList.prototype[Symbol.iterator] = Array.prototype[Symbol.iterator];
  22. }
  23.  
  24. // Create fake shadow root and style element as a bait for those who want to break ABP functionality
  25. (function(sr) {
  26. // skip Firefox since ABP doesn't use shadowRoot there
  27. // also, skip browsers which doesn't support createShadowRoot (Safari)
  28. if (isFirefox || !document.documentElement.createShadowRoot) {
  29. return;
  30. }
  31. sr = document.documentElement.createShadowRoot();
  32. // create 'shadow' element similar to ABP
  33. sr.appendChild(document.createElement('shadow'));
  34. // create empty 'style' bait
  35. var st = document.createElement('style');
  36. sr.appendChild(st);
  37. var o = new MutationObserver(function(ms){
  38. var m, node;
  39. for (m of ms) {
  40. for (node of m.removedNodes) {
  41. if (node === st) {
  42. st = document.createElement('style');
  43. sr.appendChild(st);
  44. console.log('Site took the bait and attempted to remove it.');
  45. }
  46. }
  47. }
  48. });
  49. o.observe(sr, {childList: true});
  50. })(document.documentElement.shadowRoot);
  51.  
  52. // Creates and return protected style (unless protection is manually disabled).
  53. // Protected style will re-add itself on removal and remaind enabled on attempt to disable it.
  54. function createStyle(rules, props, skip_protect) {
  55. var root = document.documentElement;
  56.  
  57. function _protect(style) {
  58. Object.defineProperty(style, 'sheet', {
  59. value: style.sheet,
  60. enumerable: true
  61. });
  62. Object.defineProperty(style, 'disabled', {
  63. get: function() {return true;}, //pretend to be disabled
  64. set: function() {},
  65. enumerable: true
  66. });
  67. }
  68.  
  69. function _create() {
  70. var style = root.appendChild(document.createElement('style')),
  71. prop, rule;
  72. style.type = 'text/css';
  73. for (prop in props) {
  74. if (style.hasOwnProperty(prop)) {
  75. style[prop] = props[prop];
  76. }
  77. }
  78. for (rule of rules) {
  79. try {
  80. style.sheet.insertRule(rule, 0);
  81. } catch (e) {
  82. console.error(e);
  83. }
  84. }
  85. if (!skip_protect) {
  86. _protect(style);
  87. }
  88. return style;
  89. }
  90.  
  91. var style = _create();
  92. if (skip_protect) {
  93. return style;
  94. }
  95.  
  96. var o = new MutationObserver(function(ms){
  97. var m, node, rule;
  98. for (m of ms) {
  99. for (node of m.removedNodes) {
  100. if (node === style) {
  101. (new Promise(function(resolve){
  102. setTimeout(function(resolve){
  103. resolve(_create());
  104. }, 0, resolve);
  105. })).then(function(st){
  106. style = st;
  107. })
  108. }
  109. }
  110. }
  111. });
  112. o.observe(root, {childList:true});
  113.  
  114. return style;
  115. }
  116.  
  117. // https://greasyfork.org/scripts/19144-websuckit/
  118. (function() {
  119. // check does browser support Proxy and WebSocket
  120. if (typeof Proxy !== 'function' ||
  121. typeof WebSocket !== 'function') {
  122. return;
  123. }
  124.  
  125. function getWrappedCode(removeSelf) {
  126. var text = getWrappedCode.toString()+WSI.toString();
  127. text = (
  128. '(function(){"use strict";'+
  129. text.replace(/\/\/[^\r\n]*/g,'').replace(/[\s\r\n]+/g,' ')+
  130. '(new WSI(self||window)).init();'+
  131. '})();\n'+
  132. (removeSelf?'var s = document.currentScript; if (s) {s.parentNode.removeChild(s);}':'')
  133. );
  134. return text;
  135. }
  136.  
  137. function WSI(win, safeWin) {
  138. safeWin = safeWin || win;
  139. var masks = [], filter;
  140. for (filter of [// blacklist
  141. '||24video.xxx^',
  142. '||adlabs.ru^', '||adspayformymortgage.win^', '||aviabay.ru^',
  143. '||bgrndi.com^', '||brokeloy.com^',
  144. '||cnamerutor.ru^',
  145. '||docfilms.info^', '||dreadfula.ru^',
  146. '||et-code.ru^',
  147. '||film-doma.ru^',
  148. '||free-torrent.org^', '||free-torrent.pw^',
  149. '||free-torrents.org^', '||free-torrents.pw^',
  150. '||game-torrent.info^', '||gocdn.ru^',
  151. '||hdkinoshka.com^', '||hghit.com^', '||hindcine.net^',
  152. '||kiev.ua^', '||kinotochka.net^',
  153. '||kinott.com^', '||kinott.ru^', '||kuveres.com^',
  154. '||lepubs.com^', '||luxadv.com^', '||luxup.ru^',
  155. '||mail.ru^', '||marketgid.com^', '||mxtads.com^',
  156. '||oconner.biz^',
  157. '||pkpojhc.com^',
  158. '||psma01.com^', '||psma02.com^', '||psma03.com^',
  159. '||recreativ.ru^', '||regpole.com^', '||ruttwind.com^',
  160. '||skidl.ru^',
  161. '||torvind.com^', '||trafmag.com^',
  162. '||webadvert-gid.ru^', '||webadvertgid.ru^',
  163. '||xxuhter.ru^',
  164. '||yuiout.online^',
  165. '||zoom-film.ru^'
  166. ]) {
  167. masks.push(new RegExp(
  168. filter.replace(/([\\\/\[\].*+?(){}$])/g, '\\$1')
  169. .replace(/\^(?!$)/g,'\\.?[^\\w%._-]')
  170. .replace(/\^$/,'\\.?([^\\w%._-]|$)')
  171. .replace(/^\|\|/,'^wss?:\\/+([^\/.]+\\.)*'),
  172. 'i'));
  173. }
  174.  
  175. function isBlocked(url) {
  176. for (var mask of masks) {
  177. if (mask.test(url)) {
  178. return true;
  179. }
  180. }
  181. return false;
  182. }
  183.  
  184. var realWebSocket = win.WebSocket;
  185. function wsGetter (target, name) {
  186. try {
  187. if (typeof realWebSocket.prototype[name] === 'function') {
  188. if (name === 'close' || name === 'send') { // send also closes connection
  189. target.readyState = realWebSocket.CLOSED;
  190. }
  191. return (
  192. function fake() {
  193. console.log('[WSI] Invoked function "'+name+'"', '| Tracing', (new Error()));
  194. return;
  195. }
  196. );
  197. }
  198. if (typeof realWebSocket.prototype[name] === 'number') {
  199. return realWebSocket[name];
  200. }
  201. } catch(ignore) {}
  202. return target[name];
  203. }
  204.  
  205. function createWebSocketWrapper(target) {
  206. return new Proxy(realWebSocket, {
  207. construct: function (target, args) {
  208. var url = args[0];
  209. console.log('[WSI] Opening socket on ' + url + ' \u2026');
  210. if (isBlocked(url)) {
  211. console.log("[WSI] Blocked.");
  212. return new Proxy({
  213. url: url,
  214. readyState: realWebSocket.OPEN
  215. }, {
  216. get: wsGetter
  217. });
  218. }
  219. return new target(args[0], args[1]);
  220. }
  221. });
  222. }
  223.  
  224. function WorkerWrapper() {
  225. var realWorker = win.Worker;
  226. function wrappedWorker(resourceURI) {
  227. var isBlobURL = /^blob:/i,
  228. xhr = null,
  229. _callbacks = new WeakMap(),
  230. _worker = null,
  231. _terminate = false,
  232. _onerror = null,
  233. _onmessage = null,
  234. _messages = [],
  235. _events = [],
  236. _self = this;
  237.  
  238. function callbackWrapper(func) {
  239. if (typeof func !== 'function') {
  240. return undefined;
  241. }
  242. return (
  243. function callback() {
  244. func.apply(_self, arguments);
  245. }
  246. );
  247. }
  248.  
  249. _self.terminate = function(){
  250. _terminate = true;
  251. if (_worker) {
  252. _worker.terminate();
  253. }
  254. };
  255. Object.defineProperty(_self, 'onmessage', {
  256. get: function() {
  257. return _onmessage;
  258. },
  259. set: function(val) {
  260. _onmessage = val;
  261. if (_worker) {
  262. _worker.onmessage = callbackWrapper(val);
  263. }
  264. }
  265. });
  266. Object.defineProperty(_self, 'onerror', {
  267. get: function() {
  268. return _onerror;
  269. },
  270. set: function(val) {
  271. _onerror = val;
  272. if (_worker) {
  273. _worker.onerror = callbackWrapper(val);
  274. }
  275. }
  276. });
  277. _self.postMessage = function(message){
  278. if (_worker) {
  279. _worker.postMessage(message);
  280. } else {
  281. _messages.push(message);
  282. }
  283. };
  284. _self.terminate = function() {
  285. _terminate = true;
  286. if (_worker) {
  287. _worker.terminate();
  288. }
  289. };
  290. _self.addEventListener = function(){
  291. if (typeof arguments[1] !== 'function') {
  292. return;
  293. }
  294. if (!_callbacks.has(arguments[1])) {
  295. _callbacks.set(arguments[1], callbackWrapper(arguments[1]));
  296. }
  297. arguments[1] = _callbacks.get(arguments[1]);
  298. if (_worker) {
  299. _worker.addEventListener.apply(_worker, arguments);
  300. } else {
  301. _events.push(['addEventListener', arguments]);
  302. }
  303. };
  304. _self.removeEventListener = function(){
  305. if (typeof arguments[1] !== 'function' || !_callbacks.has(arguments[1])) {
  306. return;
  307. }
  308. arguments[1] = _callbacks.get(arguments[1]);
  309. _callbacks.delete(arguments[1]);
  310. if (_worker) {
  311. _worker.removeEventListener.apply(_worker, arguments);
  312. } else {
  313. _events.push(['removeEventListener', arguments]);
  314. }
  315. };
  316.  
  317. if (!isBlobURL.test(resourceURI)) {
  318. _worker = new realWorker(resourceURI);
  319. return; // not a blob, no need to wrap
  320. }
  321.  
  322. xhr = new XMLHttpRequest();
  323. xhr.responseType = 'blob';
  324. try {
  325. xhr.open('GET', resourceURI, true);
  326. } catch(ignore) {
  327. _worker = new realWorker(resourceURI);
  328. return; // failed to open connection, unable to continue wrapping procedure
  329. }
  330. (new Promise(function(resolve, reject){
  331. if (xhr.readyState !== XMLHttpRequest.OPENED) {
  332. // connection wasn't opened, unable to continue wrapping procedure
  333. return reject();
  334. }
  335. xhr.onload = function(){
  336. if (this.status === 200) {
  337. var reader = new FileReader();
  338. reader.addEventListener("loadend", function() {
  339. resolve(new realWorker(URL.createObjectURL(
  340. new Blob([getWrappedCode(false)+this.result])
  341. )));
  342. });
  343. reader.readAsText(this.response);
  344. }
  345. };
  346. xhr.send();
  347. })).then(function(val) {
  348. _worker = val;
  349. _worker.onerror = callbackWrapper(_onerror);
  350. _worker.onmessage = callbackWrapper(_onmessage);
  351. var _e;
  352. while(_events.length) {
  353. _e = _events.shift();
  354. _worker[_e[0]].apply(_worker, _e[1]);
  355. }
  356. while(_messages.length) {
  357. _worker.postMessage(_messages.shift());
  358. }
  359. if (_terminate) {
  360. _worker.terminate();
  361. }
  362. }).catch(function(){});
  363.  
  364. }
  365. win.Worker = wrappedWorker.bind(safeWin);
  366. }
  367.  
  368. function CreateElementWrapper() {
  369. var realCreateElement = document.createElement.bind(document),
  370. code = encodeURIComponent('<scr'+'ipt>'+getWrappedCode(true)+'</scr'+'ipt>\n'),
  371. isDataURL = /^data:/i,
  372. isBlobURL = /^blob:/i;
  373.  
  374. function frameRewrite(e) {
  375. var f = e.target,
  376. w = f.contentWindow;
  377. if (!f.src || (w && isBlobURL.test(f.src))) {
  378. w.WebSocket = createWebSocketWrapper();
  379. }
  380. if (isDataURL.test(f.src) && f.src.indexOf(code) < 0) {
  381. f.src = f.src.replace(',',',' + code);
  382. }
  383. }
  384.  
  385. function wrappedCreateElement(name) {
  386. var el = realCreateElement.apply(document, arguments);
  387. if (el.tagName === 'IFRAME') {
  388. el.addEventListener('load', frameRewrite, false);
  389. }
  390. return el;
  391. }
  392. document.createElement = wrappedCreateElement.bind(document);
  393.  
  394. document.addEventListener('DOMContentLoaded', function(){
  395. for (var ifr of document.querySelectorAll('IFRAME')) {
  396. ifr.addEventListener('load', frameRewrite, false);
  397. }
  398. }, false);
  399. }
  400.  
  401. this.init = function() {
  402. win.WebSocket = createWebSocketWrapper();
  403. WorkerWrapper();
  404. if (typeof document !== 'undefined') {
  405. CreateElementWrapper();
  406. }
  407. };
  408. }
  409.  
  410. if (isFirefox) {
  411. var script = document.createElement('script');
  412. script.appendChild(document.createTextNode(getWrappedCode()));
  413. document.head.insertBefore(script, document.head.firstChild);
  414. return; //we don't want to call functions on page from here in Fx, so exit
  415. }
  416.  
  417. (new WSI((unsafeWindow||self||window),(self||window))).init();
  418. })();
  419.  
  420. if (!isFirefox) { // scripts for non-Firefox browsers
  421.  
  422. // https://greasyfork.org/scripts/14720-it-s-not-important
  423. (function(){
  424. var imptt = /((display|(margin|padding)(-top|-bottom)?)\s*:[^;!]*)!\s*important/ig;
  425.  
  426. function unimportanter(el, si) {
  427. if (!imptt.test(si) || el.style.display === 'none') {
  428. return 0; // get out if we have nothing to do here
  429. }
  430. if (el.nodeName === 'IFRAME' && el.src &&
  431. el.src.slice(0,17) === 'chrome-extension:') {
  432. return 0; // Web of Trust uses this method to add their frame
  433. }
  434. var so = si.replace(imptt, function(){return arguments[1];}), ret = 0;
  435. if (si !== so) {
  436. ret = 1;
  437. el.setAttribute('style', so);
  438. }
  439. return ret;
  440. }
  441.  
  442. function logger(c) {
  443. if (c) {
  444. console.log('Some page elements became a bit less important.');
  445. }
  446. }
  447.  
  448. function checkTarget(node, cnt) {
  449. if (!(node && node.getAttribute)) {
  450. return 0;
  451. }
  452. var si = node.getAttribute('style');
  453. if (si && si.indexOf('!') > -1) {
  454. cnt += unimportanter(node, si);
  455. }
  456. return cnt;
  457. }
  458.  
  459. var observer = new MutationObserver(function(mutations) {
  460. setTimeout(function(ms) {
  461. var cnt = 0, m, node;
  462. for (m of ms) {
  463. cnt = checkTarget(m.target, cnt);
  464. for (node of m.addedNodes) {
  465. cnt += checkTarget(node, cnt);
  466. }
  467. }
  468. logger(cnt);
  469. }, 0, mutations);
  470. });
  471.  
  472. observer.observe(document, { childList : true, attributes : true, attributeFilter : ['style'], subtree : true });
  473.  
  474. win.addEventListener ("load", function(){
  475. var c = 0, imp;
  476. for (imp of document.querySelectorAll('[style*="!"]')) {
  477. c+= checkTarget(imp, c);
  478. }
  479. logger(c);
  480. }, false);
  481. })();
  482.  
  483. }
  484.  
  485. if (/^https?:\/\/(music\.yandex\.|news\.yandex\.|(www\.)?yandex\.[^\/]+\/(yand)?search[\/?])/i.test(win.location.href)) {
  486. // https://greasyfork.org/en/scripts/809-no-yandex-ads
  487. (function(){
  488. var adWords = ['Яндекс.Директ','Реклама','Ad'];
  489. function remove(node) {
  490. node.parentNode.removeChild(node);
  491. }
  492. // Generic ads removal and fixes
  493. function removeGenericAds() {
  494. var s, i;
  495. s = document.querySelector('.serp-header');
  496. if (s) {
  497. s.style.marginTop='0';
  498. }
  499. for (s of document.querySelectorAll('.serp-adv__head + .serp-item, #adbanner, .serp-adv, .b-spec-adv, div[class*="serp-adv__"]')) {
  500. remove(s);
  501. }
  502. }
  503. // Search ads
  504. function removeSearchAds() {
  505. var s, item;
  506. for (s of document.querySelectorAll('.serp-block, .serp-item, .search-item')) {
  507. item = s.querySelector('.label, .serp-item__label, .document__provider-name');
  508. if (item && adWords.indexOf(item.textContent) > -1) {
  509. remove(s);
  510. console.log('Ads removed.');
  511. }
  512. }
  513. }
  514. // News ads
  515. function removeNewsAds(selector) {
  516. for (var s of document.querySelectorAll(
  517. '.page-content__left > *,'+
  518. '.page-content__right > *:not(.page-content__col),'+
  519. '.page-content__right > .page-content__col > *'
  520. )) {
  521. if (s.textContent.indexOf(adWords[0]) > -1 ||
  522. (s.clientHeight < 15 && s.classList.contains('rubric'))) {
  523. remove(s);
  524. console.log('Ads removed.');
  525. }
  526. }
  527. }
  528. // Music ads
  529. function removeMusicAds() {
  530. for (var s of document.querySelectorAll('.ads-block')) {
  531. remove(s);
  532. }
  533. }
  534. // News fixes
  535. function removePageAdsClass() {
  536. if (document.body.classList.contains("b-page_ads_yes")){
  537. document.body.classList.remove("b-page_ads_yes");
  538. console.log('Page ads class removed.');
  539. }
  540. }
  541. // Function to attach an observer to monitor dynamic changes on the page
  542. function pageUpdateObserver(func, obj, params) {
  543. if (obj) {
  544. var o = new MutationObserver(func);
  545. o.observe(obj,(params || {childList:true, subtree:true}));
  546. }
  547. }
  548. // Cleaner
  549. document.addEventListener ('DOMContentLoaded', function() {
  550. removeGenericAds();
  551. if (win.location.hostname.search(/^music\./i) === 0) {
  552. pageUpdateObserver(removeMusicAds, document.querySelector('BODY'));
  553. removeMusicAds();
  554. } if (win.location.hostname.search(/^news\./i) === 0) {
  555. pageUpdateObserver(removeNewsAds, document.querySelector('BODY'));
  556. pageUpdateObserver(removePageAdsClass, document.body, {attributes:true, attributesFilter:['class']});
  557. removeNewsAds();
  558. removePageAdsClass();
  559. } else {
  560. pageUpdateObserver(removeSearchAds, document.querySelector('.main__content'));
  561. removeSearchAds();
  562. }
  563. });
  564. })();
  565. return; //skip fixes for other sites
  566. }
  567.  
  568. // https://greasyfork.org/en/scripts/14470-4pda-unbrender
  569. if (/(^|\.)4pda\.ru$/i.test(window.location.hostname)) {
  570. (function() {
  571. var isForum = document.location.href.search('/forum/') !== -1,
  572. hStyle;
  573.  
  574. function remove(n) {
  575. if (n) {
  576. n.parentNode.removeChild(n);
  577. }
  578. }
  579.  
  580. function afterClean() {
  581. hStyle.disabled = true;
  582. remove(hStyle);
  583. }
  584.  
  585. function beforeClean() {
  586. // attach styles before document displayed
  587. hStyle = createStyle([
  588. 'html { overflow-y: scroll }',
  589. 'article + aside * { display: none !important }',
  590. '#header + div:after {'+(
  591. 'content: "";'+
  592. 'position: fixed;'+
  593. 'top: 0;'+
  594. 'left: 0;'+
  595. 'width: 100%;'+
  596. 'height: 100%;'+
  597. 'background-color: #E6E7E9'
  598. )+'}',
  599. // http://codepen.io/Beaugust/pen/DByiE
  600. '@keyframes spin { 100% { transform: rotate(360deg) } }',
  601. 'article + aside:after {'+(
  602. 'content: "";'+
  603. 'position: absolute;'+
  604. 'width: 150px;'+
  605. 'height: 150px;'+
  606. 'top: 150px;'+
  607. 'left: 50%;'+
  608. 'margin-top: -75px;'+
  609. 'margin-left: -75px;'+
  610. 'box-sizing: border-box;'+
  611. 'border-radius: 100%;'+
  612. 'border: 10px solid rgba(0, 0, 0, 0.2);'+
  613. 'border-top-color: rgba(0, 0, 0, 0.6);'+
  614. 'animation: spin 2s infinite linear'
  615. )+'}'
  616. ], {id:'ubrHider'}, true);
  617.  
  618. // display content of a page if time to load a page is more than 2 seconds to avoid
  619. // blocking access to a page if it is loading for too long or stuck in a loading state
  620. setTimeout(2000, afterClean);
  621. }
  622.  
  623. createStyle([
  624. '#nav .use-ad { display: block !important }',
  625. 'article:not(.post) + article:not(#id), a[target="_blank"] img[height="90"] { display: none !important }'
  626. ]);
  627.  
  628. if (!isForum) {
  629. beforeClean();
  630. }
  631.  
  632. // save links to non-overridden functions to use later
  633. var oGA = Element.prototype.getAttribute,
  634. oSA = Element.prototype.setAttribute,
  635. protectedElems;
  636. // protect/hide changed attributes in case site attempt to restore them
  637. function styleProtector(eventMode) {
  638. var oRAN = Element.prototype.removeAttributeNode,
  639. isStyleText = function(t){ return t === 'style'; },
  640. isStyleAttr = function(a){ return a instanceof Attr && a.nodeName === 'style' },
  641. returnUndefined = function(){},
  642. protectedElems = new WeakMap();
  643. function protoOverride(element, functionName, isStyleCheck, returnIfProtected) {
  644. var oF = element.prototype[functionName];
  645. element.prototype[functionName] = function(){
  646. if (protectedElems.get(this) !== undefined && isStyleCheck(arguments[0])) {
  647. return returnIfProtected(protectedElems.get(this), arguments, this);
  648. }
  649. return oF.apply(this, arguments);
  650. }
  651. }
  652. protoOverride(Element, 'removeAttribute', isStyleText, returnUndefined);
  653. protoOverride(Element, 'removeAttributeNS', isStyleText, returnUndefined);
  654. protoOverride(Element, 'removeAttributeNode', isStyleAttr, function(o, args, node) {
  655. if (args[0] instanceof Attr && args[0].ownerElement !== node) {
  656. // throw 'attribute of another element' error
  657. oRAN.call(node, document.createAttribute('style'));
  658. }
  659. if (o.oldStyle === null) {
  660. // throw 'not an Attr' error
  661. oRAN.call(node, null);
  662. }
  663. o.oldStyle = null;
  664. return args[0];
  665. });
  666. protoOverride(Element, 'hasAttribute', isStyleText, function(o) {
  667. return o.oldStyle !== null;
  668. });
  669. protoOverride(Element, 'hasAttributeNS', isStyleText, function(o) {
  670. return o.oldStyle !== null;
  671. });
  672. protoOverride(Element, 'setAttribute', isStyleText, function(o, args) {
  673. o.oldStyle = args[1];
  674. });
  675. protoOverride(Element, 'setAttributeNS', isStyleText, returnUndefined);
  676. protoOverride(Element, 'setAttributeNode', isStyleAttr, returnUndefined);
  677. protoOverride(Element, 'getAttribute', isStyleText, function(o) {
  678. return o.oldStyle;
  679. });
  680. protoOverride(Element, 'getAttributeNS', isStyleText, returnUndefined);
  681. protoOverride(Element, 'getAttributeNode', isStyleText, function(o){
  682. if (o.oldStyle === null) {
  683. return null;
  684. }
  685. var at = document.createAttribute('style');
  686. at.value = o.oldStyle;
  687. Object.defineProperty(at, 'ownerElement', {
  688. value: this,
  689. enumerable: true
  690. });
  691. return at;
  692. });
  693. if (eventMode) {
  694. var e = document.createEvent('Event');
  695. e.initEvent('protoOverride', false, false);
  696. window.protectedElems = protectedElems;
  697. window.dispatchEvent(e);
  698. } else {
  699. return protectedElems;
  700. }
  701. }
  702. if (isFirefox) {
  703. var s = document.createElement('script');
  704. s.textContent = '(' + styleProtector.toString() + ')(true);' +
  705. 'var s = document.currentScript; if (s) {s.parentNode.removeChild(s);}'
  706. window.addEventListener('protoOverride', function protoOverrideCallback(e){
  707. if (win.protectedElems) {
  708. protectedElems = win.protectedElems;
  709. delete win.protectedElems;
  710. }
  711. document.removeEventListener('protoOverride', protoOverrideCallback, true);
  712. }, true);
  713. document.documentElement.appendChild(s);
  714. } else {
  715. protectedElems = styleProtector(false);
  716. }
  717.  
  718. // clean a page
  719. window.addEventListener('DOMContentLoaded', function(){
  720. var rem, si, itm;
  721. function width(){ return window.innerWidth||document.documentElement.clientWidth||document.body.clientWidth||0; }
  722. function height(){ return window.innerHeight||document.documentElement.clientHeight||document.body.clientHeight||0; }
  723.  
  724.  
  725. if (isForum) {
  726. si = document.querySelector('#logostrip');
  727. if (si) {
  728. remove(si.parentNode.nextSibling);
  729. }
  730. }
  731.  
  732. if (document.location.href.search('/forum/dl/') !== -1) {
  733. document.body.setAttribute('style', (document.body.getAttribute('style')||'')+
  734. ';background-color:black!important');
  735. for (itm of document.querySelectorAll('body>div')) {
  736. if (!itm.querySelector('.dw-fdwlink')) {
  737. remove(itm);
  738. }
  739. }
  740. }
  741.  
  742. if (isForum) { // Do not continue if it's a forum
  743. return;
  744. }
  745.  
  746. si = document.querySelector('#header');
  747. if (si) {
  748. rem = si.previousSibling;
  749. while (rem) {
  750. si = rem.previousSibling;
  751. remove(rem);
  752. rem = si;
  753. }
  754. }
  755.  
  756. for (itm of document.querySelectorAll('#nav li[class]')) {
  757. if (itm && itm.querySelector('a[href^="/tag/"]')) {
  758. remove(itm);
  759. }
  760. }
  761.  
  762. var style, result;
  763. for (itm of document.querySelectorAll('DIV')) {
  764. if (itm.offsetWidth > 0.95 * width() && itm.offsetHeight > 0.8 * height()) {
  765. style = window.getComputedStyle(itm, null);
  766. result = [];
  767. if (style.backgroundImage !== 'none') {
  768. result.push('background-image:none!important');
  769. }
  770. if (style.backgroundColor !== 'transparent' &&
  771. style.backgroundColor !== 'rgba(0, 0, 0, 0)') {
  772. result.push('background-color:transparent!important');
  773. }
  774. if (result.length) {
  775. if (itm.getAttribute('style')) {
  776. result.unshift(itm.getAttribute('style'));
  777. }
  778. (function(){
  779. var fakeStyle = {
  780. 'backgroundImage': itm.style.backgroundImage,
  781. 'backgroundColor': itm.style.backgroundColor
  782. };
  783. try {
  784. Object.defineProperty(itm, 'style', {
  785. value: new Proxy(itm.style, {
  786. get: function(target, prop){
  787. if (fakeStyle.hasOwnProperty(prop)) {
  788. return fakeStyle[prop];
  789. } else {
  790. return target[prop];
  791. }
  792. },
  793. set: function(target, prop, value){
  794. if (fakeStyle.hasOwnProperty(prop)) {
  795. fakeStyle[prop] = value;
  796. } else {
  797. target[prop] = value;
  798. }
  799. return value;
  800. }
  801. }),
  802. enumerable: true
  803. });
  804. } catch (e) {
  805. console.log('Unable to protect style property.', e)
  806. }
  807. })();
  808. if (protectedElems) {
  809. protectedElems.set(itm, {oldStyle: oGA.call(itm, 'style')});
  810. }
  811. oSA.call(itm, 'style', result.join(';'));
  812. }
  813. }
  814. }
  815.  
  816. for (itm of document.querySelectorAll('ASIDE>DIV')) {
  817. if ( ((itm.querySelector('script, iframe, a[href*="/ad/www/"]') ||
  818. itm.querySelector('img[src$=".gif"]:not([height="0"]), img[height="400"]')) &&
  819. !itm.classList.contains('post') ) || !itm.childNodes.length ) {
  820. remove(itm);
  821. }
  822. }
  823.  
  824. document.body.setAttribute('style', (document.body.getAttribute('style')||'')+';background-color:#E6E7E9!important');
  825.  
  826. // display content of the page
  827. afterClean();
  828. });
  829. })();
  830. return;
  831. }
  832.  
  833. // https://greasyfork.org/en/scripts/21937-moonwalk-hdgo-kodik-fix v0.7+ (adapted & fixed)
  834. document.addEventListener ('DOMContentLoaded', function() {
  835. var tmp, t;1
  836. function log (e) {
  837. console.log('Moonwalk&HDGo&Kodik FIX: ' + e + ' player in ' + win.location.href);
  838. }
  839. if (win.adv_enabled !== undefined && win.condition_detected !== undefined) { // moonwalk
  840. log('Moonwalk');
  841. if (win.adv_enabled) {
  842. win.adv_enabled = false;
  843. }
  844. win.condition_detected = false;
  845. if (win.MXoverrollCallback) {
  846. document.addEventListener('click', function catcher(e){
  847. e.stopPropagation();
  848. win.MXoverrollCallback.call(window);
  849. document.removeEventListener('click', catcher, true);
  850. }, true);
  851. }
  852. } else if (win.banner_second !== undefined && win.$banner_ads !== undefined) { // hdgo
  853. log('HDGo');
  854. tmp = document.querySelector('#swtf');
  855. if (tmp) {
  856. tmp.style.display = 'none';
  857. }
  858. win.banner_second = 0;
  859. win.$banner_ads = false;
  860. if (win.$new_ads !== undefined) {
  861. win.$new_ads = false;
  862. }
  863. if (win.canRunAds !== undefined && win.canRunAds !== true) {
  864. win.canRunAds = true;
  865. }
  866. } else if (win.MXoverrollCallback && win.iframeSearch !== undefined) { // kodik
  867. log('Kodik');
  868. tmp = document.querySelector('.play_button');
  869. if (tmp) {
  870. tmp.onclick = win.MXoverrollCallback.bind(window);
  871. }
  872. win.IsAdBlock = false;
  873. }
  874. }, false);
  875.  
  876. // function to search and remove nodes by content
  877. // selector - standard CSS selector to define set of nodes to check
  878. // words - regular expression to check content of the suspicious nodes
  879. // params - object with multiple extra parameters:
  880. // .hide - set display to none instead of removing from the page
  881. // .parent - parent node to remove if content is found in the child node
  882. // .siblings - number of simling nodes to remove (excluding text nodes)
  883. function scRemove(e) {e.parentNode.removeChild(e);}
  884. function scHide(e) {
  885. var s = e.getAttribute('style')||'',
  886. h = ';display:none!important;';
  887. if (s.indexOf(h) < 0) {
  888. e.setAttribute('style', s+h);
  889. }
  890. }
  891. function scissors (selector, words, scope, params) {
  892. var remFunc = (params.hide ? scHide : scRemove),
  893. iterFunc = (params.siblings > 0 ?
  894. 'nextSibling' :
  895. 'previousSibling'),
  896. toRemove = [],
  897. siblings,
  898. node;
  899. for (node of scope.querySelectorAll(selector)) {
  900. if (words.test(node.innerHTML) || !node.childNodes.length) {
  901. // drill up to the specified parent node if required
  902. if (params.parent) {
  903. while(node !== scope && !(node.matches(params.parent))) {
  904. node = node.parentNode;
  905. }
  906. }
  907. if (node === scope) {
  908. break;
  909. }
  910. toRemove.push(node);
  911. // add multiple nodes if defined more than one sibling
  912. siblings = Math.abs(params.siblings) || 0;
  913. while (siblings) {
  914. node = node[iterFunc];
  915. toRemove.push(node);
  916. if (node.nodeType === Node.ELEMENT_NODE) {
  917. siblings -= 1; //count only element nodes
  918. }
  919. }
  920. }
  921. }
  922. for (node of toRemove) {
  923. remFunc(node);
  924. }
  925. return toRemove.length;
  926. }
  927.  
  928. // function to perform multiple checks if ads inserted with a delay
  929. // by default does 30 checks withing a 3 seconds unless nonstop mode specified
  930. // also does 1 extra check when a page completely loads
  931. // selector and words - passed dow to scissors
  932. // params - object with multiple extra parameters:
  933. // .root - selector to narrow down scope to scan;
  934. // .observe - if true then check will be performed continuously;
  935. // Other parameters passed down to scissors.
  936. function gardener(selector, words, params) {
  937. params = params || {};
  938. var scope = document.body,
  939. nonstop = false;
  940. // narrow down scope to a specific element
  941. if (params.root) {
  942. scope = scope.querySelector(params.root);
  943. if (!scope) {// exit if the root element is not present on the page
  944. return 0;
  945. }
  946. }
  947. // add observe mode if required
  948. if (params.observe) {
  949. if (typeof MutationObserver === 'function') {
  950. var o = new MutationObserver(function(ms){
  951. for (var m of ms) {
  952. if (m.addedNodes.length) {
  953. scissors(selector, words, scope, params);
  954. }
  955. }
  956. });
  957. o.observe(scope, {childList:true, subtree: true});
  958. } else {
  959. nonstop = true;
  960. }
  961. }
  962. // wait for a full page load to do one extra cut
  963. win.addEventListener('load',function(){
  964. scissors(selector, words, scope, params);
  965. });
  966. // do multiple cuts until ads removed
  967. function cut(sci, s, w, sc, p, i) {
  968. if (i > 0) {
  969. i -= 1;
  970. }
  971. if (i && !sci(s, w, sc, p)) {
  972. setTimeout(cut, 100, sci, s, w, sc, p, i);
  973. }
  974. }
  975. cut(scissors, selector, words, scope, params, (nonstop ? -1 : 30));
  976. }
  977.  
  978. function preventBackgroundRedirect() {
  979. // create "cose_me" event to call high-level window.close()
  980. var key = Math.random().toString(36).substr(2);
  981. window.addEventListener('close_me_'+key, function(e) {
  982. window.close();
  983. });
  984.  
  985. // window.open wrapper
  986. function pbrLander() {
  987. var orgOpen = window.open.bind(window);
  988. function closeWindow(){
  989. // site went to a new tab and attempts to unload
  990. // call for high-level close through event
  991. var event = new CustomEvent("close_me_%key%", {});
  992. window.dispatchEvent(event);
  993. }
  994. function open(){
  995. var idx = String.prototype.indexOf;
  996. if (arguments[0] &&
  997. (idx.call(arguments[0], window.location.host) > -1 ||
  998. idx.call(arguments[0], '://') === -1)) {
  999. window.addEventListener('unload', closeWindow, true);
  1000. }
  1001. orgOpen.apply(window, arguments);
  1002. }
  1003. window.open = open.bind(window);
  1004. var s = document.currentScript;
  1005. if (s) {s.parentNode.removeChild(s);}
  1006. }
  1007.  
  1008. // land wrapper on the page
  1009. var script = document.createElement('script');
  1010. script.appendChild(document.createTextNode('('+pbrLander.toString().replace(/%key%/g,key)+')();'));
  1011. document.head.insertBefore(script,document.head.firstChild);
  1012. console.log("Background redirect prevention enabled.");
  1013. }
  1014.  
  1015. function forbidServiceWorker() {
  1016. if (!("serviceWorker" in navigator)) {
  1017. return;
  1018. }
  1019. var svr = navigator.serviceWorker.ready;
  1020. Object.defineProperty(navigator, 'serviceWorker', {
  1021. value: {
  1022. register: function(){
  1023. console.log('Registration of serviceWorker ' + arguments[0] + ' blocked.');
  1024. return new Promise(function(){});
  1025. },
  1026. ready: new Promise(function(){}),
  1027. addEventListener:function(){}
  1028. }
  1029. });
  1030. document.addEventListener('DOMContentLoaded', function() {
  1031. if (!svr) {
  1032. return;
  1033. }
  1034. svr.then(function(sw) {
  1035. console.log('Found existing serviceWorker:', sw);
  1036. console.log('Attempting to unregister...');
  1037. sw.unregister().then(function() {
  1038. console.log('Unregistered! :)');
  1039. }).catch(function(err) {
  1040. console.log('Unregistration failed. :(', err);
  1041. console.log('Try to remove it manually:');
  1042. console.log(' 1. Open: chrome://serviceworker-internals/ (Google Chrome and alike) or about:serviceworkers (Mozilla Firefox) in a new tab.');
  1043. console.log(' 2. Search there for one with "'+document.domain+'" in the name.');
  1044. console.log(' 3. Use buttons in the same block with service you found to stop it and uninstall/unregister.');
  1045. });
  1046. }).catch(function(err) {
  1047. console.log("Lol, it failed on it's own. -_-", err);
  1048. });
  1049. }, false);
  1050. }
  1051.  
  1052. var scripts = {};
  1053. scripts['fs.to'] = function() {
  1054. function skipClicker(i) {
  1055. if (!i) {
  1056. return;
  1057. }
  1058. var skip = document.querySelector('.b-aplayer-banners__close');
  1059. if (skip) {
  1060. skip.click();
  1061. } else {
  1062. setTimeout(skipClicker, 100, i-1);
  1063. }
  1064. }
  1065. setTimeout(skipClicker, 100, 30);
  1066.  
  1067. createStyle([
  1068. '.l-body-branding *,'+
  1069. '.b-styled__item-central,'+
  1070. '.b-styled__content-right,'+
  1071. '.b-styled__section-central,'+
  1072. 'div[id^="adsProxy-"]'+
  1073. '{display:none!important}',
  1074. 'body {background-image:url(data:image/png;base64,'+
  1075. 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAACX'+
  1076. 'BIWXMAAC4jAAAuIwF4pT92AAAADUlEQVR42mOQUdL5DwACMgFq'+
  1077. 'BC3ttwAAAABJRU5ErkJggg==)!important}'
  1078. ]);
  1079.  
  1080. if (/\/(view_iframe|iframeplayer)\//i.test(document.location.pathname)) {
  1081. var p = document.querySelector('#player:not([preload="auto"])'),
  1082. m = document.querySelector('.main'),
  1083. adStepper = function(p) {
  1084. if (p.currentTime < p.duration) {
  1085. p.currentTime += 1;
  1086. }
  1087. },
  1088. adSkipper = function(f, p) {
  1089. f.click();
  1090. p.waitAfterSkip = false;
  1091. p.longerSkipper = false;
  1092. console.log('Пропустили.');
  1093. },
  1094. cl = function(p) {
  1095. var faster = document.querySelector('.b-aplayer__html5-desktop-skip'),
  1096. series = document.querySelector('.b-aplayer__actions-series');
  1097.  
  1098. function clickSelected() {
  1099. var s = document.querySelector('.b-aplayer__popup-series-episodes .selected a');
  1100. if (s) {
  1101. s.click();
  1102. }
  1103. }
  1104.  
  1105. if ((!faster || faster.style.display !== 'block') && series && !p.seriesClicked) {
  1106. series.click();
  1107. p.seriesClicked = true;
  1108. p.longerSkipper = true;
  1109. setTimeout(clickSelected, 1000);
  1110. p.pause();
  1111. }
  1112.  
  1113. function skipListener() {
  1114. if (p.waitAfterSkip) {
  1115. console.log('В процессе пропуска…');
  1116. return;
  1117. }
  1118. p.pause();
  1119. if (!p.classList.contains('m-hidden')) {
  1120. p.classList.add('m-hidden');
  1121. }
  1122. if (faster && p.currentTime &&
  1123. win.getComputedStyle(faster).display === 'block' &&
  1124. !faster.querySelector('.b-aplayer__html5-desktop-skip-timer')) {
  1125. p.waitAfterSkip = true;
  1126. setTimeout(adSkipper, (p.longerSkipper?3:1)*1000, faster, p);
  1127. console.log('Доступен быстрый пропуск…');
  1128. } else {
  1129. setTimeout(adStepper, 1000, p);
  1130. }
  1131. }
  1132.  
  1133. p.addEventListener('timeupdate', skipListener, false);
  1134. },
  1135. o = new MutationObserver(function (ms) {
  1136. var m, node;
  1137. for (m of ms) {
  1138. for (node of m.addedNodes) {
  1139. if (node.id === 'player' &&
  1140. node.nodeName === 'VIDEO' &&
  1141. node.getAttribute('preload') !== 'auto') {
  1142. cl(node);
  1143. }
  1144. }
  1145. }
  1146. });
  1147. if (p.nodeName === 'VIDEO') {
  1148. cl(p);
  1149. } else {
  1150. o.observe(m, {childList: true});
  1151. }
  1152. }
  1153. };
  1154. scripts['brb.to'] = scripts['fs.to'];
  1155. scripts['cxz.to'] = scripts['fs.to'];
  1156.  
  1157. scripts['drive2.ru'] = function() {
  1158. gardener('.c-block:not(.js-recommendations),.o-grid__item', />Реклама<\//i);
  1159. };
  1160.  
  1161. scripts['fishki.net'] = function() {
  1162. gardener('.main-post', /543769|Реклама/);
  1163. };
  1164.  
  1165. scripts['hdgo.cc'] = {
  1166. 'now': function(){
  1167. var o = new MutationObserver(function(ms) {
  1168. var m, node;
  1169. for (m of ms) {
  1170. for (node of m.addedNodes) {
  1171. if (node.tagName === 'SCRIPT' && node.getAttribute('onerror') !== null) {
  1172. node.removeAttribute('onerror');
  1173. }
  1174. }
  1175. }
  1176. });
  1177. o.observe(document, {childList:true, subtree: true});
  1178. }
  1179. };
  1180. scripts['couber.be'] = scripts['hdgo.cc'];
  1181. scripts['46.30.43.38'] = scripts['hdgo.cc'];
  1182.  
  1183. scripts['hdrezka.me'] = {
  1184. 'now': function() {
  1185. Object.defineProperty(win, 'fuckAdBlock', {
  1186. value: {
  1187. onDetected: function() {
  1188. console.log('Pretending to be an ABP detector.');
  1189. }
  1190. }
  1191. });
  1192. Object.defineProperty(win, 'ab', {
  1193. value: false,
  1194. enumerable: true
  1195. });
  1196. },
  1197. 'DOMContentLoaded': function() {
  1198. gardener('div[id][onclick][onmouseup][onmousedown]', /onmouseout/i);
  1199. }
  1200. };
  1201.  
  1202. scripts['megogo.net'] = {
  1203. 'now': function() {
  1204. Object.defineProperty(win, "adBlock", {
  1205. value : false,
  1206. enumerable : true
  1207. });
  1208. Object.defineProperty(win, "showAdBlockMessage", {
  1209. value : function () {},
  1210. enumerable : true
  1211. });
  1212. }
  1213. };
  1214.  
  1215. scripts['naruto-base.su'] = function() {
  1216. gardener('div[id^="entryID"],.block', /href="http.*?target="_blank"/i);
  1217. };
  1218.  
  1219. scripts['overclockers.ru'] = {
  1220. 'now': function() {
  1221. // Following code inspired by:
  1222. // https://greasyfork.org/en/scripts/23922-anti-adblock-killer-for-overclockers-ru
  1223. function antiAntiABP() {
  1224. var o = new MutationObserver(function(ms) {
  1225. var m, node;
  1226. for (m of ms) {
  1227. for (node of m.addedNodes) {
  1228. if (node.nodeType === Node.ELEMENT_NODE && node.onerror) {
  1229. node.onerror = null;
  1230. console.log("Disabled 'onerror' on", node);
  1231. }
  1232. }
  1233. }
  1234. });
  1235. o.observe(document, {childList: true, subtree: true});
  1236. var s = document.currentScript;
  1237. s.parentNode.removeChild(s);
  1238. }
  1239. var s = document.createElement('script');
  1240. s.textContent = '(' + antiAntiABP.toString() + ')();';
  1241. document.documentElement.appendChild(s);
  1242. }
  1243. };
  1244. scripts['forums.overclockers.ru'] = {
  1245. 'now': function() {
  1246. createStyle(['.needblock {position: fixed; left: -10000px}']);
  1247. Object.defineProperty(win, 'adblck', {
  1248. value: 'no',
  1249. enumerable: true
  1250. });
  1251. }
  1252. };
  1253.  
  1254. scripts['pb.wtf'] = function() {
  1255. createStyle(['.reques,#result,tbody.row1:not([id]) {display: none !important}']);
  1256. // image in the slider in the header
  1257. gardener('a[href$="=="]', /img/i, {root:'.release-navbar', observe:true, parent:'div'});
  1258. // ads in blocks on the page
  1259. gardener('a[href^="/"]', /<img\s.*<br>/i, {root:'#main_content', observe:true, parent:'div[class]'});
  1260. // line above topic content
  1261. gardener('.re_top1', /./, {root:'#main_content', parent:'.hidden-sm'});
  1262. };
  1263. scripts['piratbit.org'] = scripts['pb.wtf'];
  1264. scripts['piratbit.ru'] = scripts['pb.wtf'];
  1265.  
  1266. scripts['pikabu.ru'] = function() {
  1267. gardener('.story', /story__sponsor|story__gag|profile\/ads"/i, {root: '.inner_wrap', observe: true});
  1268. };
  1269.  
  1270. scripts['rp5.ru'] = function() {
  1271. var co = document.querySelector('#content'), i, nodes;
  1272. if (!co) {
  1273. return;
  1274. }
  1275. nodes = co.parentNode.childNodes;
  1276. i = nodes.length;
  1277. while (i--) {
  1278. if (nodes[i] !== co) {
  1279. nodes[i].parentNode.removeChild(nodes[i]);
  1280. }
  1281. }
  1282. };
  1283.  
  1284. scripts['rustorka.com'] = {
  1285. 'now':function(){
  1286. win.open = function(){
  1287. console.log('Site attempted to open a new window', arguments);
  1288. }
  1289. },
  1290. 'DOMContentLoaded':function() {
  1291. gardener('span[class],ul[class],span[id],ul[id]', /\/\d{12,}\.php/i, {root:'#sidebar1', observe:true});
  1292. gardener('div[id][style*="!important"]', /!important/i);
  1293. }
  1294. };
  1295. scripts['rumedia.ws'] = scripts['rustorka.com'];
  1296.  
  1297. scripts['sport-express.ru'] = function() {
  1298. gardener('.js-relap__item',/>Реклама\s+<\//, {root:'.container', observe: true});
  1299. };
  1300.  
  1301. scripts['sports.ru'] = function() {
  1302. gardener('.aside-news-list__item', /aside-news-list__advert/i, {root:'.aside-news-block'});
  1303. };
  1304.  
  1305. scripts['turbobit.net'] = {'now': preventBackgroundRedirect};
  1306.  
  1307. scripts['yap.ru'] = function() {
  1308. var words = /member1438|Administration/;
  1309. gardener('form > table[id^="p_row_"]', words);
  1310. gardener('tr > .holder.newsbottom', words, {parent:'tr', siblings:-2});
  1311. };
  1312. scripts['yaplakal.com'] = scripts['yap.ru'];
  1313.  
  1314. scripts['reactor.cc'] = {
  1315. 'now': function() {
  1316. win.open = (function(){ throw new Error('Redirect prevention.'); }).bind(window);
  1317. },
  1318. 'click': function(e) {
  1319. var node = e.target;
  1320. if (node.nodeType === Node.ELEMENT_NODE &&
  1321. node.style.position === 'absolute' &&
  1322. node.style.zIndex > 0)
  1323. node.parentNode.removeChild(node);
  1324. },
  1325. 'DOMContentLoaded': function() {
  1326. var words = new RegExp(
  1327. 'блокировщика рекламы'
  1328. .split('')
  1329. .map(function(e){return e+'[\u200b\u200c\u200d]*';})
  1330. .join('')
  1331. .replace(' ', '\\s*')
  1332. .replace(/[аоре]/g, function(e){return ['[аa]','[оo]','[рp]','[еe]']['аоре'.indexOf(e)];}),
  1333. 'i'),
  1334. can;
  1335. function deeper(spider) {
  1336. var c, l, n;
  1337. if (words.test(spider.innerText)) {
  1338. if (spider.nodeType === Node.TEXT_NODE) {
  1339. return true;
  1340. }
  1341. c = spider.childNodes;
  1342. l = c.length;
  1343. n = 0;
  1344. while(l--) {
  1345. if (deeper(c[l]), can) {
  1346. n++;
  1347. }
  1348. }
  1349. if (n > 0 && n === c.length && spider.offsetHeight < 750) {
  1350. can.push(spider);
  1351. }
  1352. return false;
  1353. }
  1354. return true;
  1355. }
  1356. function probe(){
  1357. if (words.test(document.body.innerText)) {
  1358. can = [];
  1359. deeper(document.body);
  1360. var i = can.length, j, spider;
  1361. while(i--) {
  1362. spider = can[i];
  1363. if (spider.offsetHeight > 10 && spider.offsetHeight < 750) {
  1364. spider.setAttribute('style', 'background:none!important');
  1365. }
  1366. }
  1367. }
  1368. }
  1369. var o = new MutationObserver(probe);
  1370. o.observe(document,{childList:true, subtree:true});
  1371. }
  1372. };
  1373. scripts['joyreactor.cc'] = scripts['reactor.cc'];
  1374. scripts['pornreactor.cc'] = scripts['reactor.cc'];
  1375.  
  1376. scripts['auto.ru'] = function() {
  1377. var words = /Реклама|Яндекс.Директ|yandex_ad_/;
  1378. var userAdsListAds = [
  1379. '.listing-list > .listing-item',
  1380. '.listing-item_type_fixed.listing-item'
  1381. ];
  1382. var catalogAds = [
  1383. 'div[class*="layout_catalog-inline"]',
  1384. 'div[class$="layout_horizontal"]'
  1385. ];
  1386. var otherAds = [
  1387. '.advt_auto',
  1388. '.sidebar-block',
  1389. '.pager-listing + div[class]',
  1390. '.card > div[class][style]',
  1391. '.sidebar > div[class]',
  1392. '.main-page__section + div[class]',
  1393. '.listing > tbody'];
  1394. gardener(userAdsListAds.join(','), words, {root:'.listing-wrap', observe:true});
  1395. gardener(catalogAds.join(','), words, {root:'.catalog__page,.content__wrapper', observe:true});
  1396. gardener(otherAds.join(','), words);
  1397. };
  1398.  
  1399. scripts['online.anidub.com'] = function() {
  1400. var script = document.createElement('script');
  1401. script.type = "text/javascript";
  1402. script.innerHTML = "function ogonekstart1() {}";
  1403. document.getElementsByTagName('head')[0].appendChild(script);
  1404.  
  1405. var style = document.createElement('style');
  1406. style.type = 'text/css';
  1407. style.appendChild(document.createTextNode('.background {background: none!important;}'));
  1408. style.appendChild(document.createTextNode('.background > script + div, .background > script ~ div:not([id]):not([class]) + div[id][class] {display:none!important}'));
  1409. document.head.appendChild(style);
  1410. };
  1411.  
  1412. scripts['rsload.net'] = {
  1413. 'load': function() {
  1414. var dis = document.querySelector('.cb-disable');
  1415. if (dis) {
  1416. dis.click();
  1417. }
  1418. },
  1419. 'click': function(e) {
  1420. var t = e.target;
  1421. if (t && t.href && (/:\/\/\d+\.\d+\.\d+\.\d+\//.test(t.href))) {
  1422. t.href = t.href.replace('://','://rsload.net:rsload.net@');
  1423. }
  1424. }
  1425. };
  1426.  
  1427. scripts['imageban.ru'] = {
  1428. 'now': preventBackgroundRedirect,
  1429. 'DOMContentLoaded': function() {
  1430. win.addEventListener('unload', function() {
  1431. if (!window.location.hash) {
  1432. window.location.replace(window.location+'#');
  1433. } else {
  1434. window.location.hash = '';
  1435. }
  1436. }, true);
  1437. }
  1438. };
  1439.  
  1440. var domain = document.domain, name;
  1441. while (domain.indexOf('.') !== -1) {
  1442. if (scripts.hasOwnProperty(domain)) {
  1443. if (typeof scripts[domain] === 'function') {
  1444. document.addEventListener ('DOMContentLoaded', scripts[domain], false);
  1445. }
  1446. for (name in scripts[domain]) {
  1447. if (name !== 'now') {
  1448. (name === 'load' ? window : document)
  1449. .addEventListener (name, scripts[domain][name], false);
  1450. } else {
  1451. scripts[domain][name]();
  1452. }
  1453. }
  1454. }
  1455. domain = domain.slice(domain.indexOf('.') + 1);
  1456. }
  1457. })();