RU AdList JS Fixes

try to take over the world!

目前為 2016-10-27 提交的版本,檢視 最新版本

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