RU AdList JS Fixes

try to take over the world!

当前为 2017-05-12 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name RU AdList JS Fixes
  3. // @namespace ruadlist_js_fixes
  4. // @version 20170512.4
  5. // @description try to take over the world!
  6. // @author lainverse & dimisa
  7. // @match *://*/*
  8. // @grant unsafeWindow
  9. // @grant window.close
  10. // @grant GM_getValue
  11. // @grant GM_setValue
  12. // @run-at document-start
  13. // ==/UserScript==
  14.  
  15. (function() {
  16. 'use strict';
  17. var win = (unsafeWindow || window),
  18. // http://stackoverflow.com/questions/9847580/how-to-detect-safari-chrome-ie-firefox-and-opera-browser
  19. isOpera = (!!window.opr && !!opr.addons) || !!window.opera || navigator.userAgent.indexOf(' OPR/') >= 0,
  20. isChrome = !!window.chrome && !!window.chrome.webstore,
  21. isSafari = (Object.prototype.toString.call(window.HTMLElement).indexOf('Constructor') > 0 ||
  22. (function (p) { return p.toString() === "[object SafariRemoteNotification]"; })(!window.safari || safari.pushNotification)),
  23. isFirefox = typeof InstallTrigger !== 'undefined',
  24. _getAttribute = Element.prototype.getAttribute,
  25. _setAttribute = Element.prototype.setAttribute,
  26. _de = document.documentElement,
  27. _appendChild = Document.prototype.appendChild.bind(_de),
  28. _removeChild = Document.prototype.removeChild.bind(_de);
  29.  
  30. // NodeList iterator polyfill (mostly for Safari)
  31. // https://jakearchibald.com/2014/iterators-gonna-iterate/
  32. if (!NodeList.prototype[Symbol.iterator]) {
  33. NodeList.prototype[Symbol.iterator] = Array.prototype[Symbol.iterator];
  34. }
  35.  
  36. // Options
  37. var opts = {
  38. 'useWSIFunc': useWSI
  39. };
  40. (function(){
  41. function optsCall(callback) {
  42. // Register event listener
  43. var key = "optsCallEvent_" + Math.random().toString(36).substr(2),
  44. cb = callback.func.bind(callback.name);
  45. window.addEventListener(key, cb, false);
  46. // Generate and dispatch synthetic event
  47. var ev = document.createEvent("HTMLEvents");
  48. ev.initEvent(key, true, false);
  49. window.dispatchEvent(ev);
  50. // Remove listener
  51. window.removeEventListener(key, cb, false);
  52. }
  53. function initOptsHandler() {
  54. /*jshint validthis:true */
  55. opts[this] = GM_getValue(this, true);
  56. if(opts[this]) {
  57. opts[this+'Func']();
  58. }
  59. }
  60. optsCall({
  61. func: initOptsHandler,
  62. name: 'useWSI'
  63. });
  64. // show options page
  65. function openOptions() {
  66. var ovl = document.createElement('div'),
  67. inner = document.createElement('div');
  68. ovl.style = (
  69. 'position: fixed;'+
  70. 'top:0; left:0;'+
  71. 'bottom: 0; right: 0;'+
  72. 'background: rgba(0,0,0,0.85);'+
  73. 'z-index: 2147483647;'+
  74. 'padding: 5em'
  75. );
  76. inner.style = (
  77. 'background: whitesmoke;'+
  78. 'font-size: 10pt;'+
  79. 'color: black;'+
  80. 'padding: 1em'
  81. );
  82. inner.textContent = 'JS Fixes Options: (reload page to apply)';
  83. inner.appendChild(document.createElement('br'));
  84. inner.appendChild(document.createElement('br'));
  85. ovl.addEventListener('click', function(e){
  86. if (e.target === ovl) {
  87. ovl.parentNode.removeChild(ovl);
  88. e.preventDefault();
  89. }
  90. e.stopPropagation();
  91. }, false);
  92. // append checkbox with label function
  93. function addCheckbox(optName, optLabel) {
  94. var c = document.createElement('input'),
  95. l = document.createElement('label');
  96. c.type = 'checkbox';
  97. c.id = optName;
  98. optsCall({
  99. func:function(){
  100. c.checked = GM_getValue(this);
  101. },
  102. name:optName
  103. });
  104. c.addEventListener('click', function(e) {
  105. optsCall({
  106. func:function(){
  107. GM_setValue(this, e.target.checked);
  108. opts[this] = e.target.checked;
  109. },
  110. name:optName
  111. });
  112. }, true);
  113. l.textContent = optLabel;
  114. l.setAttribute('for', optName);
  115. inner.appendChild(c);
  116. inner.appendChild(l);
  117. inner.appendChild(document.createElement('br'));
  118. }
  119. // append checkboxes
  120. addCheckbox('useWSI', 'Use WebSocket filter. Disable if experience problems with WebSocket connections.');
  121. document.body.appendChild(ovl);
  122. ovl.appendChild(inner);
  123. }
  124. // monitor keys pressed for Ctrl+Alt+Shift+J > s > f code
  125. var opPos = 0, opKey = 'Jsf', isNotKey;
  126. document.addEventListener('keydown', function(e) {
  127. isNotKey = (e.key.length > 1);
  128. if ((e.key === opKey[opPos] || isNotKey) &&
  129. (!!opPos || e.altKey && e.ctrlKey)) {
  130. opPos += (isNotKey ? 0 : 1);
  131. e.stopPropagation();
  132. e.preventDefault();
  133. } else {
  134. opPos = 0;
  135. }
  136. if (opPos === opKey.length) {
  137. opPos = 0;
  138. openOptions();
  139. }
  140. }, false);
  141. })();
  142.  
  143. // Special wrapper script to run scripts designed to override standard DOM functions
  144. // In Firefox appends supplied script to a page to make it run in page context and let
  145. // page content access overridden functions. In other browsers just run it as-is.
  146. function scriptLander(func, prepend) {
  147. if (!isFirefox) {
  148. func();
  149. return;
  150. }
  151. var s = document.createElement('script');
  152. s.textContent = '(function(){' + (
  153. prepend && prepend.join('') || ''
  154. ) + '!' + func + '();})();';
  155. _appendChild(s);
  156. _removeChild(s);
  157. }
  158.  
  159. // Creates and return protected style (unless protection is manually disabled).
  160. // Protected style will re-add itself on removal and remaind enabled on attempt to disable it.
  161. function createStyle(rules, props, skip_protect) {
  162. var prop = '',
  163. root = _de;
  164.  
  165. function _createGetterSetter(obj) {
  166. return {
  167. get: function() {return obj;}, //pretend to be empty
  168. set: function() {},
  169. enumerable: true
  170. };
  171. }
  172. function _protect(style) {
  173. Object.defineProperty(style, 'sheet', {
  174. value: style.sheet,
  175. enumerable: true
  176. });
  177. for (prop of ['rules', 'cssRules']) {
  178. Object.defineProperty(style.sheet, prop, _createGetterSetter([]));
  179. }
  180. Object.defineProperty(style, 'disabled', {
  181. get: function() {return true;}, //pretend to be disabled
  182. set: function() {},
  183. enumerable: true
  184. });
  185. (new MutationObserver(function() {
  186. root.removeChild(style);
  187. })).observe(style, {childList: true});
  188. }
  189.  
  190. function _create() {
  191. var style = root.appendChild(document.createElement('style'));
  192. style.type = 'text/css';
  193. for (var prop in props) {
  194. if (style[prop] !== undefined) {
  195. style[prop] = props[prop];
  196. }
  197. }
  198. function insertRule(rule) {
  199. try {
  200. style.sheet.insertRule(rule, 0);
  201. } catch (e) {
  202. console.error(e);
  203. }
  204. }
  205. if (typeof rules === 'string') {
  206. insertRule(rules);
  207. } else {
  208. rules.forEach(insertRule);
  209. }
  210. if (!skip_protect) {
  211. _protect(style);
  212. }
  213. return style;
  214. }
  215.  
  216. var style = _create();
  217. if (skip_protect) {
  218. return style;
  219. }
  220.  
  221. (new MutationObserver(function(ms){
  222. var m, node,
  223. resolveInANewContext = function(resolve){
  224. setTimeout(function(resolve){
  225. resolve(_create());
  226. }, 0, resolve);
  227. },
  228. setStyle = function(st){
  229. style = st;
  230. };
  231. for (m of ms) {
  232. for (node of m.removedNodes) {
  233. if (node === style) {
  234. (new Promise(resolveInANewContext))
  235. .then(setStyle);
  236. }
  237. }
  238. }
  239. })).observe(root, {childList:true});
  240.  
  241. return style;
  242. }
  243.  
  244. // https://greasyfork.org/scripts/19144-websuckit/
  245. function useWSI() {
  246. // check does browser support Proxy and WebSocket
  247. if (typeof Proxy !== 'function' ||
  248. typeof WebSocket !== 'function') {
  249. return;
  250. }
  251.  
  252. function getWrappedCode(removeSelf) {
  253. var text = getWrappedCode.toString()+WSI.toString();
  254. text = (
  255. '(function(){"use strict";'+
  256. text.replace(/\/\/[^\r\n]*/g,'').replace(/[\s\r\n]+/g,' ')+
  257. '(new WSI(self||window)).init();'+
  258. '})();\n'+
  259. (removeSelf?'var s = document.currentScript; if (s) {s.parentNode.removeChild(s);}':'')
  260. );
  261. return text;
  262. }
  263.  
  264. function WSI(win, safeWin) {
  265. safeWin = safeWin || win;
  266. var masks = [], filter;
  267. for (filter of [// blacklist
  268. '||10root25.website^', '||24video.xxx^',
  269. '||adlabs.ru^', '||adspayformymortgage.win^', '||aviabay.ru^',
  270. '||bgrndi.com^', '||brokeloy.com^',
  271. '||cnamerutor.ru^',
  272. '||docfilms.info^', '||dreadfula.ru^',
  273. '||et-code.ru^',
  274. '||film-doma.ru^',
  275. '||free-torrent.org^', '||free-torrent.pw^',
  276. '||free-torrents.org^', '||free-torrents.pw^',
  277. '||game-torrent.info^', '||gocdn.ru^',
  278. '||hdkinoshka.com^', '||hghit.com^', '||hindcine.net^',
  279. '||kiev.ua^', '||kinotochka.net^',
  280. '||kinott.com^', '||kinott.ru^', '||kuveres.com^',
  281. '||lepubs.com^', '||luxadv.com^', '||luxup.ru^', '||luxupcdna.com^',
  282. '||mail.ru^', '||marketgid.com^', '||mixadvert.com^', '||mxtads.com^',
  283. '||nickhel.com^',
  284. '||oconner.biz^', '||oconner.link^',
  285. '||pkpojhc.com^',
  286. '||psma01.com^', '||psma02.com^', '||psma03.com^',
  287. '||recreativ.ru^', '||redtram.com^', '||regpole.com^', '||rootmedia.ws^', '||ruttwind.com^',
  288. '||skidl.ru^',
  289. '||torvind.com^', '||traffic-media.co^', '||trafmag.com^',
  290. '||webadvert-gid.ru^', '||webadvertgid.ru^',
  291. '||xxuhter.ru^',
  292. '||yuiout.online^',
  293. '||zoom-film.ru^'
  294. ]) {
  295. masks.push(new RegExp(
  296. filter.replace(/([\\\/\[\].*+?(){}$])/g, '\\$1')
  297. .replace(/\^(?!$)/g,'\\.?[^\\w%._-]')
  298. .replace(/\^$/,'\\.?([^\\w%._-]|$)')
  299. .replace(/^\|\|/,'^(ws|http)s?:\\/+([^\/.]+\\.)*'),
  300. 'i'));
  301. }
  302.  
  303. function isBlocked(url) {
  304. for (var mask of masks) {
  305. if (mask.test(url)) {
  306. return true;
  307. }
  308. }
  309. return false;
  310. }
  311.  
  312. var realWebSocket = win.WebSocket;
  313. function wsGetter (target, name) {
  314. try {
  315. if (typeof realWebSocket.prototype[name] === 'function') {
  316. if (name === 'close' || name === 'send') { // send also closes connection
  317. target.readyState = realWebSocket.CLOSED;
  318. }
  319. return (
  320. function fake() {
  321. console.log('[WSI] Invoked function "'+name+'"', '| Tracing', (new Error()));
  322. return;
  323. }
  324. );
  325. }
  326. if (typeof realWebSocket.prototype[name] === 'number') {
  327. return realWebSocket[name];
  328. }
  329. } catch(ignore) {}
  330. return target[name];
  331. }
  332.  
  333. function createWebSocketWrapper(target) {
  334. return new Proxy(realWebSocket, {
  335. construct: function (target, args) {
  336. var url = args[0];
  337. console.log('[WSI] Opening socket on ' + url + ' \u2026');
  338. if (isBlocked(url)) {
  339. console.log("[WSI] Blocked.");
  340. return new Proxy({
  341. url: url,
  342. readyState: realWebSocket.OPEN
  343. }, {
  344. get: wsGetter
  345. });
  346. }
  347. return new target(args[0], args[1]);
  348. }
  349. });
  350. }
  351.  
  352. function WorkerWrapper() {
  353. var realWorker = win.Worker;
  354. function wrappedWorker(resourceURI) {
  355. var isBlobURL = /^blob:/i,
  356. xhr = null,
  357. _callbacks = new WeakMap(),
  358. _worker = null,
  359. _terminate = false,
  360. _onerror = null,
  361. _onmessage = null,
  362. _messages = [],
  363. _events = [],
  364. /*jshint validthis:true */
  365. _self = this;
  366.  
  367. function callbackWrapper(func) {
  368. if (typeof func !== 'function') {
  369. return undefined;
  370. }
  371. return (
  372. function callback() {
  373. func.apply(_self, arguments);
  374. }
  375. );
  376. }
  377.  
  378. _self.terminate = function(){
  379. _terminate = true;
  380. if (_worker) {
  381. _worker.terminate();
  382. }
  383. };
  384. Object.defineProperty(_self, 'onmessage', {
  385. get: function() {
  386. return _onmessage;
  387. },
  388. set: function(val) {
  389. _onmessage = val;
  390. if (_worker) {
  391. _worker.onmessage = callbackWrapper(val);
  392. }
  393. }
  394. });
  395. Object.defineProperty(_self, 'onerror', {
  396. get: function() {
  397. return _onerror;
  398. },
  399. set: function(val) {
  400. _onerror = val;
  401. if (_worker) {
  402. _worker.onerror = callbackWrapper(val);
  403. }
  404. }
  405. });
  406. _self.postMessage = function(message){
  407. if (_worker) {
  408. _worker.postMessage(message);
  409. } else {
  410. _messages.push(message);
  411. }
  412. };
  413. _self.terminate = function() {
  414. _terminate = true;
  415. if (_worker) {
  416. _worker.terminate();
  417. }
  418. };
  419. _self.addEventListener = function(){
  420. if (typeof arguments[1] !== 'function') {
  421. return;
  422. }
  423. if (!_callbacks.has(arguments[1])) {
  424. _callbacks.set(arguments[1], callbackWrapper(arguments[1]));
  425. }
  426. arguments[1] = _callbacks.get(arguments[1]);
  427. if (_worker) {
  428. _worker.addEventListener.apply(_worker, arguments);
  429. } else {
  430. _events.push(['addEventListener', arguments]);
  431. }
  432. };
  433. _self.removeEventListener = function(){
  434. if (typeof arguments[1] !== 'function' || !_callbacks.has(arguments[1])) {
  435. return;
  436. }
  437. arguments[1] = _callbacks.get(arguments[1]);
  438. _callbacks.delete(arguments[1]);
  439. if (_worker) {
  440. _worker.removeEventListener.apply(_worker, arguments);
  441. } else {
  442. _events.push(['removeEventListener', arguments]);
  443. }
  444. };
  445.  
  446. if (!isBlobURL.test(resourceURI)) {
  447. _worker = new realWorker(resourceURI);
  448. return; // not a blob, no need to wrap
  449. }
  450.  
  451. xhr = new XMLHttpRequest();
  452. xhr.responseType = 'blob';
  453. try {
  454. xhr.open('GET', resourceURI, true);
  455. } catch(ignore) {
  456. _worker = new realWorker(resourceURI);
  457. return; // failed to open connection, unable to continue wrapping procedure
  458. }
  459. (new Promise(function(resolve, reject){
  460. if (xhr.readyState !== XMLHttpRequest.OPENED) {
  461. // connection wasn't opened, unable to continue wrapping procedure
  462. return reject();
  463. }
  464. xhr.onload = function(){
  465. if (this.status === 200) {
  466. var reader = new FileReader();
  467. reader.addEventListener("loadend", function() {
  468. resolve(new realWorker(URL.createObjectURL(
  469. new Blob([getWrappedCode(false)+this.result])
  470. )));
  471. });
  472. reader.readAsText(this.response);
  473. }
  474. };
  475. xhr.send();
  476. })).then(function(val) {
  477. _worker = val;
  478. _worker.onerror = callbackWrapper(_onerror);
  479. _worker.onmessage = callbackWrapper(_onmessage);
  480. var _e;
  481. while(_events.length) {
  482. _e = _events.shift();
  483. _worker[_e[0]].apply(_worker, _e[1]);
  484. }
  485. while(_messages.length) {
  486. _worker.postMessage(_messages.shift());
  487. }
  488. if (_terminate) {
  489. _worker.terminate();
  490. }
  491. }).catch(function(){});
  492.  
  493. }
  494. win.Worker = wrappedWorker.bind(safeWin);
  495. }
  496.  
  497. function CreateElementWrapper() {
  498. var realCreateElement = Document.prototype.createElement,
  499. _addEventListener = Element.prototype.addEventListener,
  500. code = encodeURIComponent('<scr'+'ipt>'+getWrappedCode(true)+'</scr'+'ipt>\n'),
  501. isDataURL = /^data:/i,
  502. isBlobURL = /^blob:/i;
  503.  
  504. function frameRewrite(e) {
  505. var f = e.target,
  506. w = f.contentWindow;
  507. if (!f.src || (w && isBlobURL.test(f.src))) {
  508. w.WebSocket = createWebSocketWrapper();
  509. }
  510. if (isDataURL.test(f.src) && f.src.indexOf(code) < 0) {
  511. f.src = f.src.replace(',',',' + code);
  512. }
  513. }
  514.  
  515. var scriptMap = new WeakMap();
  516. scriptMap.isBlocked = isBlocked;
  517. var onErrorWrapper = {
  518. set: function(val) {
  519. if (scriptMap.has(this)) {
  520. this.removeEventListener('error', scriptMap.get(this).wrp, false);
  521. scriptMap.delete(this);
  522. }
  523. if (!val || typeof val !== 'function') {
  524. return val;
  525. }
  526. scriptMap.set(this, {
  527. org: val,
  528. wrp: function() {
  529. if (scriptMap.isBlocked(this.src)) {
  530. console.log('[WSI] Blocked "onerror" callback from', this);
  531. return;
  532. }
  533. scriptMap.get(this).org.apply(this, arguments);
  534. }
  535. });
  536. this.addEventListener('error', scriptMap.get(this).wrp, false);
  537. return val;
  538. },
  539. get: function() {
  540. return scriptMap.has(this) ? scriptMap.get(this).org : null;
  541. },
  542. enumerable: true
  543. };
  544. function wrappedCreateElement(name) {
  545. /*jshint validthis:true */
  546. var el = realCreateElement.apply(this, arguments);
  547. if (el.tagName === 'IFRAME') {
  548. _addEventListener.call(el, 'load', frameRewrite, false);
  549. }
  550. if (el.tagName === 'SCRIPT') {
  551. Object.defineProperty(el, 'onerror', onErrorWrapper);
  552. }
  553. return el;
  554. }
  555. Document.prototype.createElement = wrappedCreateElement;
  556.  
  557. document.addEventListener('DOMContentLoaded', function(){
  558. for (var ifr of document.querySelectorAll('IFRAME')) {
  559. _addEventListener.call(ifr, 'load', frameRewrite, false);
  560. }
  561. }, false);
  562. }
  563.  
  564. this.init = function() {
  565. win.WebSocket = createWebSocketWrapper();
  566. if (!(/firefox/i.test(navigator.userAgent))) {
  567. WorkerWrapper(); // skip WorkerWrapper in Firefox
  568. }
  569. if (typeof document !== 'undefined') {
  570. CreateElementWrapper();
  571. }
  572. };
  573. }
  574.  
  575. if (isFirefox) {
  576. var script = document.createElement('script');
  577. script.appendChild(document.createTextNode(getWrappedCode(true)));
  578. document.head.insertBefore(script, document.head.firstChild);
  579. return; //we don't want to call functions on page from here in Fx, so exit
  580. }
  581.  
  582. (new WSI((unsafeWindow||self||window),(self||window))).init();
  583. }
  584.  
  585. if (!isFirefox) { // scripts for non-Firefox browsers
  586.  
  587. // https://greasyfork.org/scripts/14720-it-s-not-important
  588. (function(){
  589. var imptt = /((display|(margin|padding)(-top|-bottom)?)\s*:[^;!]*)!\s*important/ig;
  590.  
  591. function unimportanter(el, si) {
  592. if (!imptt.test(si) || el.style.display === 'none') {
  593. return 0; // get out if we have nothing to do here
  594. }
  595. if (el.nodeName === 'IFRAME' && el.src &&
  596. el.src.slice(0,17) === 'chrome-extension:') {
  597. return 0; // Web of Trust uses this method to add their frame
  598. }
  599. var so = si.replace(imptt, function(){return arguments[1];}), ret = 0;
  600. if (si !== so) {
  601. ret = 1;
  602. _setAttribute.call(el, 'style', so);
  603. }
  604. return ret;
  605. }
  606.  
  607. function logger(c) {
  608. if (c) {
  609. console.log('Some page elements became a bit less important.');
  610. }
  611. }
  612.  
  613. function checkTarget(node, cnt) {
  614. if (!(node && node.getAttribute)) {
  615. return 0;
  616. }
  617. var si = _getAttribute.call(node, 'style');
  618. if (si && si.indexOf('!') > -1) {
  619. cnt += unimportanter(node, si);
  620. }
  621. return cnt;
  622. }
  623.  
  624. (new MutationObserver(function(mutations) {
  625. setTimeout(function(ms) {
  626. var cnt = 0, m, node;
  627. for (m of ms) {
  628. cnt = checkTarget(m.target, cnt);
  629. for (node of m.addedNodes) {
  630. cnt += checkTarget(node, cnt);
  631. }
  632. }
  633. logger(cnt);
  634. }, 0, mutations);
  635. })).observe(document, {
  636. childList : true,
  637. attributes : true,
  638. attributeFilter : ['style'],
  639. subtree : true
  640. });
  641.  
  642. win.addEventListener ("load", function(){
  643. var c = 0, imp;
  644. for (imp of document.querySelectorAll('[style*="!"]')) {
  645. c+= checkTarget(imp, c);
  646. }
  647. logger(c);
  648. }, false);
  649. })();
  650.  
  651. }
  652.  
  653. if (/^https?:\/\/(mail\.yandex\.|music\.yandex\.|news\.yandex\.|(www\.)?yandex\.[^\/]+\/(yand)?search[\/?])/i.test(win.location.href)) {
  654. // https://greasyfork.org/en/scripts/809-no-yandex-ads
  655. (function(){
  656. var adWords = ['Яндекс.Директ','Реклама','Ad'],
  657. genericAdSelectors = (
  658. '.serp-adv__head + .serp-item,'+
  659. '#adbanner,'+
  660. '.serp-adv,'+
  661. '.b-spec-adv,'+
  662. 'div[class*="serp-adv__"]:not(.serp-adv__found):not(.serp-adv__displayed)'
  663. );
  664. function remove(node) {
  665. node.parentNode.removeChild(node);
  666. }
  667. // Generic ads removal and fixes
  668. function removeGenericAds() {
  669. var s = document.querySelector('.serp-header');
  670. if (s) {
  671. s.style.marginTop='0';
  672. }
  673. for (s of document.querySelectorAll(genericAdSelectors)) {
  674. remove(s);
  675. }
  676. }
  677. // Search ads
  678. function removeSearchAds() {
  679. var s, item, l;
  680. for (s of document.querySelectorAll('.t-construct-adapter__legacy')) {
  681. item = s.querySelector('.organic__subtitle');
  682. l = window.getComputedStyle(item, ':after').content;
  683. if (item && adWords.indexOf(l.replace(/"/g,'')) > -1) {
  684. remove(s);
  685. console.log('Ads removed.');
  686. }
  687. }
  688. }
  689. // News ads
  690. function removeNewsAds() {
  691. for (var s of document.querySelectorAll(
  692. '.page-content__left > *,'+
  693. '.page-content__right > *:not(.page-content__col),'+
  694. '.page-content__right > .page-content__col > *'
  695. )) {
  696. if (s.textContent.indexOf(adWords[0]) > -1 ||
  697. (s.clientHeight < 15 && s.classList.contains('rubric'))) {
  698. remove(s);
  699. console.log('Ads removed.');
  700. }
  701. }
  702. }
  703. // Music ads
  704. function removeMusicAds() {
  705. for (var s of document.querySelectorAll('.ads-block')) {
  706. remove(s);
  707. }
  708. }
  709. // Mail ads
  710. function removeMailAds() {
  711. var slice = Array.prototype.slice,
  712. nodes = slice.call(document.querySelectorAll('.ns-view-folders')),
  713. node, len, cls;
  714. for (node of nodes) {
  715. if (!len || len > node.classList.length) {
  716. len = node.classList.length;
  717. }
  718. }
  719. node = nodes.pop();
  720. while (node) {
  721. if (node.classList.length > len) {
  722. for (cls of slice.call(node.classList)) {
  723. if (cls.indexOf('-') === -1) {
  724. remove(node);
  725. break;
  726. }
  727. }
  728. }
  729. node = nodes.pop();
  730. }
  731. }
  732. // News fixes
  733. function removePageAdsClass() {
  734. if (document.body.classList.contains("b-page_ads_yes")){
  735. document.body.classList.remove("b-page_ads_yes");
  736. console.log('Page ads class removed.');
  737. }
  738. }
  739. // Function to attach an observer to monitor dynamic changes on the page
  740. function pageUpdateObserver(func, obj, params) {
  741. if (obj) {
  742. (new MutationObserver(func)).observe(obj,(params || {childList:true, subtree:true}));
  743. }
  744. }
  745. // Cleaner
  746. document.addEventListener ('DOMContentLoaded', function() {
  747. removeGenericAds();
  748. if (win.location.hostname.search(/^mail\./i) === 0) {
  749. pageUpdateObserver(function(ms, o){
  750. var aside = document.querySelector('.mail-Layout-Aside');
  751. if (aside) {
  752. o.disconnect();
  753. pageUpdateObserver(removeMailAds, aside);
  754. }
  755. }, document.querySelector('BODY'));
  756. removeMailAds();
  757. } else if (win.location.hostname.search(/^music\./i) === 0) {
  758. pageUpdateObserver(removeMusicAds, document.querySelector('.sidebar'));
  759. removeMusicAds();
  760. } else if (win.location.hostname.search(/^news\./i) === 0) {
  761. pageUpdateObserver(removeNewsAds, document.querySelector('BODY'));
  762. pageUpdateObserver(removePageAdsClass, document.body, {attributes:true, attributesFilter:['class']});
  763. removeNewsAds();
  764. removePageAdsClass();
  765. } else {
  766. pageUpdateObserver(removeSearchAds, document.querySelector('.main__content'));
  767. removeSearchAds();
  768. }
  769. });
  770. })();
  771. }
  772. // Yandex Link Tracking
  773. if (/^https?:\/\/([^.]+\.)*yandex\.[^\/]+/i.test(win.location.href)) {
  774. // Partially based on https://greasyfork.org/en/scripts/22737-remove-yandex-redirect
  775. (function(){
  776. var link, selectors = (
  777. 'A[onmousedown*="/jsredir"],'+
  778. 'A[data-vdir-href],'+
  779. 'A[data-counter]'
  780. );
  781. function removeTrackingAttributes(link) {
  782. link.removeAttribute('onmousedown');
  783. if (link.hasAttribute('data-vdir-href')) {
  784. link.removeAttribute('data-vdir-href');
  785. link.removeAttribute('data-orig-href');
  786. }
  787. if (link.hasAttribute('data-counter')) {
  788. link.removeAttribute('data-counter');
  789. link.removeAttribute('data-bem');
  790. }
  791. }
  792. function removeTracking(scope) {
  793. for (link of scope.querySelectorAll(selectors)) {
  794. removeTrackingAttributes(link);
  795. }
  796. }
  797. document.addEventListener('DOMContentLoaded', function(e) {
  798. removeTracking(e.target);
  799. });
  800. (new MutationObserver(function(ms) {
  801. var m, node;
  802. for (m of ms) {
  803. for (node of m.addedNodes) {
  804. if (node.nodeType === Node.ELEMENT_NODE) {
  805. if (node.tagName === 'A' && node.matches(selectors)) {
  806. removeTrackingAttributes(node);
  807. } else {
  808. removeTracking(node);
  809. }
  810. }
  811. }
  812. }
  813. })).observe(_de, {childList: true, subtree: true});
  814. })();
  815. return; //skip fixes for other sites
  816. }
  817.  
  818. // https://greasyfork.org/en/scripts/21937-moonwalk-hdgo-kodik-fix v0.8 (adapted)
  819. document.addEventListener ('DOMContentLoaded', function() {
  820. var tmp;
  821. function log (e) {
  822. console.log('Moonwalk&HDGo&Kodik FIX: ' + e + ' player in ' + win.location.href);
  823. }
  824. if (win.adv_enabled !== undefined && win.condition_detected !== undefined) { // moonwalk
  825. log('Moonwalk');
  826. if (win.adv_enabled) {
  827. win.adv_enabled = false;
  828. }
  829. win.condition_detected = false;
  830. if (win.MXoverrollCallback) {
  831. document.addEventListener('click', function catcher(e){
  832. e.stopPropagation();
  833. win.MXoverrollCallback.call(window);
  834. document.removeEventListener('click', catcher, true);
  835. }, true);
  836. }
  837. } else if (win.stat_url !== undefined && win.is_html5 !== undefined && win.is_wp8 !== undefined) { // hdgo
  838. log('HDGo');
  839. document.body.onclick = null;
  840. tmp = document.querySelector('#swtf');
  841. if (tmp) {
  842. tmp.style.display = 'none';
  843. }
  844. if (win.banner_second !== undefined) {
  845. win.banner_second = 0;
  846. }
  847. if (win.$banner_ads !== undefined) {
  848. win.$banner_ads = false;
  849. }
  850. if (win.$new_ads !== undefined) {
  851. win.$new_ads = false;
  852. }
  853. if (win.createCookie !== undefined) {
  854. win.createCookie('popup','true','999');
  855. }
  856. if (win.canRunAds !== undefined && win.canRunAds !== true) {
  857. win.canRunAds = true;
  858. }
  859. } else if (win.MXoverrollCallback && win.iframeSearch !== undefined) { // kodik
  860. log('Kodik');
  861. tmp = document.querySelector('.play_button');
  862. if (tmp) {
  863. tmp.onclick = win.MXoverrollCallback.bind(window);
  864. }
  865. win.IsAdBlock = false;
  866. }
  867. }, false);
  868.  
  869. // Automated protection against specific circumvention method based on unwrapping various functions,
  870. // hiding ads in the Shadow DOM and injecting iFrames with ads. Previously this code were known as
  871. // apiBreaker since it were breaking Shadow DOM and onerror/onload API on specific domains. This
  872. // version should be safe enough to run on majority of sites without actually breaking them.
  873. scriptLander(function() {
  874. var blacklist = new WeakMap(),
  875. replacer, func;
  876. /* Wrap functions used to attach shadow root to a node */
  877. replacer = function (func) {
  878. return function() {
  879. blacklist.set(this, true);
  880. return func.apply(this, arguments);
  881. };
  882. };
  883. for (func of ['createShadowRoot', 'attachShadow']) {
  884. if (func in Element.prototype) {
  885. Element.prototype[func] = replacer(Element.prototype[func]);
  886. }
  887. }
  888. /* Wrap functions used to insert/append elements to check for IFRAME objects */
  889. replacer = function (func) {
  890. return function(el, par) {
  891. if (el.tagName === 'IFRAME' &&
  892. ((typeof par === 'object' && blacklist.get(par))/* ||
  893. el.style.display === 'none'*/)) {
  894. console.log('Blocked suspicious', func.name, arguments);
  895. return null;
  896. }
  897. return func.apply(this, arguments);
  898. };
  899. };
  900. for (func of [/*'appendChild', */'insertBefore']) {
  901. Object.defineProperty(Element.prototype, func, {
  902. value: replacer(Element.prototype[func]), enumerable: true
  903. });
  904. }
  905. });
  906.  
  907. // === Helper functions ===
  908.  
  909. // function to search and remove nodes by content
  910. // selector - standard CSS selector to define set of nodes to check
  911. // words - regular expression to check content of the suspicious nodes
  912. // params - object with multiple extra parameters:
  913. // .hide - set display to none instead of removing from the page
  914. // .parent - parent node to remove if content is found in the child node
  915. // .siblings - number of simling nodes to remove (excluding text nodes)
  916. function scRemove(e) {e.parentNode.removeChild(e);}
  917. function scHide(e) {
  918. var s = _getAttribute.call(e, 'style') || '',
  919. h = ';display:none!important;';
  920. if (s.indexOf(h) < 0) {
  921. _setAttribute.call(e, 'style', s+h);
  922. }
  923. }
  924. function scissors (selector, words, scope, params) {
  925. var remFunc = (params.hide ? scHide : scRemove),
  926. iterFunc = (params.siblings > 0 ?
  927. 'nextSibling' :
  928. 'previousSibling'),
  929. toRemove = [],
  930. siblings,
  931. node;
  932. for (node of scope.querySelectorAll(selector)) {
  933. if (params.parent) {
  934. while(node !== scope && !(node.matches(params.parent))) {
  935. node = node.parentNode;
  936. }
  937. }
  938. if (words.test(node.innerHTML) || !node.childNodes.length) {
  939. // drill up to the specified parent node if required
  940. if (node === scope) {
  941. break;
  942. }
  943. toRemove.push(node);
  944. // add multiple nodes if defined more than one sibling
  945. siblings = Math.abs(params.siblings) || 0;
  946. while (siblings) {
  947. node = node[iterFunc];
  948. toRemove.push(node);
  949. if (node.nodeType === Node.ELEMENT_NODE) {
  950. siblings -= 1; //count only element nodes
  951. }
  952. }
  953. }
  954. }
  955. for (node of toRemove) {
  956. remFunc(node);
  957. }
  958. return toRemove.length;
  959. }
  960.  
  961. // function to perform multiple checks if ads inserted with a delay
  962. // by default does 30 checks withing a 3 seconds unless nonstop mode specified
  963. // also does 1 extra check when a page completely loads
  964. // selector and words - passed dow to scissors
  965. // params - object with multiple extra parameters:
  966. // .root - selector to narrow down scope to scan;
  967. // .observe - if true then check will be performed continuously;
  968. // Other parameters passed down to scissors.
  969. function gardener(selector, words, params) {
  970. params = params || {};
  971. var scope = document,
  972. nonstop = false;
  973. // narrow down scope to a specific element
  974. if (params.root) {
  975. scope = scope.querySelector(params.root);
  976. if (!scope) {// exit if the root element is not present on the page
  977. return 0;
  978. }
  979. }
  980. // add observe mode if required
  981. if (params.observe) {
  982. if (typeof MutationObserver === 'function') {
  983. (new MutationObserver(function(ms){
  984. for (var m of ms) {
  985. if (m.addedNodes.length) {
  986. scissors(selector, words, scope, params);
  987. }
  988. }
  989. })).observe(scope, {childList:true, subtree: true});
  990. } else {
  991. nonstop = true;
  992. }
  993. }
  994. // wait for a full page load to do one extra cut
  995. win.addEventListener('load',function(){
  996. scissors(selector, words, scope, params);
  997. });
  998. // do multiple cuts until ads removed
  999. function cut(sci, s, w, sc, p, i) {
  1000. if (i > 0) {
  1001. i -= 1;
  1002. }
  1003. if (i && !sci(s, w, sc, p)) {
  1004. setTimeout(cut, 100, sci, s, w, sc, p, i);
  1005. }
  1006. }
  1007. cut(scissors, selector, words, scope, params, (nonstop ? -1 : 30));
  1008. }
  1009.  
  1010. // Helper function to close background tab if site opens itself in a new tab and then
  1011. // loads a 3rd-party page in the background one (thus performing background redirect).
  1012. function preventBackgroundRedirect() {
  1013. // create "cose_me" event to call high-level window.close()
  1014. var key = Math.random().toString(36).substr(2);
  1015. window.addEventListener('close_me_'+key, function(e) {
  1016. window.close();
  1017. });
  1018.  
  1019. // window.open wrapper
  1020. function pbrLander() {
  1021. var orgOpen = window.open.bind(window),
  1022. idx = String.prototype.indexOf,
  1023. event = new CustomEvent("close_me_%key%", {});
  1024. function closeWindow(){
  1025. // site went to a new tab and attempts to unload
  1026. // call for high-level close through event
  1027. window.dispatchEvent(event);
  1028. }
  1029. // window.open wrapper
  1030. function open(){
  1031. console.log(arguments, window.location.host);
  1032. if (arguments[0] &&
  1033. (idx.call(arguments[0], window.location.host) > -1 ||
  1034. idx.call(arguments[0], '://') === -1)) {
  1035. window.addEventListener('unload', closeWindow, true);
  1036. }
  1037. orgOpen.apply(window, arguments);
  1038. }
  1039. window.open = open.bind(window);
  1040. // Node.createElement wrapper to prevent click-dispatch in Google Chrome and similar browsers
  1041. var realCreateElement = Document.prototype.createElement;
  1042. function wrappedCreateElement(name) {
  1043. /*jshint validthis:true */
  1044. var el = realCreateElement.apply(this, arguments);
  1045. if (el.tagName === 'A') {
  1046. el.addEventListener('click', function(e){
  1047. if (!e.target.parentNode || !e.isTrusted) {
  1048. window.addEventListener('unload', closeWindow, true);
  1049. }
  1050. }, false);
  1051. }
  1052. return el;
  1053. }
  1054. Document.prototype.createElement = wrappedCreateElement;
  1055. }
  1056.  
  1057. // land wrapper on the page
  1058. var script = document.createElement('script');
  1059. script.appendChild(document.createTextNode('('+pbrLander.toString().replace(/%key%/g,key)+')();'));
  1060. document.head.insertBefore(script, document.head.firstChild);
  1061. script.parentNode.removeChild(script);
  1062. console.log("Background redirect prevention enabled.");
  1063. }
  1064.  
  1065. // Function to catch and block various methods to open a new window with 3rd-party content.
  1066. // Some advertisement networks went way past simple window.open call to circumvent default popup protection.
  1067. // This funciton blocks window.open, ability to restore original window.open from an IFRAME object,
  1068. // ability to perform an untrusted (not initiated by user) click on a link, click on a link without a parent
  1069. // node or simply a link with piece of javascript code in the HREF attribute.
  1070. function preventPopups() {
  1071. function open(){
  1072. console.log('Site attempted to open a new window', arguments);
  1073. function nil(){}
  1074. return {
  1075. document: {
  1076. write: nil,
  1077. writeln: nil
  1078. }
  1079. };
  1080. }
  1081. win.open = exportFunction(open, win);
  1082.  
  1083. function wrapFunctions() {
  1084. var realCreateElement = Document.prototype.createElement,
  1085. realAppendChild = Element.prototype.appendChild;
  1086. Document.prototype.createElement = function createElement(name) {
  1087. /*jshint validthis:true */
  1088. var el = realCreateElement.apply(this, arguments);
  1089. if (el.tagName === 'A') {
  1090. el.addEventListener('click', function(e) {
  1091. if (!e.target.parentNode || !e.isTrusted ||
  1092. (e.target.href && e.target.href.toLowerCase().indexOf('javascript') > -1)) {
  1093. e.preventDefault();
  1094. console.log('Blocked suspicious click event', e, 'on', e.target);
  1095. }
  1096. }, false);
  1097. }
  1098. if (el.tagName === 'IFRAME') {
  1099. el.addEventListener('load', function(){
  1100. try {
  1101. this.contentWindow.open = open;
  1102. } catch(ignore) {}
  1103. }, false);
  1104. }
  1105. return el;
  1106. };
  1107. Element.prototype.appendChild = function appendChild() {
  1108. var child = realAppendChild.apply(this, arguments);
  1109. if (child && child.nodeType === Node.ELEMENT_NODE && child.tagName === 'IFRAME') {
  1110. try {
  1111. child.contentWindow.open = open;
  1112. } catch(ignore) {}
  1113. }
  1114. return child;
  1115. };
  1116. }
  1117.  
  1118. scriptLander(wrapFunctions, [open]);
  1119. }
  1120.  
  1121. // Currently unused piece of code developed to prevent site from registering serviceWorker
  1122. // and uninstall any existing instances of serivceWorker in case there is one already.
  1123. /* Commented out since not used
  1124. function forbidServiceWorker() {
  1125. if (!("serviceWorker" in navigator)) {
  1126. return;
  1127. }
  1128. var svr = navigator.serviceWorker.ready;
  1129. Object.defineProperty(navigator, 'serviceWorker', {
  1130. value: {
  1131. register: function(){
  1132. console.log('Registration of serviceWorker ' + arguments[0] + ' blocked.');
  1133. return new Promise(function(){});
  1134. },
  1135. ready: new Promise(function(){}),
  1136. addEventListener:function(){}
  1137. }
  1138. });
  1139. document.addEventListener('DOMContentLoaded', function() {
  1140. if (!svr) {
  1141. return;
  1142. }
  1143. svr.then(function(sw) {
  1144. console.log('Found existing serviceWorker:', sw);
  1145. console.log('Attempting to unregister...');
  1146. sw.unregister().then(function() {
  1147. console.log('Unregistered! :)');
  1148. }).catch(function(err) {
  1149. console.log('Unregistration failed. :(', err);
  1150. console.log('Try to remove it manually:');
  1151. console.log(' 1. Open: chrome://serviceworker-internals/ (Google Chrome and alike) or about:serviceworkers (Mozilla Firefox) in a new tab.');
  1152. console.log(' 2. Search there for one with "'+document.domain+'" in the name.');
  1153. console.log(' 3. Use buttons in the same block with service you found to stop it and uninstall/unregister.');
  1154. });
  1155. }).catch(function(err) {
  1156. console.log("Lol, it failed on it's own. -_-", err);
  1157. });
  1158. }, false);
  1159. }
  1160. /**/
  1161.  
  1162. // Currently obsolete code developed to prevent error and load calls on objects supposed to load resources
  1163. // from the internet like IMG or IFRAME, but missing SRC/HREF attribute. Usually tricks like this are used
  1164. // to unwrap wrapped functions to be able to load ads.
  1165. /* Commented out since not used
  1166. function errorAndLoadEventsFilter() {
  1167. var toString = Function.prototype.toString,
  1168. addEventListener = Element.prototype.addEventListener,
  1169. removeEventListener = Element.prototype.removeEventListener,
  1170. hasAttribute = Element.prototype.hasAttribute,
  1171. evtMap = new WeakMap();
  1172. Element.prototype.addEventListener = function(evt, func, capt) {
  1173. if (evt === 'error' || evt === 'load') {
  1174. if (!evtMap.get(func)) {
  1175. evtMap.set(func, function() {
  1176. if (hasAttribute.call(this, 'src') ||
  1177. hasAttribute.call(this, 'href')) {
  1178. func.apply(this, arguments);
  1179. } else {
  1180. console.log('Blocked', evt, 'handler', toString.call(func), 'on', this);
  1181. }
  1182. });
  1183. }
  1184. }
  1185. addEventListener.call(this, evt, (evtMap.get(func) || func), capt);
  1186. };
  1187. Element.prototype.removeEventListener = function(evt, func, capt) {
  1188. removeEventListener.call(this, evt, (evtMap.get(func) || func), capt);
  1189. };
  1190. Object.defineProperty(HTMLElement.prototype, 'onload', {
  1191. set: function(func) {
  1192. if(evtMap.has(this)) {
  1193. if (evtMap.get(this).onload) {
  1194. Element.prototype.removeEventListener.call(this, 'load', evtMap.get(this).onload, false);
  1195. }
  1196. evtMap.get(this).onload = func;
  1197. } else {
  1198. evtMap.set(this, { onload: func });
  1199. }
  1200. if (func) {
  1201. Element.prototype.addEventListener.call(this, 'load', func, false);
  1202. }
  1203. return func;
  1204. },
  1205. get: function() {
  1206. return evtMap.has(this) ? evtMap.get(this).onload : null;
  1207. }
  1208. });
  1209. Object.defineProperty(HTMLElement.prototype, 'onerror', {
  1210. set: function(func) {
  1211. if (evtMap.has(this)) {
  1212. evtMap.get(this).onerror = func;
  1213. } else {
  1214. evtMap.set(this, { onerror: func });
  1215. }
  1216. if (func) {
  1217. console.log('Blocked error handler', toString.call(func), 'on', this);
  1218. }
  1219. return func;
  1220. },
  1221. get: function() {
  1222. return evtMap.has(this) ? evtMap.get(this).onerror : null;
  1223. }
  1224. });
  1225. }
  1226. /**/
  1227.  
  1228. // === Scripts for specific domains ===
  1229.  
  1230. var scripts = {};
  1231. // prevent popups and redirects block
  1232. var preventPopupsNow = { 'now': preventPopups },
  1233. preventBackgroundRedirectNow = { 'now': preventBackgroundRedirect };
  1234. // Popups
  1235. scripts['biqle.ru'] = preventPopupsNow;
  1236. scripts['chaturbate.com'] = preventPopupsNow;
  1237. scripts['dfiles.ru'] = preventPopupsNow;
  1238. scripts['hentaiz.org'] = preventPopupsNow;
  1239. scripts['mirrorcreator.com'] = preventPopupsNow;
  1240. scripts['online-multy.ru'] = preventPopupsNow;
  1241. scripts['openload.co'] = preventPopupsNow;
  1242. scripts['radikal.ru'] = preventPopupsNow;
  1243. scripts['seedoff.cc'] = preventPopupsNow;
  1244. scripts['tapochek.net'] = preventPopupsNow;
  1245. scripts['thepiratebay.org'] = preventPopupsNow;
  1246. scripts['torseed.net'] = preventPopupsNow;
  1247. scripts['zippyshare.com'] = preventPopupsNow;
  1248. // Background redirects
  1249. scripts['mediafire.com'] = preventBackgroundRedirectNow;
  1250. scripts['megapeer.org'] = preventBackgroundRedirectNow;
  1251. scripts['megapeer.ru'] = preventBackgroundRedirectNow;
  1252. scripts['perfectgirls.net'] = preventBackgroundRedirectNow;
  1253. scripts['turbobit.net'] = preventBackgroundRedirectNow;
  1254.  
  1255. // other
  1256. scripts['4pda.ru'] = {
  1257. 'now': function() {
  1258. // https://greasyfork.org/en/scripts/14470-4pda-unbrender
  1259. var isForum = document.location.href.search('/forum/') !== -1,
  1260. hStyle;
  1261.  
  1262. function remove(n) {
  1263. if (n) {
  1264. n.parentNode.removeChild(n);
  1265. }
  1266. }
  1267.  
  1268. function afterClean() {
  1269. hStyle.disabled = true;
  1270. remove(hStyle);
  1271. }
  1272.  
  1273. function beforeClean() {
  1274. // attach styles before document displayed
  1275. hStyle = createStyle([
  1276. 'html { overflow-y: scroll }',
  1277. 'section[id] {'+(
  1278. 'position: absolute;'+
  1279. 'width: 100%'
  1280. )+'}',
  1281. 'article + aside * { display: none !important }',
  1282. '#header + div:after {'+(
  1283. 'content: "";'+
  1284. 'position: fixed;'+
  1285. 'top: 0;'+
  1286. 'left: 0;'+
  1287. 'width: 100%;'+
  1288. 'height: 100%;'+
  1289. 'background-color: #E6E7E9'
  1290. )+'}',
  1291. // http://codepen.io/Beaugust/pen/DByiE
  1292. '@keyframes spin { 100% { transform: rotate(360deg) } }',
  1293. 'article + aside:after {'+(
  1294. 'content: "";'+
  1295. 'position: absolute;'+
  1296. 'width: 150px;'+
  1297. 'height: 150px;'+
  1298. 'top: 150px;'+
  1299. 'left: 50%;'+
  1300. 'margin-top: -75px;'+
  1301. 'margin-left: -75px;'+
  1302. 'box-sizing: border-box;'+
  1303. 'border-radius: 100%;'+
  1304. 'border: 10px solid rgba(0, 0, 0, 0.2);'+
  1305. 'border-top-color: rgba(0, 0, 0, 0.6);'+
  1306. 'animation: spin 2s infinite linear'
  1307. )+'}'
  1308. ], {id:'ubrHider'}, true);
  1309.  
  1310. // display content of a page if time to load a page is more than 2 seconds to avoid
  1311. // blocking access to a page if it is loading for too long or stuck in a loading state
  1312. setTimeout(2000, afterClean);
  1313. }
  1314.  
  1315. createStyle([
  1316. '#nav .use-ad { display: block !important }',
  1317. 'article:not(.post) + article:not(#id), a[target="_blank"] img[height="90"] { display: none !important }'
  1318. ]);
  1319.  
  1320. if (!isForum) {
  1321. beforeClean();
  1322. }
  1323.  
  1324. // save links to non-overridden functions to use later
  1325. var protectedElems;
  1326. // protect/hide changed attributes in case site attempt to restore them
  1327. function styleProtector(eventMode) {
  1328. var isStyleText = function(t){ return t === 'style'; },
  1329. returnUndefined = function(){},
  1330. protectedElems = new WeakMap();
  1331. function protoOverride(element, functionName, isStyleCheck, returnIfProtected) {
  1332. var oF = element.prototype[functionName], r;
  1333. element.prototype[functionName] = function() {
  1334. if (protectedElems.has(this) && isStyleCheck(arguments[0])) {
  1335. return returnIfProtected(this, arguments);
  1336. }
  1337. r = oF.apply(this, arguments);
  1338. return r;
  1339. };
  1340. }
  1341. protoOverride(Element, 'removeAttribute', isStyleText, returnUndefined);
  1342. protoOverride(Element, 'hasAttribute', isStyleText, function(_this) {
  1343. return protectedElems.get(_this) !== null;
  1344. });
  1345. protoOverride(Element, 'setAttribute', isStyleText, function(_this, args) {
  1346. protectedElems.set(_this, args[1]);
  1347. });
  1348. protoOverride(Element, 'getAttribute', isStyleText, function(_this) {
  1349. return protectedElems.get(_this);
  1350. });
  1351. if (eventMode) {
  1352. var e = document.createEvent('Event');
  1353. e.initEvent('protoOverride', false, false);
  1354. window.protectedElems = protectedElems;
  1355. window.dispatchEvent(e);
  1356. } else {
  1357. return protectedElems;
  1358. }
  1359. }
  1360. if (isFirefox) {
  1361. var s = document.createElement('script');
  1362. s.textContent = '(' + styleProtector.toString() + ')(true);';
  1363. window.addEventListener('protoOverride', function protoOverrideCallback(e){
  1364. if (win.protectedElems) {
  1365. protectedElems = win.protectedElems;
  1366. delete win.protectedElems;
  1367. }
  1368. document.removeEventListener('protoOverride', protoOverrideCallback, true);
  1369. }, true);
  1370. _appendChild(s);
  1371. _removeChild(s);
  1372. } else {
  1373. protectedElems = styleProtector(false);
  1374. }
  1375.  
  1376. // clean a page
  1377. window.addEventListener('DOMContentLoaded', function(){
  1378. var rem, si, itm;
  1379. function width(){ return window.innerWidth||_de.clientWidth||document.body.clientWidth||0; }
  1380. function height(){ return window.innerHeight||_de.clientHeight||document.body.clientHeight||0; }
  1381.  
  1382.  
  1383. if (isForum) {
  1384. si = document.querySelector('#logostrip');
  1385. if (si) {
  1386. remove(si.parentNode.nextSibling);
  1387. }
  1388. }
  1389.  
  1390. if (document.location.href.search('/forum/dl/') !== -1) {
  1391. document.body.setAttribute('style', (document.body.getAttribute('style')||'')+
  1392. ';background-color:black!important');
  1393. for (itm of document.querySelectorAll('body>div')) {
  1394. if (!itm.querySelector('.dw-fdwlink')) {
  1395. remove(itm);
  1396. }
  1397. }
  1398. }
  1399.  
  1400. if (isForum) { // Do not continue if it's a forum
  1401. return;
  1402. }
  1403.  
  1404. si = document.querySelector('#header');
  1405. if (si) {
  1406. rem = si.previousSibling;
  1407. while (rem) {
  1408. si = rem.previousSibling;
  1409. remove(rem);
  1410. rem = si;
  1411. }
  1412. }
  1413.  
  1414. for (itm of document.querySelectorAll('#nav li[class]')) {
  1415. if (itm && itm.querySelector('a[href^="/tag/"]')) {
  1416. remove(itm);
  1417. }
  1418. }
  1419.  
  1420. var style, result, fakeStyle,
  1421. fakeStyles = new WeakMap(),
  1422. styleProxy = {
  1423. get: function(target, prop) {
  1424. fakeStyle = fakeStyles.get(target);
  1425. if (fakeStyle.hasOwnProperty(prop)) {
  1426. return fakeStyle[prop];
  1427. } else {
  1428. return target[prop];
  1429. }
  1430. },
  1431. set: function(target, prop, value) {
  1432. fakeStyle = fakeStyles.get(target);
  1433. if (fakeStyle.hasOwnProperty(prop)) {
  1434. fakeStyle[prop] = value;
  1435. } else {
  1436. target[prop] = value;
  1437. }
  1438. return value;
  1439. }
  1440. };
  1441. for (itm of document.querySelectorAll('DIV, A')) {
  1442. if (itm.tagName ==='DIV' && itm.offsetWidth > 0.95 * width() && itm.offsetHeight > 0.85 * height()) {
  1443. style = window.getComputedStyle(itm, null);
  1444. result = [];
  1445. if (style.backgroundImage !== 'none') {
  1446. result.push('background-image:none!important');
  1447. }
  1448. if (style.backgroundColor !== 'transparent' &&
  1449. style.backgroundColor !== 'rgba(0, 0, 0, 0)') {
  1450. result.push('background-color:transparent!important');
  1451. }
  1452. if (result.length) {
  1453. if (itm.getAttribute('style')) {
  1454. result.unshift(itm.getAttribute('style'));
  1455. }
  1456. fakeStyles.set(itm.style, {
  1457. 'backgroundImage': itm.style.backgroundImage,
  1458. 'backgroundColor': itm.style.backgroundColor
  1459. });
  1460. try {
  1461. Object.defineProperty(itm, 'style', {
  1462. value: new Proxy(itm.style, styleProxy),
  1463. enumerable: true
  1464. });
  1465. } catch (e) {
  1466. console.log('Unable to protect style property.', e);
  1467. }
  1468. if (protectedElems) {
  1469. protectedElems.set(itm, _getAttribute.call(itm, 'style'));
  1470. }
  1471. _setAttribute.call(itm, 'style', result.join(';'));
  1472. }
  1473. }
  1474. if (itm.tagName ==='A' && (itm.offsetWidth > 0.95 * width() || itm.offsetHeight > 0.85 * height())) {
  1475. if (protectedElems) {
  1476. protectedElems.set(itm, _getAttribute.call(itm, 'style'));
  1477. }
  1478. _setAttribute.call(itm, 'style', 'display:none!important');
  1479. }
  1480. }
  1481.  
  1482. for (itm of document.querySelectorAll('ASIDE>DIV')) {
  1483. if ( ((itm.querySelector('script, iframe, a[href*="/ad/www/"]') ||
  1484. itm.querySelector('img[src$=".gif"]:not([height="0"]), img[height="400"]')) &&
  1485. !itm.classList.contains('post') ) || !itm.childNodes.length ) {
  1486. remove(itm);
  1487. }
  1488. }
  1489.  
  1490. document.body.setAttribute('style', (document.body.getAttribute('style')||'')+';background-color:#E6E7E9!important');
  1491.  
  1492. // display content of the page
  1493. afterClean();
  1494. });
  1495. }
  1496. };
  1497.  
  1498. scripts['allmovie.pro'] = function() {
  1499. // pretend to be Android to make site use different played for ads
  1500. if (isSafari) {
  1501. return;
  1502. }
  1503. Object.defineProperty(navigator, 'userAgent', {
  1504. get: function(){ return 'Mozilla/5.0 (Linux; Android 4.1.1; Nexus 7 Build/JRO03D) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.166 Safari/535.19'; },
  1505. enumerable: true
  1506. });
  1507. };
  1508. scripts['rufilmtv.org'] = scripts['allmovie.pro'];
  1509.  
  1510. scripts['anidub-online.ru'] = function() {
  1511. var script = document.createElement('script');
  1512. script.type = "text/javascript";
  1513. script.innerHTML = "function ogonekstart1() {}";
  1514. document.getElementsByTagName('head')[0].appendChild(script);
  1515.  
  1516. var style = document.createElement('style');
  1517. style.type = 'text/css';
  1518. style.appendChild(document.createTextNode('.background {background: none!important;}'));
  1519. style.appendChild(document.createTextNode('.background > script + div, .background > script ~ div:not([id]):not([class]) + div[id][class] {display:none!important}'));
  1520. document.head.appendChild(style);
  1521. };
  1522. scripts['online.anidub.com'] = scripts['anidub-online.ru'];
  1523.  
  1524. scripts['fs.to'] = function() {
  1525. function skipClicker(i) {
  1526. if (!i) {
  1527. return;
  1528. }
  1529. var skip = document.querySelector('.b-aplayer-banners__close');
  1530. if (skip) {
  1531. skip.click();
  1532. } else {
  1533. setTimeout(skipClicker, 100, i-1);
  1534. }
  1535. }
  1536. setTimeout(skipClicker, 100, 30);
  1537.  
  1538. createStyle([
  1539. '.l-body-branding *,'+
  1540. '.b-styled__item-central,'+
  1541. '.b-styled__content-right,'+
  1542. '.b-styled__section-central,'+
  1543. 'div[id^="adsProxy-"]'+
  1544. '{display:none!important}',
  1545. 'body {background-image:url(data:image/png;base64,'+
  1546. 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAACX'+
  1547. 'BIWXMAAC4jAAAuIwF4pT92AAAADUlEQVR42mOQUdL5DwACMgFq'+
  1548. 'BC3ttwAAAABJRU5ErkJggg==)!important}'
  1549. ]);
  1550.  
  1551. if (/\/(view_iframe|iframeplayer)\//i.test(document.location.pathname)) {
  1552. var p = document.querySelector('#player:not([preload="auto"])'),
  1553. m = document.querySelector('.main'),
  1554. adStepper = function(p) {
  1555. if (p.currentTime < p.duration) {
  1556. p.currentTime += 1;
  1557. }
  1558. },
  1559. adSkipper = function(f, p) {
  1560. f.click();
  1561. p.waitAfterSkip = false;
  1562. p.longerSkipper = false;
  1563. console.log('Пропустили.');
  1564. },
  1565. cl = function(p) {
  1566. var faster = document.querySelector('.b-aplayer__html5-desktop-skip'),
  1567. series = document.querySelector('.b-aplayer__actions-series');
  1568.  
  1569. function clickSelected() {
  1570. var s = document.querySelector('.b-aplayer__popup-series-episodes .selected a');
  1571. if (s) {
  1572. s.click();
  1573. }
  1574. }
  1575.  
  1576. if ((!faster || faster.style.display !== 'block') && series && !p.seriesClicked) {
  1577. series.click();
  1578. p.seriesClicked = true;
  1579. p.longerSkipper = true;
  1580. setTimeout(clickSelected, 1000);
  1581. p.pause();
  1582. }
  1583.  
  1584. function skipListener() {
  1585. if (p.waitAfterSkip) {
  1586. console.log('В процессе пропуска…');
  1587. return;
  1588. }
  1589. p.pause();
  1590. if (!p.classList.contains('m-hidden')) {
  1591. p.classList.add('m-hidden');
  1592. }
  1593. if (faster && p.currentTime &&
  1594. win.getComputedStyle(faster).display === 'block' &&
  1595. !faster.querySelector('.b-aplayer__html5-desktop-skip-timer')) {
  1596. p.waitAfterSkip = true;
  1597. setTimeout(adSkipper, (p.longerSkipper?3:1)*1000, faster, p);
  1598. console.log('Доступен быстрый пропуск…');
  1599. } else {
  1600. setTimeout(adStepper, 1000, p);
  1601. }
  1602. }
  1603.  
  1604. p.addEventListener('timeupdate', skipListener, false);
  1605. };
  1606. if (p.nodeName === 'VIDEO') {
  1607. cl(p);
  1608. } else {
  1609. (new MutationObserver(function (ms) {
  1610. var m, node;
  1611. for (m of ms) {
  1612. for (node of m.addedNodes) {
  1613. if (node.id === 'player' &&
  1614. node.nodeName === 'VIDEO' &&
  1615. _getAttribute.call(node, 'preload') !== 'auto') {
  1616. cl(node);
  1617. }
  1618. }
  1619. }
  1620. })).observe(m, {childList: true});
  1621. }
  1622. }
  1623. };
  1624. scripts['brb.to'] = scripts['fs.to'];
  1625. scripts['cxz.to'] = scripts['fs.to'];
  1626.  
  1627. scripts['drive2.ru'] = function() {
  1628. gardener('.c-block:not([data-metrika="recomm"]),.o-grid__item', />Реклама<\//i);
  1629. };
  1630.  
  1631. scripts['fishki.net'] = function() {
  1632. gardener('.drag_list > .drag_element, .list-view > .paddingtop15, .post-wrap', /543769|Новости\sпартнеров/);
  1633. };
  1634.  
  1635. scripts['gidonline.club'] = {
  1636. 'now': function() {
  1637. createStyle('.tray > div[style] {display: none!important}');
  1638. }
  1639. };
  1640. scripts['gidonlinekino.com'] = scripts['gidonline.club'];
  1641.  
  1642. scripts['hdgo.cc'] = {
  1643. 'now': function(){
  1644. (new MutationObserver(function(ms) {
  1645. var m, node;
  1646. for (m of ms) {
  1647. for (node of m.addedNodes) {
  1648. if (node.tagName === 'SCRIPT' && _getAttribute(node, 'onerror') !== null) {
  1649. node.removeAttribute('onerror');
  1650. }
  1651. }
  1652. }
  1653. })).observe(document, {childList:true, subtree: true});
  1654. }
  1655. };
  1656. scripts['couber.be'] = scripts['hdgo.cc'];
  1657. scripts['46.30.43.38'] = scripts['hdgo.cc'];
  1658.  
  1659. scripts['gismeteo.ru'] = {
  1660. 'DOMContentLoaded': function() {
  1661. gardener('div > a[target^="_"]', /Яндекс\.Директ/i, { root: 'body', observe: true, parent: 'div[class*="frame"]' });
  1662. }
  1663. };
  1664.  
  1665. scripts['hdrezka.me'] = {
  1666. 'now': function() {
  1667. Object.defineProperty(win, 'fuckAdBlock', {
  1668. value: {
  1669. onDetected: function() {
  1670. console.log('Pretending to be an ABP detector.');
  1671. }
  1672. }
  1673. });
  1674. Object.defineProperty(win, 'ab', {
  1675. value: false,
  1676. enumerable: true
  1677. });
  1678. },
  1679. 'DOMContentLoaded': function() {
  1680. gardener('div[id][onclick][onmouseup][onmousedown]', /onmouseout/i);
  1681. }
  1682. };
  1683.  
  1684. scripts['imageban.ru'] = {
  1685. 'now': preventBackgroundRedirect,
  1686. 'DOMContentLoaded': function() {
  1687. win.addEventListener('unload', function() {
  1688. if (!window.location.hash) {
  1689. window.location.replace(window.location+'#');
  1690. } else {
  1691. window.location.hash = '';
  1692. }
  1693. }, true);
  1694. }
  1695. };
  1696.  
  1697. scripts['e.mail.ru'] = function() {
  1698. /*gardener('#LEGO :not([data-mnemo])>.js-href[data-id]',
  1699. /data:image.*>Реклама<|>Реклама<.*\/\/favicon\./i,
  1700. {root:'#LEGO', observe: true, parent:'div[id][class]'});*/
  1701. };
  1702.  
  1703. scripts['mail.ru'] = {
  1704. 'now': function() {
  1705. // Trick to prevent mail.ru from removing 3rd-party styles
  1706. scriptLander(function(){
  1707. Object.defineProperty(Object.prototype, 'restoreVisibility', {
  1708. get: function() { return function(){}; },
  1709. set: function() {}
  1710. });
  1711. });
  1712. }
  1713. };
  1714.  
  1715. scripts['megogo.net'] = {
  1716. 'now': function() {
  1717. Object.defineProperty(win, "adBlock", {
  1718. value : false,
  1719. enumerable : true
  1720. });
  1721. Object.defineProperty(win, "showAdBlockMessage", {
  1722. value : function () {},
  1723. enumerable : true
  1724. });
  1725. }
  1726. };
  1727.  
  1728. scripts['naruto-base.su'] = function() {
  1729. gardener('div[id^="entryID"],.block', /href="http.*?target="_blank"/i);
  1730. };
  1731.  
  1732. scripts['overclockers.ru'] = {
  1733. 'now': function() {
  1734. createStyle('.fixoldhtml {display:block!important}');
  1735. if (!isChrome && !isOpera) {
  1736. return; // Looks like my code works only in Chrome-like browsers
  1737. }
  1738. var noContentYet = true;
  1739. function jWrap() {
  1740. var _$ = win.$, _e = _$.extend;
  1741. win.$ = function() {
  1742. var _ret = _$.apply(window, arguments);
  1743. if (_ret[0] === document.body) {
  1744. _ret.html = function() {
  1745. console.log('Anti-adblock prevented.');
  1746. };
  1747. }
  1748. return _ret;
  1749. };
  1750. win.$.extend = function() {
  1751. return _e.apply(_$, arguments);
  1752. };
  1753. win.jQuery = win.$;
  1754. }
  1755. (function jReady() {
  1756. if (!win.$ && noContentYet) {
  1757. setTimeout(jReady, 0);
  1758. } else {
  1759. jWrap();
  1760. }
  1761. })();
  1762. document.addEventListener ('DOMContentLoaded', function(){
  1763. noContentYet = false;
  1764. }, false);
  1765. }
  1766. };
  1767. scripts['forums.overclockers.ru'] = {
  1768. 'now': function() {
  1769. createStyle('.needblock {position: fixed; left: -10000px}');
  1770. Object.defineProperty(win, 'adblck', {
  1771. value: 'no',
  1772. enumerable: true
  1773. });
  1774. }
  1775. };
  1776.  
  1777. scripts['pb.wtf'] = function() {
  1778. createStyle('.reques,#result,tbody.row1:not([id]) {display: none !important}');
  1779. // image in the slider in the header
  1780. gardener('a[href$="=="]', /img/i, {root:'.release-navbar', observe:true, parent:'div'});
  1781. // ads in blocks on the page
  1782. gardener('a[href^="/"]', /<img\s.*<br>/i, {root:'#main_content', observe:true, parent:'div[class]'});
  1783. // line above topic content
  1784. gardener('.re_top1', /./, {root:'#main_content', parent:'.hidden-sm'});
  1785. };
  1786. scripts['piratbit.org'] = scripts['pb.wtf'];
  1787. scripts['piratbit.ru'] = scripts['pb.wtf'];
  1788.  
  1789. scripts['pikabu.ru'] = function() {
  1790. gardener('.story', /story__sponsor|story__gag|profile\/ads"/i, {root: '.inner_wrap', observe: true});
  1791. };
  1792.  
  1793. scripts['rp5.ru'] = function() {
  1794. createStyle('#bannerBottom {display: none!important}');
  1795. var co = document.querySelector('#content'), i, nodes;
  1796. if (!co) {
  1797. return;
  1798. }
  1799. nodes = co.parentNode.childNodes;
  1800. i = nodes.length;
  1801. while (i--) {
  1802. if (nodes[i] !== co) {
  1803. nodes[i].parentNode.removeChild(nodes[i]);
  1804. }
  1805. }
  1806. };
  1807. scripts['rp5.by'] = scripts['rp5.ru'];
  1808. scripts['rp5.ua'] = scripts['rp5.ru'];
  1809.  
  1810. scripts['rustorka.com'] = {
  1811. 'now': function() {
  1812. createStyle('.header > div:not(.head-block) a, #sidebar1 img, #logo img {opacity:0!important}', {
  1813. id: 'tempHidingStyles'
  1814. }, true);
  1815. preventPopups();
  1816. },
  1817. 'DOMContentLoaded': function() {
  1818. for (var o of document.querySelectorAll('IMG, A')) {
  1819. if ((o.clientWidth === 728 && o.clientHeight === 90) ||
  1820. (o.clientWidth === 300 && o.clientHeight === 250)) {
  1821. while (o && o.tagName !== 'A') {
  1822. o = o.parentNode;
  1823. }
  1824. if (o) {
  1825. _setAttribute.call(o, 'style', 'display: none !important');
  1826. }
  1827. }
  1828. }
  1829. var s = document.querySelector('#tempHidingStyles');
  1830. s.parentNode.removeChild(s);
  1831. }
  1832. };
  1833. scripts['rumedia.ws'] = scripts['rustorka.com'];
  1834.  
  1835. scripts['sport-express.ru'] = function() {
  1836. gardener('.js-relap__item',/>Реклама\s+<\//, {root:'.container', observe: true});
  1837. };
  1838.  
  1839. scripts['sports.ru'] = function() {
  1840. gardener('.aside-news-list__item', /aside-news-list__advert/i, {root:'.columns-layout__left', observe: true});
  1841. gardener('.material-list__item', /Реклама/i, {root:'.columns-layout', observe: true});
  1842. // extra functionality: shows/hides panel at the top depending on scroll direction
  1843. createStyle([
  1844. '.user-panel__fixed { transition: top 0.2s ease-in-out!important; }',
  1845. '.user-panel-up { top: -40px!important }'
  1846. ], {id: 'userPanelSlide'}, false);
  1847. (function lookForPanel() {
  1848. var panel = document.querySelector('.user-panel__fixed');
  1849. if (!panel) {
  1850. setTimeout(lookForPanel, 100);
  1851. } else {
  1852. window.addEventListener('wheel', function(e){
  1853. if (e.deltaY > 0 && !panel.classList.contains('user-panel-up')) {
  1854. panel.classList.add('user-panel-up');
  1855. } else
  1856. if (e.deltaY < 0 && panel.classList.contains('user-panel-up')) {
  1857. panel.classList.remove('user-panel-up');
  1858. }
  1859. }, false);
  1860. }
  1861. })();
  1862. };
  1863.  
  1864. scripts['www.ukr.net'] = scripts['sinoptik.com.ru'];
  1865.  
  1866. scripts['vk.com'] = function() {
  1867. gardener('div[data-post-id]', /wall_marked_as_ads/, {root: '#page_wall_posts', observe: true});
  1868. };
  1869.  
  1870. scripts['yap.ru'] = function() {
  1871. var words = /member1438|Administration|\/go\/?.*yplkl\.php/;
  1872. gardener('form > table[id^="p_row_"]:nth-of-type(2)', words);
  1873. gardener('tr > .holder.newsbottom', words, {parent:'tr', siblings:-2});
  1874. };
  1875. scripts['yaplakal.com'] = scripts['yap.ru'];
  1876.  
  1877. scripts['rambler.ru'] = {
  1878. 'now': function() {
  1879. scriptLander(function() {
  1880. var _createElement = Document.prototype.createElement,
  1881. loadMap = new WeakMap();
  1882. Document.prototype.createElement = function createElement(name) {
  1883. /*jshint validthis:true */
  1884. var el = _createElement.apply(this, arguments);
  1885. if (el.tagName === 'LINK') {
  1886. Object.defineProperty(el, 'onload', {
  1887. get: function() {
  1888. return loadMap.get(loadMap.get(this));
  1889. },
  1890. set: function(func) {
  1891. var wrap = loadMap.get(this),
  1892. isContent = /\{\s*content\s*:\s*"[^"]+"/i;
  1893. if (wrap) {
  1894. this.removeEventListener('load', wrap, false);
  1895. loadMap.remove(wrap);
  1896. loadMap.remove(this);
  1897. }
  1898. wrap = function(e) {
  1899. if (e.target && e.target.sheet && e.target.sheet.cssRules &&
  1900. e.target.sheet.cssRules[0] && e.target.sheet.cssRules[0].cssText &&
  1901. isContent.test(e.target.sheet.cssRules[0].cssText)) {
  1902. console.log('Blocked "onload" for', e.target.href);
  1903. return false;
  1904. }
  1905. return func.apply(this, arguments);
  1906. };
  1907. loadMap.set(this, wrap);
  1908. loadMap.set(wrap, func);
  1909. this.addEventListener('load', wrap, false);
  1910. },
  1911. enumberable: true
  1912. });
  1913. }
  1914. return el;
  1915. };
  1916. });
  1917. }
  1918. };
  1919.  
  1920. scripts['reactor.cc'] = {
  1921. 'now': function() {
  1922. win.open = (function(){ throw new Error('Redirect prevention.'); }).bind(window);
  1923. },
  1924. 'click': function(e) {
  1925. var node = e.target;
  1926. if (node.nodeType === Node.ELEMENT_NODE &&
  1927. node.style.position === 'absolute' &&
  1928. node.style.zIndex > 0)
  1929. node.parentNode.removeChild(node);
  1930. },
  1931. 'DOMContentLoaded': function() {
  1932. var words = new RegExp(
  1933. 'блокировщика рекламы'
  1934. .split('')
  1935. .map(function(e){return e+'[\u200b\u200c\u200d]*';})
  1936. .join('')
  1937. .replace(' ', '\\s*')
  1938. .replace(/[аоре]/g, function(e){return ['[аa]','[оo]','[рp]','[еe]']['аоре'.indexOf(e)];}),
  1939. 'i'),
  1940. can;
  1941. function deeper(spider) {
  1942. var c, l, n;
  1943. if (words.test(spider.innerText)) {
  1944. if (spider.nodeType === Node.TEXT_NODE) {
  1945. return true;
  1946. }
  1947. c = spider.childNodes;
  1948. l = c.length;
  1949. n = 0;
  1950. while(l--) {
  1951. if (deeper(c[l]), can) {
  1952. n++;
  1953. }
  1954. }
  1955. if (n > 0 && n === c.length && spider.offsetHeight < 750) {
  1956. can.push(spider);
  1957. }
  1958. return false;
  1959. }
  1960. return true;
  1961. }
  1962. function probe(){
  1963. if (words.test(document.body.innerText)) {
  1964. can = [];
  1965. deeper(document.body);
  1966. var i = can.length, spider;
  1967. while(i--) {
  1968. spider = can[i];
  1969. if (spider.offsetHeight > 10 && spider.offsetHeight < 750) {
  1970. _setAttribute.call(spider, 'style', 'background:none!important');
  1971. }
  1972. }
  1973. }
  1974. }
  1975. (new MutationObserver(probe)).observe(document,{childList:true, subtree:true});
  1976. }
  1977. };
  1978. scripts['joyreactor.cc'] = scripts['reactor.cc'];
  1979. scripts['pornreactor.cc'] = scripts['reactor.cc'];
  1980.  
  1981. scripts['auto.ru'] = function() {
  1982. var words = /Реклама|Яндекс.Директ|yandex_ad_/;
  1983. var userAdsListAds = [
  1984. '.listing-list > .listing-item',
  1985. '.listing-item_type_fixed.listing-item'
  1986. ];
  1987. var catalogAds = [
  1988. 'div[class*="layout_catalog-inline"]',
  1989. 'div[class$="layout_horizontal"]'
  1990. ];
  1991. var otherAds = [
  1992. '.advt_auto',
  1993. '.sidebar-block',
  1994. '.pager-listing + div[class]',
  1995. '.card > div[class][style]',
  1996. '.sidebar > div[class]',
  1997. '.main-page__section + div[class]',
  1998. '.listing > tbody'];
  1999. gardener(userAdsListAds.join(','), words, {root:'.listing-wrap', observe:true});
  2000. gardener(catalogAds.join(','), words, {root:'.catalog__page,.content__wrapper', observe:true});
  2001. gardener(otherAds.join(','), words);
  2002. };
  2003.  
  2004. scripts['rsload.net'] = {
  2005. 'load': function() {
  2006. var dis = document.querySelector('label[class*="cb-disable"]');
  2007. if (dis) {
  2008. dis.click();
  2009. }
  2010. },
  2011. 'click': function(e) {
  2012. var t = e.target;
  2013. if (t && t.href && (/:\/\/\d+\.\d+\.\d+\.\d+\//.test(t.href))) {
  2014. t.href = t.href.replace('://','://rsload.net:rsload.net@');
  2015. }
  2016. }
  2017. };
  2018.  
  2019. var domain = document.domain, name;
  2020. while (domain.indexOf('.') !== -1) {
  2021. if (scripts.hasOwnProperty(domain)) {
  2022. if (typeof scripts[domain] === 'function') {
  2023. document.addEventListener ('DOMContentLoaded', scripts[domain], false);
  2024. }
  2025. for (name in scripts[domain]) {
  2026. if (name !== 'now') {
  2027. (name === 'load' ? window : document)
  2028. .addEventListener (name, scripts[domain][name], false);
  2029. } else {
  2030. scripts[domain][name]();
  2031. }
  2032. }
  2033. }
  2034. domain = domain.slice(domain.indexOf('.') + 1);
  2035. }
  2036. })();