RU AdList JS Fixes

try to take over the world!

目前为 2016-11-03 提交的版本。查看 最新版本

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