RU AdList JS Fixes

try to take over the world!

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

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