RU AdList JS Fixes

try to take over the world!

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

  1. // ==UserScript==
  2. // @name RU AdList JS Fixes
  3. // @namespace ruadlist_js_fixes
  4. // @version 20170510.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. var o = new MutationObserver(function() {
  186. root.removeChild(style);
  187. });
  188. o.observe(style, {childList: true});
  189. }
  190.  
  191. function _create() {
  192. var style = root.appendChild(document.createElement('style')),
  193. prop, rule;
  194. style.type = 'text/css';
  195. for (prop in props) {
  196. if (style[prop] !== undefined) {
  197. style[prop] = props[prop];
  198. }
  199. }
  200. function insertRule(rule) {
  201. try {
  202. style.sheet.insertRule(rule, 0);
  203. } catch (e) {
  204. console.error(e);
  205. }
  206. }
  207. if (typeof rules === 'string') {
  208. insertRule(rules);
  209. } else {
  210. rules.forEach(insertRule);
  211. }
  212. if (!skip_protect) {
  213. _protect(style);
  214. }
  215. return style;
  216. }
  217.  
  218. var style = _create();
  219. if (skip_protect) {
  220. return style;
  221. }
  222.  
  223. var o = new MutationObserver(function(ms){
  224. var m, node, rule;
  225. for (m of ms) {
  226. for (node of m.removedNodes) {
  227. if (node === style) {
  228. (new Promise(function(resolve){
  229. setTimeout(function(resolve){
  230. resolve(_create());
  231. }, 0, resolve);
  232. })).then(function(st){
  233. style = st;
  234. });
  235. }
  236. }
  237. }
  238. });
  239. o.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. var observer = 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. });
  636.  
  637. observer.observe(document, { childList : true, attributes : true, attributeFilter : ['style'], subtree : true });
  638.  
  639. win.addEventListener ("load", function(){
  640. var c = 0, imp;
  641. for (imp of document.querySelectorAll('[style*="!"]')) {
  642. c+= checkTarget(imp, c);
  643. }
  644. logger(c);
  645. }, false);
  646. })();
  647.  
  648. }
  649.  
  650. if (/^https?:\/\/(mail\.yandex\.|music\.yandex\.|news\.yandex\.|(www\.)?yandex\.[^\/]+\/(yand)?search[\/?])/i.test(win.location.href)) {
  651. // https://greasyfork.org/en/scripts/809-no-yandex-ads
  652. (function(){
  653. var adWords = ['Яндекс.Директ','Реклама','Ad'];
  654. function remove(node) {
  655. node.parentNode.removeChild(node);
  656. }
  657. // Generic ads removal and fixes
  658. function removeGenericAds() {
  659. var s, i;
  660. s = document.querySelector('.serp-header');
  661. if (s) {
  662. s.style.marginTop='0';
  663. }
  664. for (s of document.querySelectorAll('.serp-adv__head + .serp-item, #adbanner, .serp-adv, .b-spec-adv, div[class*="serp-adv__"]:not(.serp-adv__found):not(.serp-adv__displayed)')) {
  665. remove(s);
  666. }
  667. }
  668. // Search ads
  669. function removeSearchAds() {
  670. var s, item, l;
  671. for (s of document.querySelectorAll('.t-construct-adapter__legacy')) {
  672. item = s.querySelector('.organic__subtitle');
  673. l = window.getComputedStyle(item, ':after').content;
  674. if (item && adWords.indexOf(l.replace(/"/g,'')) > -1) {
  675. remove(s);
  676. console.log('Ads removed.');
  677. }
  678. }
  679. }
  680. // News ads
  681. function removeNewsAds() {
  682. for (var s of document.querySelectorAll(
  683. '.page-content__left > *,'+
  684. '.page-content__right > *:not(.page-content__col),'+
  685. '.page-content__right > .page-content__col > *'
  686. )) {
  687. if (s.textContent.indexOf(adWords[0]) > -1 ||
  688. (s.clientHeight < 15 && s.classList.contains('rubric'))) {
  689. remove(s);
  690. console.log('Ads removed.');
  691. }
  692. }
  693. }
  694. // Music ads
  695. function removeMusicAds() {
  696. for (var s of document.querySelectorAll('.ads-block')) {
  697. remove(s);
  698. }
  699. }
  700. // Mail ads
  701. function removeMailAds() {
  702. var slice = Array.prototype.slice,
  703. nodes = slice.call(document.querySelectorAll('.ns-view-folders')),
  704. node, len, classes, cls;
  705. for (node of nodes) {
  706. if (!len || len > node.classList.length) {
  707. len = node.classList.length;
  708. }
  709. }
  710. node = nodes.pop();
  711. while (node) {
  712. if (node.classList.length > len) {
  713. for (cls of slice.call(node.classList)) {
  714. if (cls.indexOf('-') === -1) {
  715. remove(node);
  716. break;
  717. }
  718. }
  719. }
  720. node = nodes.pop();
  721. }
  722. }
  723. // News fixes
  724. function removePageAdsClass() {
  725. if (document.body.classList.contains("b-page_ads_yes")){
  726. document.body.classList.remove("b-page_ads_yes");
  727. console.log('Page ads class removed.');
  728. }
  729. }
  730. // Function to attach an observer to monitor dynamic changes on the page
  731. function pageUpdateObserver(func, obj, params) {
  732. if (obj) {
  733. var o = new MutationObserver(func);
  734. o.observe(obj,(params || {childList:true, subtree:true}));
  735. }
  736. }
  737. // Cleaner
  738. document.addEventListener ('DOMContentLoaded', function() {
  739. removeGenericAds();
  740. if (win.location.hostname.search(/^mail\./i) === 0) {
  741. pageUpdateObserver(function(ms, o){
  742. var aside = document.querySelector('.mail-Layout-Aside');
  743. if (aside) {
  744. o.disconnect();
  745. pageUpdateObserver(removeMailAds, aside);
  746. }
  747. }, document.querySelector('BODY'));
  748. removeMailAds();
  749. } else if (win.location.hostname.search(/^music\./i) === 0) {
  750. pageUpdateObserver(removeMusicAds, document.querySelector('.sidebar'));
  751. removeMusicAds();
  752. } else if (win.location.hostname.search(/^news\./i) === 0) {
  753. pageUpdateObserver(removeNewsAds, document.querySelector('BODY'));
  754. pageUpdateObserver(removePageAdsClass, document.body, {attributes:true, attributesFilter:['class']});
  755. removeNewsAds();
  756. removePageAdsClass();
  757. } else {
  758. pageUpdateObserver(removeSearchAds, document.querySelector('.main__content'));
  759. removeSearchAds();
  760. }
  761. });
  762. })();
  763. }
  764. // Yandex Link Tracking
  765. if (/^https?:\/\/([^.]+\.)*yandex\.[^\/]+/i.test(win.location.href)) {
  766. // Partially based on https://greasyfork.org/en/scripts/22737-remove-yandex-redirect
  767. (function(){
  768. var link;
  769. function removeTracking(scope) {
  770. for (link of scope.querySelectorAll('A')) {
  771. if (link.hasAttribute('onmousedown') &&
  772. /\/jsredir/i.test(link.getAttribute('onmousedown'))) {
  773. link.removeAttribute('onmousedown');
  774. }
  775. if (link.hasAttribute('data-vdir-href')) {
  776. link.removeAttribute('data-vdir-href');
  777. link.removeAttribute('data-orig-href');
  778. }
  779. link.removeAttribute('data-counter');
  780. link.removeAttribute('data-bem');
  781. }
  782. }
  783. removeTracking(_de);
  784. var o = new MutationObserver(function(ms) {
  785. var m, node;
  786. for (m of ms) {
  787. for (node of m.addedNodes) {
  788. if (node.nodeType === Node.ELEMENT_NODE) {
  789. removeTracking(node);
  790. }
  791. }
  792. }
  793. });
  794. o.observe(_de, {childList: true, subtree: true});
  795. })();
  796. return; //skip fixes for other sites
  797. }
  798.  
  799. // https://greasyfork.org/en/scripts/21937-moonwalk-hdgo-kodik-fix v0.8 (adapted)
  800. document.addEventListener ('DOMContentLoaded', function() {
  801. var tmp;
  802. function log (e) {
  803. console.log('Moonwalk&HDGo&Kodik FIX: ' + e + ' player in ' + win.location.href);
  804. }
  805. if (win.adv_enabled !== undefined && win.condition_detected !== undefined) { // moonwalk
  806. log('Moonwalk');
  807. if (win.adv_enabled) {
  808. win.adv_enabled = false;
  809. }
  810. win.condition_detected = false;
  811. if (win.MXoverrollCallback) {
  812. document.addEventListener('click', function catcher(e){
  813. e.stopPropagation();
  814. win.MXoverrollCallback.call(window);
  815. document.removeEventListener('click', catcher, true);
  816. }, true);
  817. }
  818. } else if (win.stat_url !== undefined && win.is_html5 !== undefined && win.is_wp8 !== undefined) { // hdgo
  819. log('HDGo');
  820. document.body.onclick = null;
  821. tmp = document.querySelector('#swtf');
  822. if (tmp) {
  823. tmp.style.display = 'none';
  824. }
  825. if (win.banner_second !== undefined) {
  826. win.banner_second = 0;
  827. }
  828. if (win.$banner_ads !== undefined) {
  829. win.$banner_ads = false;
  830. }
  831. if (win.$new_ads !== undefined) {
  832. win.$new_ads = false;
  833. }
  834. if (win.createCookie !== undefined) {
  835. win.createCookie('popup','true','999');
  836. }
  837. if (win.canRunAds !== undefined && win.canRunAds !== true) {
  838. win.canRunAds = true;
  839. }
  840. } else if (win.MXoverrollCallback && win.iframeSearch !== undefined) { // kodik
  841. log('Kodik');
  842. tmp = document.querySelector('.play_button');
  843. if (tmp) {
  844. tmp.onclick = win.MXoverrollCallback.bind(window);
  845. }
  846. win.IsAdBlock = false;
  847. }
  848. }, false);
  849.  
  850. // Automated protection against specific circumvention method based on unwrapping various functions,
  851. // hiding ads in the Shadow DOM and injecting iFrames with ads. Previously this code were known as
  852. // apiBreaker since it were breaking Shadow DOM and onerror/onload API on specific domains. This
  853. // version should be safe enough to run on majority of sites without actually breaking them.
  854. scriptLander(function() {
  855. var blacklist = new WeakMap(),
  856. replacer, func;
  857. /* Wrap functions used to attach shadow root to a node */
  858. replacer = function (func) {
  859. return function() {
  860. blacklist.set(this, true);
  861. return func.apply(this, arguments);
  862. };
  863. };
  864. for (func of ['createShadowRoot', 'attachShadow']) {
  865. if (func in Element.prototype) {
  866. Element.prototype[func] = replacer(Element.prototype[func]);
  867. }
  868. }
  869. /* Wrap functions used to insert/append elements to check for IFRAME objects */
  870. replacer = function (func) {
  871. return function(el, par) {
  872. if (el.tagName === 'IFRAME' &&
  873. ((typeof par === 'object' && blacklist.get(par))/* ||
  874. el.style.display === 'none'*/)) {
  875. console.log('Blocked suspicious', func.name, arguments);
  876. return null;
  877. }
  878. return func.apply(this, arguments);
  879. };
  880. };
  881. for (func of [/*'appendChild', */'insertBefore']) {
  882. Object.defineProperty(Element.prototype, func, {
  883. value: replacer(Element.prototype[func]), enumerable: true
  884. });
  885. }
  886. });
  887.  
  888. // === Helper functions ===
  889.  
  890. // function to search and remove nodes by content
  891. // selector - standard CSS selector to define set of nodes to check
  892. // words - regular expression to check content of the suspicious nodes
  893. // params - object with multiple extra parameters:
  894. // .hide - set display to none instead of removing from the page
  895. // .parent - parent node to remove if content is found in the child node
  896. // .siblings - number of simling nodes to remove (excluding text nodes)
  897. function scRemove(e) {e.parentNode.removeChild(e);}
  898. function scHide(e) {
  899. var s = _getAttribute.call(e, 'style') || '',
  900. h = ';display:none!important;';
  901. if (s.indexOf(h) < 0) {
  902. _setAttribute.call(e, 'style', s+h);
  903. }
  904. }
  905. function scissors (selector, words, scope, params) {
  906. var remFunc = (params.hide ? scHide : scRemove),
  907. iterFunc = (params.siblings > 0 ?
  908. 'nextSibling' :
  909. 'previousSibling'),
  910. toRemove = [],
  911. siblings,
  912. node;
  913. for (node of scope.querySelectorAll(selector)) {
  914. if (params.parent) {
  915. while(node !== scope && !(node.matches(params.parent))) {
  916. node = node.parentNode;
  917. }
  918. }
  919. if (words.test(node.innerHTML) || !node.childNodes.length) {
  920. // drill up to the specified parent node if required
  921. if (node === scope) {
  922. break;
  923. }
  924. toRemove.push(node);
  925. // add multiple nodes if defined more than one sibling
  926. siblings = Math.abs(params.siblings) || 0;
  927. while (siblings) {
  928. node = node[iterFunc];
  929. toRemove.push(node);
  930. if (node.nodeType === Node.ELEMENT_NODE) {
  931. siblings -= 1; //count only element nodes
  932. }
  933. }
  934. }
  935. }
  936. for (node of toRemove) {
  937. remFunc(node);
  938. }
  939. return toRemove.length;
  940. }
  941.  
  942. // function to perform multiple checks if ads inserted with a delay
  943. // by default does 30 checks withing a 3 seconds unless nonstop mode specified
  944. // also does 1 extra check when a page completely loads
  945. // selector and words - passed dow to scissors
  946. // params - object with multiple extra parameters:
  947. // .root - selector to narrow down scope to scan;
  948. // .observe - if true then check will be performed continuously;
  949. // Other parameters passed down to scissors.
  950. function gardener(selector, words, params) {
  951. params = params || {};
  952. var scope = document,
  953. nonstop = false;
  954. // narrow down scope to a specific element
  955. if (params.root) {
  956. scope = scope.querySelector(params.root);
  957. if (!scope) {// exit if the root element is not present on the page
  958. return 0;
  959. }
  960. }
  961. // add observe mode if required
  962. if (params.observe) {
  963. if (typeof MutationObserver === 'function') {
  964. var o = new MutationObserver(function(ms){
  965. for (var m of ms) {
  966. if (m.addedNodes.length) {
  967. scissors(selector, words, scope, params);
  968. }
  969. }
  970. });
  971. o.observe(scope, {childList:true, subtree: true});
  972. } else {
  973. nonstop = true;
  974. }
  975. }
  976. // wait for a full page load to do one extra cut
  977. win.addEventListener('load',function(){
  978. scissors(selector, words, scope, params);
  979. });
  980. // do multiple cuts until ads removed
  981. function cut(sci, s, w, sc, p, i) {
  982. if (i > 0) {
  983. i -= 1;
  984. }
  985. if (i && !sci(s, w, sc, p)) {
  986. setTimeout(cut, 100, sci, s, w, sc, p, i);
  987. }
  988. }
  989. cut(scissors, selector, words, scope, params, (nonstop ? -1 : 30));
  990. }
  991.  
  992. // Helper function to close background tab if site opens itself in a new tab and then
  993. // loads a 3rd-party page in the background one (thus performing background redirect).
  994. function preventBackgroundRedirect() {
  995. // create "cose_me" event to call high-level window.close()
  996. var key = Math.random().toString(36).substr(2);
  997. window.addEventListener('close_me_'+key, function(e) {
  998. window.close();
  999. });
  1000.  
  1001. // window.open wrapper
  1002. function pbrLander() {
  1003. var orgOpen = window.open.bind(window),
  1004. idx = String.prototype.indexOf,
  1005. event = new CustomEvent("close_me_%key%", {});
  1006. function closeWindow(){
  1007. // site went to a new tab and attempts to unload
  1008. // call for high-level close through event
  1009. window.dispatchEvent(event);
  1010. }
  1011. // window.open wrapper
  1012. function open(){
  1013. console.log(arguments, window.location.host);
  1014. if (arguments[0] &&
  1015. (idx.call(arguments[0], window.location.host) > -1 ||
  1016. idx.call(arguments[0], '://') === -1)) {
  1017. window.addEventListener('unload', closeWindow, true);
  1018. }
  1019. orgOpen.apply(window, arguments);
  1020. }
  1021. window.open = open.bind(window);
  1022. // Node.createElement wrapper to prevent click-dispatch in Google Chrome and similar browsers
  1023. var realCreateElement = Document.prototype.createElement;
  1024. function wrappedCreateElement(name) {
  1025. /*jshint validthis:true */
  1026. var el = realCreateElement.apply(this, arguments);
  1027. if (el.tagName === 'A') {
  1028. el.addEventListener('click', function(e){
  1029. if (!e.target.parentNode || !e.isTrusted) {
  1030. window.addEventListener('unload', closeWindow, true);
  1031. }
  1032. }, false);
  1033. }
  1034. return el;
  1035. }
  1036. Document.prototype.createElement = wrappedCreateElement;
  1037. }
  1038.  
  1039. // land wrapper on the page
  1040. var script = document.createElement('script');
  1041. script.appendChild(document.createTextNode('('+pbrLander.toString().replace(/%key%/g,key)+')();'));
  1042. document.head.insertBefore(script, document.head.firstChild);
  1043. script.parentNode.removeChild(script);
  1044. console.log("Background redirect prevention enabled.");
  1045. }
  1046.  
  1047. // Function to catch and block various methods to open a new window with 3rd-party content.
  1048. // Some advertisement networks went way past simple window.open call to circumvent default popup protection.
  1049. // This funciton blocks window.open, ability to restore original window.open from an IFRAME object,
  1050. // ability to perform an untrusted (not initiated by user) click on a link, click on a link without a parent
  1051. // node or simply a link with piece of javascript code in the HREF attribute.
  1052. function preventPopups() {
  1053. function open(){
  1054. console.log('Site attempted to open a new window', arguments);
  1055. function nil(){}
  1056. return {
  1057. document: {
  1058. write: nil,
  1059. writeln: nil
  1060. }
  1061. };
  1062. }
  1063. win.open = exportFunction(open, win);
  1064.  
  1065. function wrapFunctions() {
  1066. var realCreateElement = Document.prototype.createElement,
  1067. realAppendChild = Element.prototype.appendChild;
  1068. Document.prototype.createElement = function createElement(name) {
  1069. /*jshint validthis:true */
  1070. var el = realCreateElement.apply(this, arguments);
  1071. if (el.tagName === 'A') {
  1072. el.addEventListener('click', function(e) {
  1073. if (!e.target.parentNode || !e.isTrusted ||
  1074. (e.target.href && e.target.href.toLowerCase().indexOf('javascript') > -1)) {
  1075. e.preventDefault();
  1076. console.log('Blocked suspicious click event', e, 'on', e.target);
  1077. }
  1078. }, false);
  1079. }
  1080. if (el.tagName === 'IFRAME') {
  1081. el.addEventListener('load', function(){
  1082. try {
  1083. this.contentWindow.open = open;
  1084. } catch(ignore) {}
  1085. }, false);
  1086. }
  1087. return el;
  1088. };
  1089. Element.prototype.appendChild = function appendChild() {
  1090. var child = realAppendChild.apply(this, arguments);
  1091. if (child && child.nodeType === Node.ELEMENT_NODE && child.tagName === 'IFRAME') {
  1092. try {
  1093. child.contentWindow.open = open;
  1094. } catch(ignore) {}
  1095. }
  1096. return child;
  1097. };
  1098. }
  1099.  
  1100. scriptLander(wrapFunctions, [open]);
  1101. }
  1102.  
  1103. // Currently unused piece of code developed to prevent site from registering serviceWorker
  1104. // and uninstall any existing instances of serivceWorker in case there is one already.
  1105. /* Commented out since not used
  1106. function forbidServiceWorker() {
  1107. if (!("serviceWorker" in navigator)) {
  1108. return;
  1109. }
  1110. var svr = navigator.serviceWorker.ready;
  1111. Object.defineProperty(navigator, 'serviceWorker', {
  1112. value: {
  1113. register: function(){
  1114. console.log('Registration of serviceWorker ' + arguments[0] + ' blocked.');
  1115. return new Promise(function(){});
  1116. },
  1117. ready: new Promise(function(){}),
  1118. addEventListener:function(){}
  1119. }
  1120. });
  1121. document.addEventListener('DOMContentLoaded', function() {
  1122. if (!svr) {
  1123. return;
  1124. }
  1125. svr.then(function(sw) {
  1126. console.log('Found existing serviceWorker:', sw);
  1127. console.log('Attempting to unregister...');
  1128. sw.unregister().then(function() {
  1129. console.log('Unregistered! :)');
  1130. }).catch(function(err) {
  1131. console.log('Unregistration failed. :(', err);
  1132. console.log('Try to remove it manually:');
  1133. console.log(' 1. Open: chrome://serviceworker-internals/ (Google Chrome and alike) or about:serviceworkers (Mozilla Firefox) in a new tab.');
  1134. console.log(' 2. Search there for one with "'+document.domain+'" in the name.');
  1135. console.log(' 3. Use buttons in the same block with service you found to stop it and uninstall/unregister.');
  1136. });
  1137. }).catch(function(err) {
  1138. console.log("Lol, it failed on it's own. -_-", err);
  1139. });
  1140. }, false);
  1141. }
  1142. /**/
  1143.  
  1144. // Currently obsolete code developed to prevent error and load calls on objects supposed to load resources
  1145. // from the internet like IMG or IFRAME, but missing SRC/HREF attribute. Usually tricks like this are used
  1146. // to unwrap wrapped functions to be able to load ads.
  1147. /* Commented out since not used
  1148. function errorAndLoadEventsFilter() {
  1149. var toString = Function.prototype.toString,
  1150. addEventListener = Element.prototype.addEventListener,
  1151. removeEventListener = Element.prototype.removeEventListener,
  1152. hasAttribute = Element.prototype.hasAttribute,
  1153. evtMap = new WeakMap();
  1154. Element.prototype.addEventListener = function(evt, func, capt) {
  1155. if (evt === 'error' || evt === 'load') {
  1156. if (!evtMap.get(func)) {
  1157. evtMap.set(func, function() {
  1158. if (hasAttribute.call(this, 'src') ||
  1159. hasAttribute.call(this, 'href')) {
  1160. func.apply(this, arguments);
  1161. } else {
  1162. console.log('Blocked', evt, 'handler', toString.call(func), 'on', this);
  1163. }
  1164. });
  1165. }
  1166. }
  1167. addEventListener.call(this, evt, (evtMap.get(func) || func), capt);
  1168. };
  1169. Element.prototype.removeEventListener = function(evt, func, capt) {
  1170. removeEventListener.call(this, evt, (evtMap.get(func) || func), capt);
  1171. };
  1172. Object.defineProperty(HTMLElement.prototype, 'onload', {
  1173. set: function(func) {
  1174. if(evtMap.has(this)) {
  1175. if (evtMap.get(this).onload) {
  1176. Element.prototype.removeEventListener.call(this, 'load', evtMap.get(this).onload, false);
  1177. }
  1178. evtMap.get(this).onload = func;
  1179. } else {
  1180. evtMap.set(this, { onload: func });
  1181. }
  1182. if (func) {
  1183. Element.prototype.addEventListener.call(this, 'load', func, false);
  1184. }
  1185. return func;
  1186. },
  1187. get: function() {
  1188. return evtMap.has(this) ? evtMap.get(this).onload : null;
  1189. }
  1190. });
  1191. Object.defineProperty(HTMLElement.prototype, 'onerror', {
  1192. set: function(func) {
  1193. if (evtMap.has(this)) {
  1194. evtMap.get(this).onerror = func;
  1195. } else {
  1196. evtMap.set(this, { onerror: func });
  1197. }
  1198. if (func) {
  1199. console.log('Blocked error handler', toString.call(func), 'on', this);
  1200. }
  1201. return func;
  1202. },
  1203. get: function() {
  1204. return evtMap.has(this) ? evtMap.get(this).onerror : null;
  1205. }
  1206. });
  1207. }
  1208. /**/
  1209.  
  1210. // === Scripts for specific domains ===
  1211.  
  1212. var scripts = {};
  1213. // prevent popups and redirects block
  1214. var preventPopupsNow = { 'now': preventPopups },
  1215. preventBackgroundRedirectNow = { 'now': preventBackgroundRedirect };
  1216. // Popups
  1217. scripts['biqle.ru'] = preventPopupsNow;
  1218. scripts['chaturbate.com'] = preventPopupsNow;
  1219. scripts['dfiles.ru'] = preventPopupsNow;
  1220. scripts['hentaiz.org'] = preventPopupsNow;
  1221. scripts['mirrorcreator.com'] = preventPopupsNow;
  1222. scripts['online-multy.ru'] = preventPopupsNow;
  1223. scripts['openload.co'] = preventPopupsNow;
  1224. scripts['radikal.ru'] = preventPopupsNow;
  1225. scripts['seedoff.cc'] = preventPopupsNow;
  1226. scripts['tapochek.net'] = preventPopupsNow;
  1227. scripts['thepiratebay.org'] = preventPopupsNow;
  1228. scripts['torseed.net'] = preventPopupsNow;
  1229. scripts['zippyshare.com'] = preventPopupsNow;
  1230. // Background redirects
  1231. scripts['mediafire.com'] = preventBackgroundRedirectNow;
  1232. scripts['megapeer.org'] = preventBackgroundRedirectNow;
  1233. scripts['megapeer.ru'] = preventBackgroundRedirectNow;
  1234. scripts['perfectgirls.net'] = preventBackgroundRedirectNow;
  1235. scripts['turbobit.net'] = preventBackgroundRedirectNow;
  1236.  
  1237. // other
  1238. scripts['4pda.ru'] = {
  1239. 'now': function() {
  1240. // https://greasyfork.org/en/scripts/14470-4pda-unbrender
  1241. var isForum = document.location.href.search('/forum/') !== -1,
  1242. hStyle;
  1243.  
  1244. function remove(n) {
  1245. if (n) {
  1246. n.parentNode.removeChild(n);
  1247. }
  1248. }
  1249.  
  1250. function afterClean() {
  1251. hStyle.disabled = true;
  1252. remove(hStyle);
  1253. }
  1254.  
  1255. function beforeClean() {
  1256. // attach styles before document displayed
  1257. hStyle = createStyle([
  1258. 'html { overflow-y: scroll }',
  1259. 'section[id] {'+(
  1260. 'position: absolute;'+
  1261. 'width: 100%'
  1262. )+'}',
  1263. 'article + aside * { display: none !important }',
  1264. '#header + div:after {'+(
  1265. 'content: "";'+
  1266. 'position: fixed;'+
  1267. 'top: 0;'+
  1268. 'left: 0;'+
  1269. 'width: 100%;'+
  1270. 'height: 100%;'+
  1271. 'background-color: #E6E7E9'
  1272. )+'}',
  1273. // http://codepen.io/Beaugust/pen/DByiE
  1274. '@keyframes spin { 100% { transform: rotate(360deg) } }',
  1275. 'article + aside:after {'+(
  1276. 'content: "";'+
  1277. 'position: absolute;'+
  1278. 'width: 150px;'+
  1279. 'height: 150px;'+
  1280. 'top: 150px;'+
  1281. 'left: 50%;'+
  1282. 'margin-top: -75px;'+
  1283. 'margin-left: -75px;'+
  1284. 'box-sizing: border-box;'+
  1285. 'border-radius: 100%;'+
  1286. 'border: 10px solid rgba(0, 0, 0, 0.2);'+
  1287. 'border-top-color: rgba(0, 0, 0, 0.6);'+
  1288. 'animation: spin 2s infinite linear'
  1289. )+'}'
  1290. ], {id:'ubrHider'}, true);
  1291.  
  1292. // display content of a page if time to load a page is more than 2 seconds to avoid
  1293. // blocking access to a page if it is loading for too long or stuck in a loading state
  1294. setTimeout(2000, afterClean);
  1295. }
  1296.  
  1297. createStyle([
  1298. '#nav .use-ad { display: block !important }',
  1299. 'article:not(.post) + article:not(#id), a[target="_blank"] img[height="90"] { display: none !important }'
  1300. ]);
  1301.  
  1302. if (!isForum) {
  1303. beforeClean();
  1304. }
  1305.  
  1306. // save links to non-overridden functions to use later
  1307. var protectedElems;
  1308. // protect/hide changed attributes in case site attempt to restore them
  1309. function styleProtector(eventMode) {
  1310. var oRAN = Element.prototype.removeAttributeNode,
  1311. isStyleText = function(t){ return t === 'style'; },
  1312. isStyleAttr = function(a){ return a instanceof Attr && a.nodeName === 'style'; },
  1313. returnUndefined = function(){},
  1314. protectedElems = new WeakMap();
  1315. function protoOverride(element, functionName, isStyleCheck, returnIfProtected) {
  1316. var oF = element.prototype[functionName], r;
  1317. element.prototype[functionName] = function() {
  1318. if (protectedElems.has(this) && isStyleCheck(arguments[0])) {
  1319. return returnIfProtected(this, arguments);
  1320. }
  1321. r = oF.apply(this, arguments);
  1322. return r;
  1323. };
  1324. }
  1325. protoOverride(Element, 'removeAttribute', isStyleText, returnUndefined);
  1326. protoOverride(Element, 'hasAttribute', isStyleText, function(_this) {
  1327. return protectedElems.get(_this) !== null;
  1328. });
  1329. protoOverride(Element, 'setAttribute', isStyleText, function(_this, args) {
  1330. protectedElems.set(_this, args[1]);
  1331. });
  1332. protoOverride(Element, 'getAttribute', isStyleText, function(_this) {
  1333. return protectedElems.get(_this);
  1334. });
  1335. if (eventMode) {
  1336. var e = document.createEvent('Event');
  1337. e.initEvent('protoOverride', false, false);
  1338. window.protectedElems = protectedElems;
  1339. window.dispatchEvent(e);
  1340. } else {
  1341. return protectedElems;
  1342. }
  1343. }
  1344. if (isFirefox) {
  1345. var s = document.createElement('script');
  1346. s.textContent = '(' + styleProtector.toString() + ')(true);';
  1347. window.addEventListener('protoOverride', function protoOverrideCallback(e){
  1348. if (win.protectedElems) {
  1349. protectedElems = win.protectedElems;
  1350. delete win.protectedElems;
  1351. }
  1352. document.removeEventListener('protoOverride', protoOverrideCallback, true);
  1353. }, true);
  1354. _appendChild(s);
  1355. _removeChild(s);
  1356. } else {
  1357. protectedElems = styleProtector(false);
  1358. }
  1359.  
  1360. // clean a page
  1361. window.addEventListener('DOMContentLoaded', function(){
  1362. var rem, si, itm;
  1363. function width(){ return window.innerWidth||_de.clientWidth||document.body.clientWidth||0; }
  1364. function height(){ return window.innerHeight||_de.clientHeight||document.body.clientHeight||0; }
  1365.  
  1366.  
  1367. if (isForum) {
  1368. si = document.querySelector('#logostrip');
  1369. if (si) {
  1370. remove(si.parentNode.nextSibling);
  1371. }
  1372. }
  1373.  
  1374. if (document.location.href.search('/forum/dl/') !== -1) {
  1375. document.body.setAttribute('style', (document.body.getAttribute('style')||'')+
  1376. ';background-color:black!important');
  1377. for (itm of document.querySelectorAll('body>div')) {
  1378. if (!itm.querySelector('.dw-fdwlink')) {
  1379. remove(itm);
  1380. }
  1381. }
  1382. }
  1383.  
  1384. if (isForum) { // Do not continue if it's a forum
  1385. return;
  1386. }
  1387.  
  1388. si = document.querySelector('#header');
  1389. if (si) {
  1390. rem = si.previousSibling;
  1391. while (rem) {
  1392. si = rem.previousSibling;
  1393. remove(rem);
  1394. rem = si;
  1395. }
  1396. }
  1397.  
  1398. for (itm of document.querySelectorAll('#nav li[class]')) {
  1399. if (itm && itm.querySelector('a[href^="/tag/"]')) {
  1400. remove(itm);
  1401. }
  1402. }
  1403.  
  1404. var style, result;
  1405. for (itm of document.querySelectorAll('DIV, A')) {
  1406. if (itm.tagName ==='DIV' && itm.offsetWidth > 0.95 * width() && itm.offsetHeight > 0.85 * height()) {
  1407. style = window.getComputedStyle(itm, null);
  1408. result = [];
  1409. if (style.backgroundImage !== 'none') {
  1410. result.push('background-image:none!important');
  1411. }
  1412. if (style.backgroundColor !== 'transparent' &&
  1413. style.backgroundColor !== 'rgba(0, 0, 0, 0)') {
  1414. result.push('background-color:transparent!important');
  1415. }
  1416. if (result.length) {
  1417. if (itm.getAttribute('style')) {
  1418. result.unshift(itm.getAttribute('style'));
  1419. }
  1420. (function(){
  1421. var fakeStyle = {
  1422. 'backgroundImage': itm.style.backgroundImage,
  1423. 'backgroundColor': itm.style.backgroundColor
  1424. };
  1425. try {
  1426. Object.defineProperty(itm, 'style', {
  1427. value: new Proxy(itm.style, {
  1428. get: function(target, prop){
  1429. if (fakeStyle.hasOwnProperty(prop)) {
  1430. return fakeStyle[prop];
  1431. } else {
  1432. return target[prop];
  1433. }
  1434. },
  1435. set: function(target, prop, value){
  1436. if (fakeStyle.hasOwnProperty(prop)) {
  1437. fakeStyle[prop] = value;
  1438. } else {
  1439. target[prop] = value;
  1440. }
  1441. return value;
  1442. }
  1443. }),
  1444. enumerable: true
  1445. });
  1446. } catch (e) {
  1447. console.log('Unable to protect style property.', e);
  1448. }
  1449. })();
  1450. if (protectedElems) {
  1451. protectedElems.set(itm, _getAttribute.call(itm, 'style'));
  1452. }
  1453. _setAttribute.call(itm, 'style', result.join(';'));
  1454. }
  1455. }
  1456. if (itm.tagName ==='A' && (itm.offsetWidth > 0.95 * width() || itm.offsetHeight > 0.85 * height())) {
  1457. if (protectedElems) {
  1458. protectedElems.set(itm, _getAttribute.call(itm, 'style'));
  1459. }
  1460. _setAttribute.call(itm, 'style', 'display:none!important');
  1461. }
  1462. }
  1463.  
  1464. for (itm of document.querySelectorAll('ASIDE>DIV')) {
  1465. if ( ((itm.querySelector('script, iframe, a[href*="/ad/www/"]') ||
  1466. itm.querySelector('img[src$=".gif"]:not([height="0"]), img[height="400"]')) &&
  1467. !itm.classList.contains('post') ) || !itm.childNodes.length ) {
  1468. remove(itm);
  1469. }
  1470. }
  1471.  
  1472. document.body.setAttribute('style', (document.body.getAttribute('style')||'')+';background-color:#E6E7E9!important');
  1473.  
  1474. // display content of the page
  1475. afterClean();
  1476. });
  1477. }
  1478. };
  1479.  
  1480. scripts['allmovie.pro'] = function() {
  1481. // pretend to be Android to make site use different played for ads
  1482. if (isSafari) {
  1483. return;
  1484. }
  1485. Object.defineProperty(navigator, 'userAgent', {
  1486. 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'; },
  1487. enumerable: true
  1488. });
  1489. };
  1490. scripts['rufilmtv.org'] = scripts['allmovie.pro'];
  1491.  
  1492. scripts['anidub-online.ru'] = function() {
  1493. var script = document.createElement('script');
  1494. script.type = "text/javascript";
  1495. script.innerHTML = "function ogonekstart1() {}";
  1496. document.getElementsByTagName('head')[0].appendChild(script);
  1497.  
  1498. var style = document.createElement('style');
  1499. style.type = 'text/css';
  1500. style.appendChild(document.createTextNode('.background {background: none!important;}'));
  1501. style.appendChild(document.createTextNode('.background > script + div, .background > script ~ div:not([id]):not([class]) + div[id][class] {display:none!important}'));
  1502. document.head.appendChild(style);
  1503. };
  1504. scripts['online.anidub.com'] = scripts['anidub-online.ru'];
  1505.  
  1506. scripts['fs.to'] = function() {
  1507. function skipClicker(i) {
  1508. if (!i) {
  1509. return;
  1510. }
  1511. var skip = document.querySelector('.b-aplayer-banners__close');
  1512. if (skip) {
  1513. skip.click();
  1514. } else {
  1515. setTimeout(skipClicker, 100, i-1);
  1516. }
  1517. }
  1518. setTimeout(skipClicker, 100, 30);
  1519.  
  1520. createStyle([
  1521. '.l-body-branding *,'+
  1522. '.b-styled__item-central,'+
  1523. '.b-styled__content-right,'+
  1524. '.b-styled__section-central,'+
  1525. 'div[id^="adsProxy-"]'+
  1526. '{display:none!important}',
  1527. 'body {background-image:url(data:image/png;base64,'+
  1528. 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAACX'+
  1529. 'BIWXMAAC4jAAAuIwF4pT92AAAADUlEQVR42mOQUdL5DwACMgFq'+
  1530. 'BC3ttwAAAABJRU5ErkJggg==)!important}'
  1531. ]);
  1532.  
  1533. if (/\/(view_iframe|iframeplayer)\//i.test(document.location.pathname)) {
  1534. var p = document.querySelector('#player:not([preload="auto"])'),
  1535. m = document.querySelector('.main'),
  1536. adStepper = function(p) {
  1537. if (p.currentTime < p.duration) {
  1538. p.currentTime += 1;
  1539. }
  1540. },
  1541. adSkipper = function(f, p) {
  1542. f.click();
  1543. p.waitAfterSkip = false;
  1544. p.longerSkipper = false;
  1545. console.log('Пропустили.');
  1546. },
  1547. cl = function(p) {
  1548. var faster = document.querySelector('.b-aplayer__html5-desktop-skip'),
  1549. series = document.querySelector('.b-aplayer__actions-series');
  1550.  
  1551. function clickSelected() {
  1552. var s = document.querySelector('.b-aplayer__popup-series-episodes .selected a');
  1553. if (s) {
  1554. s.click();
  1555. }
  1556. }
  1557.  
  1558. if ((!faster || faster.style.display !== 'block') && series && !p.seriesClicked) {
  1559. series.click();
  1560. p.seriesClicked = true;
  1561. p.longerSkipper = true;
  1562. setTimeout(clickSelected, 1000);
  1563. p.pause();
  1564. }
  1565.  
  1566. function skipListener() {
  1567. if (p.waitAfterSkip) {
  1568. console.log('В процессе пропуска…');
  1569. return;
  1570. }
  1571. p.pause();
  1572. if (!p.classList.contains('m-hidden')) {
  1573. p.classList.add('m-hidden');
  1574. }
  1575. if (faster && p.currentTime &&
  1576. win.getComputedStyle(faster).display === 'block' &&
  1577. !faster.querySelector('.b-aplayer__html5-desktop-skip-timer')) {
  1578. p.waitAfterSkip = true;
  1579. setTimeout(adSkipper, (p.longerSkipper?3:1)*1000, faster, p);
  1580. console.log('Доступен быстрый пропуск…');
  1581. } else {
  1582. setTimeout(adStepper, 1000, p);
  1583. }
  1584. }
  1585.  
  1586. p.addEventListener('timeupdate', skipListener, false);
  1587. },
  1588. o = new MutationObserver(function (ms) {
  1589. var m, node;
  1590. for (m of ms) {
  1591. for (node of m.addedNodes) {
  1592. if (node.id === 'player' &&
  1593. node.nodeName === 'VIDEO' &&
  1594. _getAttribute.call(node, 'preload') !== 'auto') {
  1595. cl(node);
  1596. }
  1597. }
  1598. }
  1599. });
  1600. if (p.nodeName === 'VIDEO') {
  1601. cl(p);
  1602. } else {
  1603. o.observe(m, {childList: true});
  1604. }
  1605. }
  1606. };
  1607. scripts['brb.to'] = scripts['fs.to'];
  1608. scripts['cxz.to'] = scripts['fs.to'];
  1609.  
  1610. scripts['drive2.ru'] = function() {
  1611. gardener('.c-block:not([data-metrika="recomm"]),.o-grid__item', />Реклама<\//i);
  1612. };
  1613.  
  1614. scripts['fishki.net'] = function() {
  1615. gardener('.drag_list > .drag_element, .list-view > .paddingtop15, .post-wrap', /543769|Новости партнеров/);
  1616. };
  1617.  
  1618. scripts['gidonline.club'] = {
  1619. 'now': function() {
  1620. createStyle('.tray > div[style] {display: none!important}');
  1621. }
  1622. };
  1623. scripts['gidonlinekino.com'] = scripts['gidonline.club'];
  1624.  
  1625. scripts['hdgo.cc'] = {
  1626. 'now': function(){
  1627. var o = new MutationObserver(function(ms) {
  1628. var m, node;
  1629. for (m of ms) {
  1630. for (node of m.addedNodes) {
  1631. if (node.tagName === 'SCRIPT' && _getAttribute(node, 'onerror') !== null) {
  1632. node.removeAttribute('onerror');
  1633. }
  1634. }
  1635. }
  1636. });
  1637. o.observe(document, {childList:true, subtree: true});
  1638. }
  1639. };
  1640. scripts['couber.be'] = scripts['hdgo.cc'];
  1641. scripts['46.30.43.38'] = scripts['hdgo.cc'];
  1642.  
  1643. scripts['gismeteo.ru'] = {
  1644. 'DOMContentLoaded': function() {
  1645. gardener('div > a[target^="_"]', /Яндекс\.Директ/i, { root: 'body', observe: true, parent: 'div[class*="frame"]' });
  1646. }
  1647. };
  1648.  
  1649. scripts['hdrezka.me'] = {
  1650. 'now': function() {
  1651. Object.defineProperty(win, 'fuckAdBlock', {
  1652. value: {
  1653. onDetected: function() {
  1654. console.log('Pretending to be an ABP detector.');
  1655. }
  1656. }
  1657. });
  1658. Object.defineProperty(win, 'ab', {
  1659. value: false,
  1660. enumerable: true
  1661. });
  1662. },
  1663. 'DOMContentLoaded': function() {
  1664. gardener('div[id][onclick][onmouseup][onmousedown]', /onmouseout/i);
  1665. }
  1666. };
  1667.  
  1668. scripts['imageban.ru'] = {
  1669. 'now': preventBackgroundRedirect,
  1670. 'DOMContentLoaded': function() {
  1671. win.addEventListener('unload', function() {
  1672. if (!window.location.hash) {
  1673. window.location.replace(window.location+'#');
  1674. } else {
  1675. window.location.hash = '';
  1676. }
  1677. }, true);
  1678. }
  1679. };
  1680.  
  1681. scripts['e.mail.ru'] = function() {
  1682. gardener('#LEGO :not([data-mnemo])>.js-href[data-id]',
  1683. /data:image.*>Реклама<|>Реклама<.*\/\/favicon\./i,
  1684. {root:'#LEGO', observe: true, parent:'div[id][class]'});
  1685. };
  1686.  
  1687. scripts['mail.ru'] = {
  1688. 'now': function() {
  1689. // Trick to prevent mail.ru from removing 3rd-party styles
  1690. scriptLander(function(){
  1691. Object.defineProperty(Object.prototype, 'restoreVisibility', {
  1692. get: function() { return function(){}; },
  1693. set: function() {}
  1694. });
  1695. });
  1696. }
  1697. };
  1698.  
  1699. scripts['megogo.net'] = {
  1700. 'now': function() {
  1701. Object.defineProperty(win, "adBlock", {
  1702. value : false,
  1703. enumerable : true
  1704. });
  1705. Object.defineProperty(win, "showAdBlockMessage", {
  1706. value : function () {},
  1707. enumerable : true
  1708. });
  1709. }
  1710. };
  1711.  
  1712. scripts['naruto-base.su'] = function() {
  1713. gardener('div[id^="entryID"],.block', /href="http.*?target="_blank"/i);
  1714. };
  1715.  
  1716. scripts['overclockers.ru'] = {
  1717. 'now': function() {
  1718. createStyle('.fixoldhtml {display:block!important}');
  1719. if (!isChrome && !isOpera) {
  1720. return; // Looks like my code works only in Chrome-like browsers
  1721. }
  1722. var noContentYet = true;
  1723. function jWrap() {
  1724. var _$ = win.$, _e = _$.extend;
  1725. win.$ = function() {
  1726. var _ret = _$.apply(window, arguments);
  1727. if (_ret[0] === document.body) {
  1728. _ret.html = function() {
  1729. console.log('Anti-adblock prevented.');
  1730. };
  1731. }
  1732. return _ret;
  1733. };
  1734. win.$.extend = function() {
  1735. return _e.apply(_$, arguments);
  1736. };
  1737. win.jQuery = win.$;
  1738. }
  1739. (function jReady() {
  1740. if (!win.$ && noContentYet) {
  1741. setTimeout(jReady, 0);
  1742. } else {
  1743. jWrap();
  1744. }
  1745. })();
  1746. document.addEventListener ('DOMContentLoaded', function(){
  1747. noContentYet = false;
  1748. }, false);
  1749. }
  1750. };
  1751. scripts['forums.overclockers.ru'] = {
  1752. 'now': function() {
  1753. createStyle('.needblock {position: fixed; left: -10000px}');
  1754. Object.defineProperty(win, 'adblck', {
  1755. value: 'no',
  1756. enumerable: true
  1757. });
  1758. }
  1759. };
  1760.  
  1761. scripts['pb.wtf'] = function() {
  1762. createStyle('.reques,#result,tbody.row1:not([id]) {display: none !important}');
  1763. // image in the slider in the header
  1764. gardener('a[href$="=="]', /img/i, {root:'.release-navbar', observe:true, parent:'div'});
  1765. // ads in blocks on the page
  1766. gardener('a[href^="/"]', /<img\s.*<br>/i, {root:'#main_content', observe:true, parent:'div[class]'});
  1767. // line above topic content
  1768. gardener('.re_top1', /./, {root:'#main_content', parent:'.hidden-sm'});
  1769. };
  1770. scripts['piratbit.org'] = scripts['pb.wtf'];
  1771. scripts['piratbit.ru'] = scripts['pb.wtf'];
  1772.  
  1773. scripts['pikabu.ru'] = function() {
  1774. gardener('.story', /story__sponsor|story__gag|profile\/ads"/i, {root: '.inner_wrap', observe: true});
  1775. };
  1776.  
  1777. scripts['rp5.ru'] = function() {
  1778. createStyle('#bannerBottom {display: none!important}');
  1779. var co = document.querySelector('#content'), i, nodes;
  1780. if (!co) {
  1781. return;
  1782. }
  1783. nodes = co.parentNode.childNodes;
  1784. i = nodes.length;
  1785. while (i--) {
  1786. if (nodes[i] !== co) {
  1787. nodes[i].parentNode.removeChild(nodes[i]);
  1788. }
  1789. }
  1790. };
  1791. scripts['rp5.by'] = scripts['rp5.ru'];
  1792. scripts['rp5.ua'] = scripts['rp5.ru'];
  1793.  
  1794. scripts['rustorka.com'] = {
  1795. 'now': function() {
  1796. createStyle('.header > div:not(.head-block) a, #sidebar1 img, #logo img {opacity:0!important}', {
  1797. id: 'tempHidingStyles'
  1798. }, true);
  1799. preventPopups();
  1800. },
  1801. 'DOMContentLoaded': function() {
  1802. for (var o of document.querySelectorAll('IMG, A')) {
  1803. if ((o.clientWidth === 728 && o.clientHeight === 90) ||
  1804. (o.clientWidth === 300 && o.clientHeight === 250)) {
  1805. while (o && o.tagName !== 'A') {
  1806. o = o.parentNode;
  1807. }
  1808. if (o) {
  1809. _setAttribute.call(o, 'style', 'display: none !important');
  1810. }
  1811. }
  1812. }
  1813. var s = document.querySelector('#tempHidingStyles');
  1814. s.parentNode.removeChild(s);
  1815. }
  1816. };
  1817. scripts['rumedia.ws'] = scripts['rustorka.com'];
  1818.  
  1819. scripts['sport-express.ru'] = function() {
  1820. gardener('.js-relap__item',/>Реклама\s+<\//, {root:'.container', observe: true});
  1821. };
  1822.  
  1823. scripts['sports.ru'] = function() {
  1824. gardener('.aside-news-list__item', /aside-news-list__advert/i, {root:'.columns-layout__left', observe: true});
  1825. gardener('.material-list__item', /Реклама/i, {root:'.columns-layout', observe: true});
  1826. // extra functionality: shows/hides panel at the top depending on scroll direction
  1827. createStyle([
  1828. '.user-panel__fixed { transition: top 0.2s ease-in-out!important; }',
  1829. '.user-panel-up { top: -40px!important }'
  1830. ], {id: 'userPanelSlide'}, false);
  1831. (function lookForPanel() {
  1832. var panel = document.querySelector('.user-panel__fixed');
  1833. if (!panel) {
  1834. setTimeout(lookForPanel, 100);
  1835. } else {
  1836. window.addEventListener('wheel', function(e){
  1837. if (e.deltaY > 0 && !panel.classList.contains('user-panel-up')) {
  1838. panel.classList.add('user-panel-up');
  1839. } else
  1840. if (e.deltaY < 0 && panel.classList.contains('user-panel-up')) {
  1841. panel.classList.remove('user-panel-up');
  1842. }
  1843. }, false);
  1844. }
  1845. })();
  1846. };
  1847.  
  1848. scripts['www.ukr.net'] = scripts['sinoptik.com.ru'];
  1849.  
  1850. scripts['vk.com'] = function() {
  1851. gardener('div[data-post-id]', /wall_marked_as_ads/, {root: '#page_wall_posts', observe: true});
  1852. };
  1853.  
  1854. scripts['yap.ru'] = function() {
  1855. var words = /member1438|Administration|\/go\/?.*yplkl\.php/;
  1856. gardener('form > table[id^="p_row_"]:nth-of-type(2)', words);
  1857. gardener('tr > .holder.newsbottom', words, {parent:'tr', siblings:-2});
  1858. };
  1859. scripts['yaplakal.com'] = scripts['yap.ru'];
  1860.  
  1861. scripts['rambler.ru'] = {
  1862. 'now': function() {
  1863. scriptLander(function() {
  1864. var _createElement = Document.prototype.createElement,
  1865. loadMap = new WeakMap();
  1866. Document.prototype.createElement = function createElement(name) {
  1867. /*jshint validthis:true */
  1868. var el = _createElement.apply(this, arguments);
  1869. if (el.tagName === 'LINK') {
  1870. Object.defineProperty(el, 'onload', {
  1871. get: function() {
  1872. return loadMap.get(loadMap.get(this));
  1873. },
  1874. set: function(func) {
  1875. var wrap = loadMap.get(this);
  1876. if (wrap) {
  1877. this.removeEventListener('load', wrap, false);
  1878. loadMap.remove(wrap);
  1879. loadMap.remove(this);
  1880. }
  1881. wrap = function(e) {
  1882. if (e.target && e.target.sheet && e.target.sheet.cssRules &&
  1883. e.target.sheet.cssRules[0] && e.target.sheet.cssRules[0].cssText &&
  1884. /\{\s*content\s*:\s*"[^"]+"/i.test(e.target.sheet.cssRules[0].cssText)) {
  1885. console.log('Blocked "onload" for', e.target.href);
  1886. return false;
  1887. }
  1888. return func.apply(this, arguments);
  1889. };
  1890. loadMap.set(this, wrap);
  1891. loadMap.set(wrap, func);
  1892. this.addEventListener('load', wrap, false);
  1893. },
  1894. enumberable: true
  1895. });
  1896. }
  1897. return el;
  1898. };
  1899. });
  1900. }
  1901. };
  1902.  
  1903. scripts['reactor.cc'] = {
  1904. 'now': function() {
  1905. win.open = (function(){ throw new Error('Redirect prevention.'); }).bind(window);
  1906. },
  1907. 'click': function(e) {
  1908. var node = e.target;
  1909. if (node.nodeType === Node.ELEMENT_NODE &&
  1910. node.style.position === 'absolute' &&
  1911. node.style.zIndex > 0)
  1912. node.parentNode.removeChild(node);
  1913. },
  1914. 'DOMContentLoaded': function() {
  1915. var words = new RegExp(
  1916. 'блокировщика рекламы'
  1917. .split('')
  1918. .map(function(e){return e+'[\u200b\u200c\u200d]*';})
  1919. .join('')
  1920. .replace(' ', '\\s*')
  1921. .replace(/[аоре]/g, function(e){return ['[аa]','[оo]','[рp]','[еe]']['аоре'.indexOf(e)];}),
  1922. 'i'),
  1923. can;
  1924. function deeper(spider) {
  1925. var c, l, n;
  1926. if (words.test(spider.innerText)) {
  1927. if (spider.nodeType === Node.TEXT_NODE) {
  1928. return true;
  1929. }
  1930. c = spider.childNodes;
  1931. l = c.length;
  1932. n = 0;
  1933. while(l--) {
  1934. if (deeper(c[l]), can) {
  1935. n++;
  1936. }
  1937. }
  1938. if (n > 0 && n === c.length && spider.offsetHeight < 750) {
  1939. can.push(spider);
  1940. }
  1941. return false;
  1942. }
  1943. return true;
  1944. }
  1945. function probe(){
  1946. if (words.test(document.body.innerText)) {
  1947. can = [];
  1948. deeper(document.body);
  1949. var i = can.length, j, spider;
  1950. while(i--) {
  1951. spider = can[i];
  1952. if (spider.offsetHeight > 10 && spider.offsetHeight < 750) {
  1953. _setAttribute.call(spider, 'style', 'background:none!important');
  1954. }
  1955. }
  1956. }
  1957. }
  1958. var o = new MutationObserver(probe);
  1959. o.observe(document,{childList:true, subtree:true});
  1960. }
  1961. };
  1962. scripts['joyreactor.cc'] = scripts['reactor.cc'];
  1963. scripts['pornreactor.cc'] = scripts['reactor.cc'];
  1964.  
  1965. scripts['auto.ru'] = function() {
  1966. var words = /Реклама|Яндекс.Директ|yandex_ad_/;
  1967. var userAdsListAds = [
  1968. '.listing-list > .listing-item',
  1969. '.listing-item_type_fixed.listing-item'
  1970. ];
  1971. var catalogAds = [
  1972. 'div[class*="layout_catalog-inline"]',
  1973. 'div[class$="layout_horizontal"]'
  1974. ];
  1975. var otherAds = [
  1976. '.advt_auto',
  1977. '.sidebar-block',
  1978. '.pager-listing + div[class]',
  1979. '.card > div[class][style]',
  1980. '.sidebar > div[class]',
  1981. '.main-page__section + div[class]',
  1982. '.listing > tbody'];
  1983. gardener(userAdsListAds.join(','), words, {root:'.listing-wrap', observe:true});
  1984. gardener(catalogAds.join(','), words, {root:'.catalog__page,.content__wrapper', observe:true});
  1985. gardener(otherAds.join(','), words);
  1986. };
  1987.  
  1988. scripts['rsload.net'] = {
  1989. 'load': function() {
  1990. var dis = document.querySelector('label[class*="cb-disable"]');
  1991. if (dis) {
  1992. dis.click();
  1993. }
  1994. },
  1995. 'click': function(e) {
  1996. var t = e.target;
  1997. if (t && t.href && (/:\/\/\d+\.\d+\.\d+\.\d+\//.test(t.href))) {
  1998. t.href = t.href.replace('://','://rsload.net:rsload.net@');
  1999. }
  2000. }
  2001. };
  2002.  
  2003. var domain = document.domain, name;
  2004. while (domain.indexOf('.') !== -1) {
  2005. if (scripts.hasOwnProperty(domain)) {
  2006. if (typeof scripts[domain] === 'function') {
  2007. document.addEventListener ('DOMContentLoaded', scripts[domain], false);
  2008. }
  2009. for (name in scripts[domain]) {
  2010. if (name !== 'now') {
  2011. (name === 'load' ? window : document)
  2012. .addEventListener (name, scripts[domain][name], false);
  2013. } else {
  2014. scripts[domain][name]();
  2015. }
  2016. }
  2017. }
  2018. domain = domain.slice(domain.indexOf('.') + 1);
  2019. }
  2020. })();