RU AdList JS Fixes

try to take over the world!

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

  1. // ==UserScript==
  2. // @name RU AdList JS Fixes
  3. // @namespace ruadlist_js_fixes
  4. // @version 20170522.2
  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^', '||octoclick.net^', '||octozoon.org^',
  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. // .log - display log in the console
  914. // .hide - set display to none instead of removing from the page
  915. // .parent - parent node to remove if content is found in the child node
  916. // .siblings - number of simling nodes to remove (excluding text nodes)
  917. function scRemove(e) {
  918. e.parentNode.removeChild(e);
  919. }
  920. function scHide(e) {
  921. var s = _getAttribute.call(e, 'style') || '',
  922. h = ';display:none!important;';
  923. if (s.indexOf(h) < 0) {
  924. _setAttribute.call(e, 'style', s+h);
  925. }
  926. }
  927. function scissors (selector, words, scope, params) {
  928. if (params.log) console.log('[s] starting with', selector, words, scope, JSON.stringify(params));
  929. var remFunc = (params.hide ? scHide : scRemove),
  930. iterFunc = (params.siblings > 0 ?
  931. 'nextSibling' :
  932. 'previousSibling'),
  933. toRemove = [],
  934. siblings,
  935. node;
  936. for (node of scope.querySelectorAll(selector)) {
  937. if (params.log) console.log('[s] found node', node);
  938. if (params.parent) {
  939. while(node !== scope && !(node.matches(params.parent))) {
  940. node = node.parentNode;
  941. }
  942. if (params.log) console.log('[s] moving to parent node', node);
  943. }
  944. if (words.test(node.innerHTML) || !node.childNodes.length) {
  945. // drill up to the specified parent node if required
  946. if (node === scope) {
  947. if (params.log) console.log('[s] oops, we don\'t want to remove our scope!');
  948. break;
  949. }
  950. if (toRemove.indexOf(node) === -1) {
  951. if (params.log) console.log('[s] adding node into list for removal');
  952. toRemove.push(node);
  953. // add multiple nodes if defined more than one sibling
  954. siblings = Math.abs(params.siblings) || 0;
  955. while (siblings) {
  956. node = node[iterFunc];
  957. if (node.nodeType === Node.ELEMENT_NODE) {
  958. if (params.log) console.log('[s] adding sibling node', node);
  959. toRemove.push(node);
  960. siblings -= 1; //count only element nodes
  961. } else if (!params.hide) {
  962. if (params.log) console.log('[s] adding sibling node', node);
  963. toRemove.push(node);
  964. }
  965. }
  966. } else {
  967. if (params.log) console.log('[s] node already marked for removal');
  968. }
  969. } else {
  970. if (params.log) console.log('[s] word test failed, proceed to the next node');
  971. }
  972. }
  973. if (params.log) console.log('[s] proceed with', (params.hide?'hide':'removal'), 'of', toRemove);
  974. for (node of toRemove) {
  975. remFunc(node);
  976. }
  977. return toRemove.length;
  978. }
  979.  
  980. // function to perform multiple checks if ads inserted with a delay
  981. // by default does 30 checks withing a 3 seconds unless nonstop mode specified
  982. // also does 1 extra check when a page completely loads
  983. // selector and words - passed dow to scissors
  984. // params - object with multiple extra parameters:
  985. // .log - display log in the console
  986. // .root - selector to narrow down scope to scan;
  987. // .observe - if true then check will be performed continuously;
  988. // Other parameters passed down to scissors.
  989. function gardener(selector, words, params) {
  990. params = params || {};
  991. if (params.log) console.log('[g] starting with', selector, words, JSON.stringify(params));
  992. var scope = document,
  993. nonstop = false;
  994. // narrow down scope to a specific element
  995. if (params.root) {
  996. scope = scope.querySelector(params.root);
  997. if (!scope) {// exit if the root element is not present on the page
  998. return 0;
  999. }
  1000. if (params.log) console.log('[g] scope', scope);
  1001. }
  1002. // add observe mode if required
  1003. if (params.observe) {
  1004. if (typeof MutationObserver === 'function') {
  1005. (new MutationObserver(function(ms){
  1006. for (var m of ms) {
  1007. if (m.addedNodes.length) {
  1008. scissors(selector, words, scope, params);
  1009. }
  1010. }
  1011. })).observe(scope, {childList:true, subtree: true});
  1012. if (params.log) console.log('[g] observer enabled');
  1013. } else {
  1014. nonstop = true;
  1015. if (params.log) console.log('[g] nonstop mode enabled');
  1016. }
  1017. }
  1018. // wait for a full page load to do one extra cut
  1019. win.addEventListener('load',function(){
  1020. if (params.log) console.log('[g] onload cleanup');
  1021. scissors(selector, words, scope, params);
  1022. });
  1023. // do multiple cuts until ads removed
  1024. function cut(sci, s, w, sc, p, i) {
  1025. if (i > 0) {
  1026. i -= 1;
  1027. }
  1028. if (i && !sci(s, w, sc, p)) {
  1029. setTimeout(cut, 100, sci, s, w, sc, p, i);
  1030. }
  1031. }
  1032. cut(scissors, selector, words, scope, params, (nonstop ? -1 : 30));
  1033. }
  1034.  
  1035. // Helper function to close background tab if site opens itself in a new tab and then
  1036. // loads a 3rd-party page in the background one (thus performing background redirect).
  1037. function preventBackgroundRedirect() {
  1038. // create "cose_me" event to call high-level window.close()
  1039. var key = Math.random().toString(36).substr(2);
  1040. window.addEventListener('close_me_'+key, function(e) {
  1041. window.close();
  1042. });
  1043.  
  1044. // window.open wrapper
  1045. function pbrLander() {
  1046. var orgOpen = window.open.bind(window),
  1047. idx = String.prototype.indexOf,
  1048. event = new CustomEvent("close_me_%key%", {});
  1049. function closeWindow(){
  1050. // site went to a new tab and attempts to unload
  1051. // call for high-level close through event
  1052. window.dispatchEvent(event);
  1053. }
  1054. // window.open wrapper
  1055. function open(){
  1056. console.log(arguments, window.location.host);
  1057. if (arguments[0] &&
  1058. (idx.call(arguments[0], window.location.host) > -1 ||
  1059. idx.call(arguments[0], '://') === -1)) {
  1060. window.addEventListener('unload', closeWindow, true);
  1061. }
  1062. orgOpen.apply(window, arguments);
  1063. }
  1064. window.open = open.bind(window);
  1065. // Node.createElement wrapper to prevent click-dispatch in Google Chrome and similar browsers
  1066. var realCreateElement = Document.prototype.createElement;
  1067. function wrappedCreateElement(name) {
  1068. /*jshint validthis:true */
  1069. var el = realCreateElement.apply(this, arguments);
  1070. if (el.tagName === 'A') {
  1071. el.addEventListener('click', function(e){
  1072. if (!e.target.parentNode || !e.isTrusted) {
  1073. window.addEventListener('unload', closeWindow, true);
  1074. }
  1075. }, false);
  1076. }
  1077. return el;
  1078. }
  1079. Document.prototype.createElement = wrappedCreateElement;
  1080. console.log("Background redirect prevention enabled.");
  1081. }
  1082.  
  1083. // land wrapper on the page
  1084. var script = document.createElement('script');
  1085. script.appendChild(document.createTextNode('('+pbrLander.toString().replace(/%key%/g,key)+')();'));
  1086. document.head.insertBefore(script, document.head.firstChild);
  1087. script.parentNode.removeChild(script);
  1088. }
  1089.  
  1090. // Function to catch and block various methods to open a new window with 3rd-party content.
  1091. // Some advertisement networks went way past simple window.open call to circumvent default popup protection.
  1092. // This funciton blocks window.open, ability to restore original window.open from an IFRAME object,
  1093. // ability to perform an untrusted (not initiated by user) click on a link, click on a link without a parent
  1094. // node or simply a link with piece of javascript code in the HREF attribute.
  1095. function preventPopups() {
  1096. function open(){
  1097. console.log('Site attempted to open a new window', arguments);
  1098. function nil(){}
  1099. return {
  1100. document: {
  1101. write: nil,
  1102. writeln: nil
  1103. }
  1104. };
  1105. }
  1106. win.open = exportFunction(open, win);
  1107.  
  1108. function wrapFunctions() {
  1109. var realCreateElement = Document.prototype.createElement,
  1110. realAppendChild = Element.prototype.appendChild;
  1111. Document.prototype.createElement = function createElement(name) {
  1112. /*jshint validthis:true */
  1113. var el = realCreateElement.apply(this, arguments);
  1114. if (el.tagName === 'A') {
  1115. el.addEventListener('click', function(e) {
  1116. if (!e.target.parentNode || !e.isTrusted ||
  1117. (e.target.href && e.target.href.toLowerCase().indexOf('javascript') > -1)) {
  1118. e.preventDefault();
  1119. console.log('Blocked suspicious click event', e, 'on', e.target);
  1120. }
  1121. }, false);
  1122. }
  1123. if (el.tagName === 'IFRAME') {
  1124. el.addEventListener('load', function(){
  1125. try {
  1126. this.contentWindow.open = open;
  1127. } catch(ignore) {}
  1128. }, false);
  1129. }
  1130. return el;
  1131. };
  1132. Element.prototype.appendChild = function appendChild() {
  1133. var child = realAppendChild.apply(this, arguments);
  1134. if (child && child.nodeType === Node.ELEMENT_NODE && child.tagName === 'IFRAME') {
  1135. try {
  1136. child.contentWindow.open = open;
  1137. } catch(ignore) {}
  1138. }
  1139. return child;
  1140. };
  1141. console.log('Popup prevention enabled.');
  1142. }
  1143.  
  1144. scriptLander(wrapFunctions, [open]);
  1145. }
  1146.  
  1147. // Currently unused piece of code developed to prevent site from registering serviceWorker
  1148. // and uninstall any existing instances of serivceWorker in case there is one already.
  1149. /* Commented out since not used
  1150. function forbidServiceWorker() {
  1151. if (!("serviceWorker" in navigator)) {
  1152. return;
  1153. }
  1154. var svr = navigator.serviceWorker.ready;
  1155. Object.defineProperty(navigator, 'serviceWorker', {
  1156. value: {
  1157. register: function(){
  1158. console.log('Registration of serviceWorker ' + arguments[0] + ' blocked.');
  1159. return new Promise(function(){});
  1160. },
  1161. ready: new Promise(function(){}),
  1162. addEventListener:function(){}
  1163. }
  1164. });
  1165. document.addEventListener('DOMContentLoaded', function() {
  1166. if (!svr) {
  1167. return;
  1168. }
  1169. svr.then(function(sw) {
  1170. console.log('Found existing serviceWorker:', sw);
  1171. console.log('Attempting to unregister...');
  1172. sw.unregister().then(function() {
  1173. console.log('Unregistered! :)');
  1174. }).catch(function(err) {
  1175. console.log('Unregistration failed. :(', err);
  1176. console.log('Try to remove it manually:');
  1177. console.log(' 1. Open: chrome://serviceworker-internals/ (Google Chrome and alike) or about:serviceworkers (Mozilla Firefox) in a new tab.');
  1178. console.log(' 2. Search there for one with "'+document.domain+'" in the name.');
  1179. console.log(' 3. Use buttons in the same block with service you found to stop it and uninstall/unregister.');
  1180. });
  1181. }).catch(function(err) {
  1182. console.log("Lol, it failed on it's own. -_-", err);
  1183. });
  1184. }, false);
  1185. }
  1186. /**/
  1187.  
  1188. // Currently obsolete code developed to prevent error and load calls on objects supposed to load resources
  1189. // from the internet like IMG or IFRAME, but missing SRC/HREF attribute. Usually tricks like this are used
  1190. // to unwrap wrapped functions to be able to load ads.
  1191. /* Commented out since not used
  1192. function errorAndLoadEventsFilter() {
  1193. var toString = Function.prototype.toString,
  1194. addEventListener = Element.prototype.addEventListener,
  1195. removeEventListener = Element.prototype.removeEventListener,
  1196. hasAttribute = Element.prototype.hasAttribute,
  1197. evtMap = new WeakMap();
  1198. Element.prototype.addEventListener = function(evt, func, capt) {
  1199. if (evt === 'error' || evt === 'load') {
  1200. if (!evtMap.get(func)) {
  1201. evtMap.set(func, function() {
  1202. if (hasAttribute.call(this, 'src') ||
  1203. hasAttribute.call(this, 'href')) {
  1204. func.apply(this, arguments);
  1205. } else {
  1206. console.log('Blocked', evt, 'handler', toString.call(func), 'on', this);
  1207. }
  1208. });
  1209. }
  1210. }
  1211. addEventListener.call(this, evt, (evtMap.get(func) || func), capt);
  1212. };
  1213. Element.prototype.removeEventListener = function(evt, func, capt) {
  1214. removeEventListener.call(this, evt, (evtMap.get(func) || func), capt);
  1215. };
  1216. Object.defineProperty(HTMLElement.prototype, 'onload', {
  1217. set: function(func) {
  1218. if(evtMap.has(this)) {
  1219. if (evtMap.get(this).onload) {
  1220. Element.prototype.removeEventListener.call(this, 'load', evtMap.get(this).onload, false);
  1221. }
  1222. evtMap.get(this).onload = func;
  1223. } else {
  1224. evtMap.set(this, { onload: func });
  1225. }
  1226. if (func) {
  1227. Element.prototype.addEventListener.call(this, 'load', func, false);
  1228. }
  1229. return func;
  1230. },
  1231. get: function() {
  1232. return evtMap.has(this) ? evtMap.get(this).onload : null;
  1233. }
  1234. });
  1235. Object.defineProperty(HTMLElement.prototype, 'onerror', {
  1236. set: function(func) {
  1237. if (evtMap.has(this)) {
  1238. evtMap.get(this).onerror = func;
  1239. } else {
  1240. evtMap.set(this, { onerror: func });
  1241. }
  1242. if (func) {
  1243. console.log('Blocked error handler', toString.call(func), 'on', this);
  1244. }
  1245. return func;
  1246. },
  1247. get: function() {
  1248. return evtMap.has(this) ? evtMap.get(this).onerror : null;
  1249. }
  1250. });
  1251. }
  1252. /**/
  1253.  
  1254. // === Scripts for specific domains ===
  1255.  
  1256. var scripts = {};
  1257. // prevent popups and redirects block
  1258. var preventPopupsNow = { 'now': preventPopups },
  1259. preventBackgroundRedirectNow = { 'now': preventBackgroundRedirect };
  1260. // Popups
  1261. scripts['biqle.ru'] = preventPopupsNow;
  1262. scripts['chaturbate.com'] = preventPopupsNow;
  1263. scripts['dfiles.ru'] = preventPopupsNow;
  1264. scripts['hentaiz.org'] = preventPopupsNow;
  1265. scripts['mirrorcreator.com'] = preventPopupsNow;
  1266. scripts['online-multy.ru'] = preventPopupsNow;
  1267. scripts['openload.co'] = preventPopupsNow;
  1268. scripts['radikal.ru'] = preventPopupsNow;
  1269. scripts['seedoff.cc'] = preventPopupsNow;
  1270. scripts['seedoff.tv'] = preventPopupsNow;
  1271. scripts['tapochek.net'] = preventPopupsNow;
  1272. scripts['thepiratebay.org'] = preventPopupsNow;
  1273. scripts['torseed.net'] = preventPopupsNow;
  1274. scripts['zippyshare.com'] = preventPopupsNow;
  1275. // Background redirects
  1276. scripts['mediafire.com'] = preventBackgroundRedirectNow;
  1277. scripts['megapeer.org'] = preventBackgroundRedirectNow;
  1278. scripts['megapeer.ru'] = preventBackgroundRedirectNow;
  1279. scripts['perfectgirls.net'] = preventBackgroundRedirectNow;
  1280. scripts['turbobit.net'] = preventBackgroundRedirectNow;
  1281.  
  1282. // other
  1283. scripts['4pda.ru'] = {
  1284. 'now': function() {
  1285. // https://greasyfork.org/en/scripts/14470-4pda-unbrender
  1286. var isForum = document.location.href.search('/forum/') !== -1,
  1287. hStyle;
  1288.  
  1289. function remove(n) {
  1290. if (n) {
  1291. n.parentNode.removeChild(n);
  1292. }
  1293. }
  1294.  
  1295. function afterClean() {
  1296. hStyle.disabled = true;
  1297. remove(hStyle);
  1298. }
  1299.  
  1300. function beforeClean() {
  1301. // attach styles before document displayed
  1302. hStyle = createStyle([
  1303. 'html { overflow-y: scroll }',
  1304. 'section[id] {'+(
  1305. 'position: absolute;'+
  1306. 'width: 100%'
  1307. )+'}',
  1308. 'article + aside * { display: none !important }',
  1309. '#header + div:after {'+(
  1310. 'content: "";'+
  1311. 'position: fixed;'+
  1312. 'top: 0;'+
  1313. 'left: 0;'+
  1314. 'width: 100%;'+
  1315. 'height: 100%;'+
  1316. 'background-color: #E6E7E9'
  1317. )+'}',
  1318. // http://codepen.io/Beaugust/pen/DByiE
  1319. '@keyframes spin { 100% { transform: rotate(360deg) } }',
  1320. 'article + aside:after {'+(
  1321. 'content: "";'+
  1322. 'position: absolute;'+
  1323. 'width: 150px;'+
  1324. 'height: 150px;'+
  1325. 'top: 150px;'+
  1326. 'left: 50%;'+
  1327. 'margin-top: -75px;'+
  1328. 'margin-left: -75px;'+
  1329. 'box-sizing: border-box;'+
  1330. 'border-radius: 100%;'+
  1331. 'border: 10px solid rgba(0, 0, 0, 0.2);'+
  1332. 'border-top-color: rgba(0, 0, 0, 0.6);'+
  1333. 'animation: spin 2s infinite linear'
  1334. )+'}'
  1335. ], {id:'ubrHider'}, true);
  1336.  
  1337. // display content of a page if time to load a page is more than 2 seconds to avoid
  1338. // blocking access to a page if it is loading for too long or stuck in a loading state
  1339. setTimeout(2000, afterClean);
  1340. }
  1341.  
  1342. createStyle([
  1343. '#nav .use-ad { display: block !important }',
  1344. 'article:not(.post) + article:not(#id), a[target="_blank"] img[height="90"] { display: none !important }'
  1345. ]);
  1346.  
  1347. if (!isForum) {
  1348. beforeClean();
  1349. }
  1350.  
  1351. // save links to non-overridden functions to use later
  1352. var protectedElems;
  1353. // protect/hide changed attributes in case site attempt to restore them
  1354. function styleProtector(eventMode) {
  1355. var isStyleText = function(t){ return t === 'style'; },
  1356. returnUndefined = function(){},
  1357. protectedElems = new WeakMap();
  1358. function protoOverride(element, functionName, isStyleCheck, returnIfProtected) {
  1359. var oF = element.prototype[functionName], r;
  1360. element.prototype[functionName] = function() {
  1361. if (protectedElems.has(this) && isStyleCheck(arguments[0])) {
  1362. return returnIfProtected(this, arguments);
  1363. }
  1364. r = oF.apply(this, arguments);
  1365. return r;
  1366. };
  1367. }
  1368. protoOverride(Element, 'removeAttribute', isStyleText, returnUndefined);
  1369. protoOverride(Element, 'hasAttribute', isStyleText, function(_this) {
  1370. return protectedElems.get(_this) !== null;
  1371. });
  1372. protoOverride(Element, 'setAttribute', isStyleText, function(_this, args) {
  1373. protectedElems.set(_this, args[1]);
  1374. });
  1375. protoOverride(Element, 'getAttribute', isStyleText, function(_this) {
  1376. return protectedElems.get(_this);
  1377. });
  1378. if (eventMode) {
  1379. var e = document.createEvent('Event');
  1380. e.initEvent('protoOverride', false, false);
  1381. window.protectedElems = protectedElems;
  1382. window.dispatchEvent(e);
  1383. } else {
  1384. return protectedElems;
  1385. }
  1386. }
  1387. if (isFirefox) {
  1388. var s = document.createElement('script');
  1389. s.textContent = '(' + styleProtector.toString() + ')(true);';
  1390. window.addEventListener('protoOverride', function protoOverrideCallback(e){
  1391. if (win.protectedElems) {
  1392. protectedElems = win.protectedElems;
  1393. delete win.protectedElems;
  1394. }
  1395. document.removeEventListener('protoOverride', protoOverrideCallback, true);
  1396. }, true);
  1397. _appendChild(s);
  1398. _removeChild(s);
  1399. } else {
  1400. protectedElems = styleProtector(false);
  1401. }
  1402.  
  1403. // clean a page
  1404. window.addEventListener('DOMContentLoaded', function(){
  1405. var rem, si, itm;
  1406. function width(){ return window.innerWidth||_de.clientWidth||document.body.clientWidth||0; }
  1407. function height(){ return window.innerHeight||_de.clientHeight||document.body.clientHeight||0; }
  1408.  
  1409.  
  1410. if (isForum) {
  1411. si = document.querySelector('#logostrip');
  1412. if (si) {
  1413. remove(si.parentNode.nextSibling);
  1414. }
  1415. }
  1416.  
  1417. if (document.location.href.search('/forum/dl/') !== -1) {
  1418. document.body.setAttribute('style', (document.body.getAttribute('style')||'')+
  1419. ';background-color:black!important');
  1420. for (itm of document.querySelectorAll('body>div')) {
  1421. if (!itm.querySelector('.dw-fdwlink')) {
  1422. remove(itm);
  1423. }
  1424. }
  1425. }
  1426.  
  1427. if (isForum) { // Do not continue if it's a forum
  1428. return;
  1429. }
  1430.  
  1431. si = document.querySelector('#header');
  1432. if (si) {
  1433. rem = si.previousSibling;
  1434. while (rem) {
  1435. si = rem.previousSibling;
  1436. remove(rem);
  1437. rem = si;
  1438. }
  1439. }
  1440.  
  1441. for (itm of document.querySelectorAll('#nav li[class]')) {
  1442. if (itm && itm.querySelector('a[href^="/tag/"]')) {
  1443. remove(itm);
  1444. }
  1445. }
  1446.  
  1447. var style, result, fakeStyle,
  1448. fakeStyles = new WeakMap(),
  1449. styleProxy = {
  1450. get: function(target, prop) {
  1451. fakeStyle = fakeStyles.get(target);
  1452. if (fakeStyle.hasOwnProperty(prop)) {
  1453. return fakeStyle[prop];
  1454. } else {
  1455. return target[prop];
  1456. }
  1457. },
  1458. set: function(target, prop, value) {
  1459. fakeStyle = fakeStyles.get(target);
  1460. if (fakeStyle.hasOwnProperty(prop)) {
  1461. fakeStyle[prop] = value;
  1462. } else {
  1463. target[prop] = value;
  1464. }
  1465. return value;
  1466. }
  1467. };
  1468. for (itm of document.querySelectorAll('DIV, A')) {
  1469. if (itm.tagName ==='DIV' && itm.offsetWidth > 0.95 * width() && itm.offsetHeight > 0.85 * height()) {
  1470. style = window.getComputedStyle(itm, null);
  1471. result = [];
  1472. if (style.backgroundImage !== 'none') {
  1473. result.push('background-image:none!important');
  1474. }
  1475. if (style.backgroundColor !== 'transparent' &&
  1476. style.backgroundColor !== 'rgba(0, 0, 0, 0)') {
  1477. result.push('background-color:transparent!important');
  1478. }
  1479. if (result.length) {
  1480. if (itm.getAttribute('style')) {
  1481. result.unshift(itm.getAttribute('style'));
  1482. }
  1483. fakeStyles.set(itm.style, {
  1484. 'backgroundImage': itm.style.backgroundImage,
  1485. 'backgroundColor': itm.style.backgroundColor
  1486. });
  1487. try {
  1488. Object.defineProperty(itm, 'style', {
  1489. value: new Proxy(itm.style, styleProxy),
  1490. enumerable: true
  1491. });
  1492. } catch (e) {
  1493. console.log('Unable to protect style property.', e);
  1494. }
  1495. if (protectedElems) {
  1496. protectedElems.set(itm, _getAttribute.call(itm, 'style'));
  1497. }
  1498. _setAttribute.call(itm, 'style', result.join(';'));
  1499. }
  1500. }
  1501. if (itm.tagName ==='A' && (itm.offsetWidth > 0.95 * width() || itm.offsetHeight > 0.85 * height())) {
  1502. if (protectedElems) {
  1503. protectedElems.set(itm, _getAttribute.call(itm, 'style'));
  1504. }
  1505. _setAttribute.call(itm, 'style', 'display:none!important');
  1506. }
  1507. }
  1508.  
  1509. for (itm of document.querySelectorAll('ASIDE>DIV')) {
  1510. if ( ((itm.querySelector('script, iframe, a[href*="/ad/www/"]') ||
  1511. itm.querySelector('img[src$=".gif"]:not([height="0"]), img[height="400"]')) &&
  1512. !itm.classList.contains('post') ) || !itm.childNodes.length ) {
  1513. remove(itm);
  1514. }
  1515. }
  1516.  
  1517. document.body.setAttribute('style', (document.body.getAttribute('style')||'')+';background-color:#E6E7E9!important');
  1518.  
  1519. // display content of the page
  1520. afterClean();
  1521. });
  1522. }
  1523. };
  1524.  
  1525. scripts['allmovie.pro'] = function() {
  1526. // pretend to be Android to make site use different played for ads
  1527. if (isSafari) {
  1528. return;
  1529. }
  1530. Object.defineProperty(navigator, 'userAgent', {
  1531. 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'; },
  1532. enumerable: true
  1533. });
  1534. };
  1535. scripts['rufilmtv.org'] = scripts['allmovie.pro'];
  1536.  
  1537. scripts['anidub-online.ru'] = function() {
  1538. var script = document.createElement('script');
  1539. script.type = "text/javascript";
  1540. script.innerHTML = "function ogonekstart1() {}";
  1541. document.getElementsByTagName('head')[0].appendChild(script);
  1542.  
  1543. var style = document.createElement('style');
  1544. style.type = 'text/css';
  1545. style.appendChild(document.createTextNode('.background {background: none!important;}'));
  1546. style.appendChild(document.createTextNode('.background > script + div, .background > script ~ div:not([id]):not([class]) + div[id][class] {display:none!important}'));
  1547. document.head.appendChild(style);
  1548. };
  1549. scripts['online.anidub.com'] = scripts['anidub-online.ru'];
  1550.  
  1551. scripts['fs.to'] = function() {
  1552. function skipClicker(i) {
  1553. if (!i) {
  1554. return;
  1555. }
  1556. var skip = document.querySelector('.b-aplayer-banners__close');
  1557. if (skip) {
  1558. skip.click();
  1559. } else {
  1560. setTimeout(skipClicker, 100, i-1);
  1561. }
  1562. }
  1563. setTimeout(skipClicker, 100, 30);
  1564.  
  1565. createStyle([
  1566. '.l-body-branding *,'+
  1567. '.b-styled__item-central,'+
  1568. '.b-styled__content-right,'+
  1569. '.b-styled__section-central,'+
  1570. 'div[id^="adsProxy-"]'+
  1571. '{display:none!important}',
  1572. 'body {background-image:url(data:image/png;base64,'+
  1573. 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAACX'+
  1574. 'BIWXMAAC4jAAAuIwF4pT92AAAADUlEQVR42mOQUdL5DwACMgFq'+
  1575. 'BC3ttwAAAABJRU5ErkJggg==)!important}'
  1576. ]);
  1577.  
  1578. if (/\/(view_iframe|iframeplayer)\//i.test(document.location.pathname)) {
  1579. var p = document.querySelector('#player:not([preload="auto"])'),
  1580. m = document.querySelector('.main'),
  1581. adStepper = function(p) {
  1582. if (p.currentTime < p.duration) {
  1583. p.currentTime += 1;
  1584. }
  1585. },
  1586. adSkipper = function(f, p) {
  1587. f.click();
  1588. p.waitAfterSkip = false;
  1589. p.longerSkipper = false;
  1590. console.log('Пропустили.');
  1591. },
  1592. cl = function(p) {
  1593. var faster = document.querySelector('.b-aplayer__html5-desktop-skip'),
  1594. series = document.querySelector('.b-aplayer__actions-series');
  1595.  
  1596. function clickSelected() {
  1597. var s = document.querySelector('.b-aplayer__popup-series-episodes .selected a');
  1598. if (s) {
  1599. s.click();
  1600. }
  1601. }
  1602.  
  1603. if ((!faster || faster.style.display !== 'block') && series && !p.seriesClicked) {
  1604. series.click();
  1605. p.seriesClicked = true;
  1606. p.longerSkipper = true;
  1607. setTimeout(clickSelected, 1000);
  1608. p.pause();
  1609. }
  1610.  
  1611. function skipListener() {
  1612. if (p.waitAfterSkip) {
  1613. console.log('В процессе пропуска…');
  1614. return;
  1615. }
  1616. p.pause();
  1617. if (!p.classList.contains('m-hidden')) {
  1618. p.classList.add('m-hidden');
  1619. }
  1620. if (faster && p.currentTime &&
  1621. win.getComputedStyle(faster).display === 'block' &&
  1622. !faster.querySelector('.b-aplayer__html5-desktop-skip-timer')) {
  1623. p.waitAfterSkip = true;
  1624. setTimeout(adSkipper, (p.longerSkipper?3:1)*1000, faster, p);
  1625. console.log('Доступен быстрый пропуск…');
  1626. } else {
  1627. setTimeout(adStepper, 1000, p);
  1628. }
  1629. }
  1630.  
  1631. p.addEventListener('timeupdate', skipListener, false);
  1632. };
  1633. if (p.nodeName === 'VIDEO') {
  1634. cl(p);
  1635. } else {
  1636. (new MutationObserver(function (ms) {
  1637. var m, node;
  1638. for (m of ms) {
  1639. for (node of m.addedNodes) {
  1640. if (node.id === 'player' &&
  1641. node.nodeName === 'VIDEO' &&
  1642. _getAttribute.call(node, 'preload') !== 'auto') {
  1643. cl(node);
  1644. }
  1645. }
  1646. }
  1647. })).observe(m, {childList: true});
  1648. }
  1649. }
  1650. };
  1651. scripts['brb.to'] = scripts['fs.to'];
  1652. scripts['cxz.to'] = scripts['fs.to'];
  1653.  
  1654. scripts['drive2.ru'] = function() {
  1655. gardener('.c-block:not([data-metrika="recomm"]),.o-grid__item', />Реклама<\//i);
  1656. };
  1657.  
  1658. scripts['fishki.net'] = function() {
  1659. gardener('.drag_list > .drag_element, .list-view > .paddingtop15, .post-wrap', /543769|Новости\sпартнеров/);
  1660. };
  1661.  
  1662. scripts['gidonline.club'] = {
  1663. 'now': function() {
  1664. createStyle('.tray > div[style] {display: none!important}');
  1665. }
  1666. };
  1667. scripts['gidonlinekino.com'] = scripts['gidonline.club'];
  1668.  
  1669. scripts['hdgo.cc'] = {
  1670. 'now': function(){
  1671. (new MutationObserver(function(ms) {
  1672. var m, node;
  1673. for (m of ms) {
  1674. for (node of m.addedNodes) {
  1675. if (node.tagName === 'SCRIPT' && _getAttribute(node, 'onerror') !== null) {
  1676. node.removeAttribute('onerror');
  1677. }
  1678. }
  1679. }
  1680. })).observe(document, {childList:true, subtree: true});
  1681. }
  1682. };
  1683. scripts['couber.be'] = scripts['hdgo.cc'];
  1684. scripts['46.30.43.38'] = scripts['hdgo.cc'];
  1685.  
  1686. scripts['gismeteo.ru'] = {
  1687. 'DOMContentLoaded': function() {
  1688. gardener('div > a[target^="_"]', /Яндекс\.Директ/i, { root: 'body', observe: true, parent: 'div[class*="frame"]' });
  1689. }
  1690. };
  1691.  
  1692. scripts['hdrezka.me'] = {
  1693. 'now': function() {
  1694. Object.defineProperty(win, 'fuckAdBlock', {
  1695. value: {
  1696. onDetected: function() {
  1697. console.log('Pretending to be an ABP detector.');
  1698. }
  1699. }
  1700. });
  1701. Object.defineProperty(win, 'ab', {
  1702. value: false,
  1703. enumerable: true
  1704. });
  1705. },
  1706. 'DOMContentLoaded': function() {
  1707. gardener('div[id][onclick][onmouseup][onmousedown]', /onmouseout/i);
  1708. }
  1709. };
  1710.  
  1711. scripts['imageban.ru'] = {
  1712. 'now': preventBackgroundRedirect,
  1713. 'DOMContentLoaded': function() {
  1714. win.addEventListener('unload', function() {
  1715. if (!window.location.hash) {
  1716. window.location.replace(window.location+'#');
  1717. } else {
  1718. window.location.hash = '';
  1719. }
  1720. }, true);
  1721. }
  1722. };
  1723.  
  1724. scripts['e.mail.ru'] = function() {
  1725. /*gardener('#LEGO :not([data-mnemo])>.js-href[data-id]',
  1726. /data:image.*>Реклама<|>Реклама<.*\/\/favicon\./i,
  1727. {root:'#LEGO', observe: true, parent:'div[id][class]'});*/
  1728. };
  1729.  
  1730. scripts['mail.ru'] = {
  1731. 'now': function() {
  1732. // Trick to prevent mail.ru from removing 3rd-party styles
  1733. scriptLander(function(){
  1734. Object.defineProperty(Object.prototype, 'restoreVisibility', {
  1735. get: function() { return function(){}; },
  1736. set: function() {}
  1737. });
  1738. });
  1739. }
  1740. };
  1741.  
  1742. scripts['megogo.net'] = {
  1743. 'now': function() {
  1744. Object.defineProperty(win, "adBlock", {
  1745. value : false,
  1746. enumerable : true
  1747. });
  1748. Object.defineProperty(win, "showAdBlockMessage", {
  1749. value : function () {},
  1750. enumerable : true
  1751. });
  1752. }
  1753. };
  1754.  
  1755. scripts['naruto-base.su'] = function() {
  1756. gardener('div[id^="entryID"],.block', /href="http.*?target="_blank"/i);
  1757. };
  1758.  
  1759. scripts['overclockers.ru'] = {
  1760. 'now': function() {
  1761. createStyle('.fixoldhtml {display:block!important}');
  1762. if (!isChrome && !isOpera) {
  1763. return; // Looks like my code works only in Chrome-like browsers
  1764. }
  1765. var noContentYet = true;
  1766. function jWrap() {
  1767. var _$ = win.$, _e = _$.extend;
  1768. win.$ = function() {
  1769. var _ret = _$.apply(window, arguments);
  1770. if (_ret[0] === document.body) {
  1771. _ret.html = function() {
  1772. console.log('Anti-adblock prevented.');
  1773. };
  1774. }
  1775. return _ret;
  1776. };
  1777. win.$.extend = function() {
  1778. return _e.apply(_$, arguments);
  1779. };
  1780. win.jQuery = win.$;
  1781. }
  1782. (function jReady() {
  1783. if (!win.$ && noContentYet) {
  1784. setTimeout(jReady, 0);
  1785. } else {
  1786. jWrap();
  1787. }
  1788. })();
  1789. document.addEventListener ('DOMContentLoaded', function(){
  1790. noContentYet = false;
  1791. }, false);
  1792. }
  1793. };
  1794. scripts['forums.overclockers.ru'] = {
  1795. 'now': function() {
  1796. createStyle('.needblock {position: fixed; left: -10000px}');
  1797. Object.defineProperty(win, 'adblck', {
  1798. value: 'no',
  1799. enumerable: true
  1800. });
  1801. }
  1802. };
  1803.  
  1804. scripts['pb.wtf'] = function() {
  1805. createStyle('.reques,#result,tbody.row1:not([id]) {display: none !important}');
  1806. // image in the slider in the header
  1807. gardener('a[href^="/ex"],a[href$="=="]', /img/i, {root:'.release-navbar', observe:true, parent:'div'});
  1808. // ads in blocks on the page
  1809. gardener('a[href^="/topic/234257"]', /Как\sразместить/i, {siblings:-1, root:'#main_content', observe:true, parent:'span[style]'});
  1810. // line above topic content
  1811. gardener('.re_top1', /./, {root:'#main_content', parent:'.hidden-sm'});
  1812. };
  1813. scripts['piratbit.org'] = scripts['pb.wtf'];
  1814. scripts['piratbit.ru'] = scripts['pb.wtf'];
  1815.  
  1816. scripts['pikabu.ru'] = function() {
  1817. gardener('.story', /story__sponsor|story__gag|profile\/ads"/i, {root: '.inner_wrap', observe: true});
  1818. };
  1819.  
  1820. scripts['rp5.ru'] = function() {
  1821. createStyle('#bannerBottom {display: none!important}');
  1822. var co = document.querySelector('#content'), i, nodes;
  1823. if (!co) {
  1824. return;
  1825. }
  1826. nodes = co.parentNode.childNodes;
  1827. i = nodes.length;
  1828. while (i--) {
  1829. if (nodes[i] !== co) {
  1830. nodes[i].parentNode.removeChild(nodes[i]);
  1831. }
  1832. }
  1833. };
  1834. scripts['rp5.by'] = scripts['rp5.ru'];
  1835. scripts['rp5.ua'] = scripts['rp5.ru'];
  1836.  
  1837. scripts['rustorka.com'] = {
  1838. 'now': function() {
  1839. createStyle('.header > div:not(.head-block) a, #sidebar1 img, #logo img {opacity:0!important}', {
  1840. id: 'tempHidingStyles'
  1841. }, true);
  1842. preventPopups();
  1843. },
  1844. 'DOMContentLoaded': function() {
  1845. for (var o of document.querySelectorAll('IMG, A')) {
  1846. if ((o.clientWidth === 728 && o.clientHeight === 90) ||
  1847. (o.clientWidth === 300 && o.clientHeight === 250)) {
  1848. while (o && o.tagName !== 'A') {
  1849. o = o.parentNode;
  1850. }
  1851. if (o) {
  1852. _setAttribute.call(o, 'style', 'display: none !important');
  1853. }
  1854. }
  1855. }
  1856. var s = document.querySelector('#tempHidingStyles');
  1857. s.parentNode.removeChild(s);
  1858. }
  1859. };
  1860. scripts['rumedia.ws'] = scripts['rustorka.com'];
  1861.  
  1862. scripts['sport-express.ru'] = function() {
  1863. gardener('.js-relap__item',/>Реклама\s+<\//, {root:'.container', observe: true});
  1864. };
  1865.  
  1866. scripts['sports.ru'] = function() {
  1867. gardener('.aside-news-list__item', /aside-news-list__advert/i, {root:'.columns-layout__left', observe: true});
  1868. gardener('.material-list__item', /Реклама/i, {root:'.columns-layout', observe: true});
  1869. // extra functionality: shows/hides panel at the top depending on scroll direction
  1870. createStyle([
  1871. '.user-panel__fixed { transition: top 0.2s ease-in-out!important; }',
  1872. '.user-panel-up { top: -40px!important }'
  1873. ], {id: 'userPanelSlide'}, false);
  1874. (function lookForPanel() {
  1875. var panel = document.querySelector('.user-panel__fixed');
  1876. if (!panel) {
  1877. setTimeout(lookForPanel, 100);
  1878. } else {
  1879. window.addEventListener('wheel', function(e){
  1880. if (e.deltaY > 0 && !panel.classList.contains('user-panel-up')) {
  1881. panel.classList.add('user-panel-up');
  1882. } else
  1883. if (e.deltaY < 0 && panel.classList.contains('user-panel-up')) {
  1884. panel.classList.remove('user-panel-up');
  1885. }
  1886. }, false);
  1887. }
  1888. })();
  1889. };
  1890.  
  1891. scripts['www.ukr.net'] = scripts['sinoptik.com.ru'];
  1892.  
  1893. scripts['vk.com'] = function() {
  1894. gardener('div[data-post-id]', /wall_marked_as_ads/, {root: '#page_wall_posts', observe: true});
  1895. };
  1896.  
  1897. scripts['yap.ru'] = function() {
  1898. gardener('form > table[id^="p_row_"]:nth-of-type(2)', /member1438|Administration/);
  1899. gardener('.icon-comments', /\/go\/\?http/, {parent:'tr', siblings:-2});
  1900. };
  1901. scripts['yaplakal.com'] = scripts['yap.ru'];
  1902.  
  1903. scripts['rambler.ru'] = {
  1904. 'now': function() {
  1905. scriptLander(function() {
  1906. var _createElement = Document.prototype.createElement,
  1907. loadMap = new WeakMap();
  1908. Document.prototype.createElement = function createElement(name) {
  1909. /*jshint validthis:true */
  1910. var el = _createElement.apply(this, arguments);
  1911. if (el.tagName === 'LINK') {
  1912. Object.defineProperty(el, 'onload', {
  1913. get: function() {
  1914. return loadMap.get(loadMap.get(this));
  1915. },
  1916. set: function(func) {
  1917. var wrap = loadMap.get(this),
  1918. isContent = /\{\s*content\s*:\s*"[^"]+"/i;
  1919. if (wrap) {
  1920. this.removeEventListener('load', wrap, false);
  1921. loadMap.remove(wrap);
  1922. loadMap.remove(this);
  1923. }
  1924. wrap = function(e) {
  1925. if (e.target && e.target.sheet && e.target.sheet.cssRules &&
  1926. e.target.sheet.cssRules[0] && e.target.sheet.cssRules[0].cssText &&
  1927. isContent.test(e.target.sheet.cssRules[0].cssText)) {
  1928. console.log('Blocked "onload" for', e.target.href);
  1929. return false;
  1930. }
  1931. return func.apply(this, arguments);
  1932. };
  1933. loadMap.set(this, wrap);
  1934. loadMap.set(wrap, func);
  1935. this.addEventListener('load', wrap, false);
  1936. },
  1937. enumberable: true
  1938. });
  1939. }
  1940. return el;
  1941. };
  1942. });
  1943. }
  1944. };
  1945.  
  1946. scripts['reactor.cc'] = {
  1947. 'now': function() {
  1948. win.open = (function(){ throw new Error('Redirect prevention.'); }).bind(window);
  1949. },
  1950. 'click': function(e) {
  1951. var node = e.target;
  1952. if (node.nodeType === Node.ELEMENT_NODE &&
  1953. node.style.position === 'absolute' &&
  1954. node.style.zIndex > 0)
  1955. node.parentNode.removeChild(node);
  1956. },
  1957. 'DOMContentLoaded': function() {
  1958. var words = new RegExp(
  1959. 'блокировщика рекламы'
  1960. .split('')
  1961. .map(function(e){return e+'[\u200b\u200c\u200d]*';})
  1962. .join('')
  1963. .replace(' ', '\\s*')
  1964. .replace(/[аоре]/g, function(e){return ['[аa]','[оo]','[рp]','[еe]']['аоре'.indexOf(e)];}),
  1965. 'i'),
  1966. can;
  1967. function deeper(spider) {
  1968. var c, l, n;
  1969. if (words.test(spider.innerText)) {
  1970. if (spider.nodeType === Node.TEXT_NODE) {
  1971. return true;
  1972. }
  1973. c = spider.childNodes;
  1974. l = c.length;
  1975. n = 0;
  1976. while(l--) {
  1977. if (deeper(c[l]), can) {
  1978. n++;
  1979. }
  1980. }
  1981. if (n > 0 && n === c.length && spider.offsetHeight < 750) {
  1982. can.push(spider);
  1983. }
  1984. return false;
  1985. }
  1986. return true;
  1987. }
  1988. function probe(){
  1989. if (words.test(document.body.innerText)) {
  1990. can = [];
  1991. deeper(document.body);
  1992. var i = can.length, spider;
  1993. while(i--) {
  1994. spider = can[i];
  1995. if (spider.offsetHeight > 10 && spider.offsetHeight < 750) {
  1996. _setAttribute.call(spider, 'style', 'background:none!important');
  1997. }
  1998. }
  1999. }
  2000. }
  2001. (new MutationObserver(probe)).observe(document,{childList:true, subtree:true});
  2002. }
  2003. };
  2004. scripts['joyreactor.cc'] = scripts['reactor.cc'];
  2005. scripts['pornreactor.cc'] = scripts['reactor.cc'];
  2006.  
  2007. scripts['auto.ru'] = function() {
  2008. var words = /Реклама|Яндекс.Директ|yandex_ad_/;
  2009. var userAdsListAds = [
  2010. '.listing-list > .listing-item',
  2011. '.listing-item_type_fixed.listing-item'
  2012. ];
  2013. var catalogAds = [
  2014. 'div[class*="layout_catalog-inline"]',
  2015. 'div[class$="layout_horizontal"]'
  2016. ];
  2017. var otherAds = [
  2018. '.advt_auto',
  2019. '.sidebar-block',
  2020. '.pager-listing + div[class]',
  2021. '.card > div[class][style]',
  2022. '.sidebar > div[class]',
  2023. '.main-page__section + div[class]',
  2024. '.listing > tbody'];
  2025. gardener(userAdsListAds.join(','), words, {root:'.listing-wrap', observe:true});
  2026. gardener(catalogAds.join(','), words, {root:'.catalog__page,.content__wrapper', observe:true});
  2027. gardener(otherAds.join(','), words);
  2028. };
  2029.  
  2030. scripts['rsload.net'] = {
  2031. 'load': function() {
  2032. var dis = document.querySelector('label[class*="cb-disable"]');
  2033. if (dis) {
  2034. dis.click();
  2035. }
  2036. },
  2037. 'click': function(e) {
  2038. var t = e.target;
  2039. if (t && t.href && (/:\/\/\d+\.\d+\.\d+\.\d+\//.test(t.href))) {
  2040. t.href = t.href.replace('://','://rsload.net:rsload.net@');
  2041. }
  2042. }
  2043. };
  2044.  
  2045. var domain = document.domain, name;
  2046. while (domain.indexOf('.') !== -1) {
  2047. if (scripts.hasOwnProperty(domain)) {
  2048. if (typeof scripts[domain] === 'function') {
  2049. document.addEventListener ('DOMContentLoaded', scripts[domain], false);
  2050. }
  2051. for (name in scripts[domain]) {
  2052. if (name !== 'now') {
  2053. (name === 'load' ? window : document)
  2054. .addEventListener (name, scripts[domain][name], false);
  2055. } else {
  2056. scripts[domain][name]();
  2057. }
  2058. }
  2059. }
  2060. domain = domain.slice(domain.indexOf('.') + 1);
  2061. }
  2062. })();