RU AdList JS Fixes

try to take over the world!

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

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