RU AdList JS Fixes

try to take over the world!

目前為 2016-11-02 提交的版本,檢視 最新版本

  1. // ==UserScript==
  2. // @name RU AdList JS Fixes
  3. // @namespace ruadlist_js_fixes
  4. // @version 20161103.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. }
  569. node = nodes.pop();
  570. }
  571. }
  572. // News fixes
  573. function removePageAdsClass() {
  574. if (document.body.classList.contains("b-page_ads_yes")){
  575. document.body.classList.remove("b-page_ads_yes");
  576. console.log('Page ads class removed.');
  577. }
  578. }
  579. // Function to attach an observer to monitor dynamic changes on the page
  580. function pageUpdateObserver(func, obj, params) {
  581. if (obj) {
  582. var o = new MutationObserver(func);
  583. o.observe(obj,(params || {childList:true, subtree:true}));
  584. }
  585. }
  586. // Cleaner
  587. document.addEventListener ('DOMContentLoaded', function() {
  588. removeGenericAds();
  589. if (win.location.hostname.search(/^mail\./i) === 0) {
  590. pageUpdateObserver(function(ms, o){
  591. var aside = document.querySelector('.mail-Layout-Aside');
  592. if (aside) {
  593. o.disconnect();
  594. pageUpdateObserver(removeMailAds, aside);
  595. }
  596. }, document.querySelector('BODY'));
  597. removeMailAds();
  598. } else if (win.location.hostname.search(/^music\./i) === 0) {
  599. pageUpdateObserver(removeMusicAds, document.querySelector('.sidebar'));
  600. removeMusicAds();
  601. } else if (win.location.hostname.search(/^news\./i) === 0) {
  602. pageUpdateObserver(removeNewsAds, document.querySelector('BODY'));
  603. pageUpdateObserver(removePageAdsClass, document.body, {attributes:true, attributesFilter:['class']});
  604. removeNewsAds();
  605. removePageAdsClass();
  606. } else {
  607. pageUpdateObserver(removeSearchAds, document.querySelector('.main__content'));
  608. removeSearchAds();
  609. }
  610. });
  611. })();
  612. return; //skip fixes for other sites
  613. }
  614.  
  615. // https://greasyfork.org/en/scripts/14470-4pda-unbrender
  616. if (/(^|\.)4pda\.ru$/i.test(window.location.hostname)) {
  617. (function() {
  618. var isForum = document.location.href.search('/forum/') !== -1,
  619. hStyle;
  620.  
  621. function remove(n) {
  622. if (n) {
  623. n.parentNode.removeChild(n);
  624. }
  625. }
  626.  
  627. function afterClean() {
  628. hStyle.disabled = true;
  629. remove(hStyle);
  630. }
  631.  
  632. function beforeClean() {
  633. // attach styles before document displayed
  634. hStyle = createStyle([
  635. 'html { overflow-y: scroll }',
  636. 'article + aside * { display: none !important }',
  637. '#header + div:after {'+(
  638. 'content: "";'+
  639. 'position: fixed;'+
  640. 'top: 0;'+
  641. 'left: 0;'+
  642. 'width: 100%;'+
  643. 'height: 100%;'+
  644. 'background-color: #E6E7E9'
  645. )+'}',
  646. // http://codepen.io/Beaugust/pen/DByiE
  647. '@keyframes spin { 100% { transform: rotate(360deg) } }',
  648. 'article + aside:after {'+(
  649. 'content: "";'+
  650. 'position: absolute;'+
  651. 'width: 150px;'+
  652. 'height: 150px;'+
  653. 'top: 150px;'+
  654. 'left: 50%;'+
  655. 'margin-top: -75px;'+
  656. 'margin-left: -75px;'+
  657. 'box-sizing: border-box;'+
  658. 'border-radius: 100%;'+
  659. 'border: 10px solid rgba(0, 0, 0, 0.2);'+
  660. 'border-top-color: rgba(0, 0, 0, 0.6);'+
  661. 'animation: spin 2s infinite linear'
  662. )+'}'
  663. ], {id:'ubrHider'}, true);
  664.  
  665. // display content of a page if time to load a page is more than 2 seconds to avoid
  666. // blocking access to a page if it is loading for too long or stuck in a loading state
  667. setTimeout(2000, afterClean);
  668. }
  669.  
  670. createStyle([
  671. '#nav .use-ad { display: block !important }',
  672. 'article:not(.post) + article:not(#id), a[target="_blank"] img[height="90"] { display: none !important }'
  673. ]);
  674.  
  675. if (!isForum) {
  676. beforeClean();
  677. }
  678.  
  679. // save links to non-overridden functions to use later
  680. var oGA = Element.prototype.getAttribute,
  681. oSA = Element.prototype.setAttribute,
  682. protectedElems;
  683. // protect/hide changed attributes in case site attempt to restore them
  684. function styleProtector(eventMode) {
  685. var oRAN = Element.prototype.removeAttributeNode,
  686. isStyleText = function(t){ return t === 'style'; },
  687. isStyleAttr = function(a){ return a instanceof Attr && a.nodeName === 'style'; },
  688. returnUndefined = function(){},
  689. protectedElems = new WeakMap();
  690. function protoOverride(element, functionName, isStyleCheck, returnIfProtected) {
  691. var oF = element.prototype[functionName];
  692. element.prototype[functionName] = function(){
  693. if (protectedElems.get(this) !== undefined && isStyleCheck(arguments[0])) {
  694. return returnIfProtected(protectedElems.get(this), arguments, this);
  695. }
  696. return oF.apply(this, arguments);
  697. };
  698. }
  699. protoOverride(Element, 'removeAttribute', isStyleText, returnUndefined);
  700. protoOverride(Element, 'removeAttributeNS', isStyleText, returnUndefined);
  701. protoOverride(Element, 'removeAttributeNode', isStyleAttr, function(o, args, node) {
  702. if (args[0] instanceof Attr && args[0].ownerElement !== node) {
  703. // throw 'attribute of another element' error
  704. oRAN.call(node, document.createAttribute('style'));
  705. }
  706. if (o.oldStyle === null) {
  707. // throw 'not an Attr' error
  708. oRAN.call(node, null);
  709. }
  710. o.oldStyle = null;
  711. return args[0];
  712. });
  713. protoOverride(Element, 'hasAttribute', isStyleText, function(o) {
  714. return o.oldStyle !== null;
  715. });
  716. protoOverride(Element, 'hasAttributeNS', isStyleText, function(o) {
  717. return o.oldStyle !== null;
  718. });
  719. protoOverride(Element, 'setAttribute', isStyleText, function(o, args) {
  720. o.oldStyle = args[1];
  721. });
  722. protoOverride(Element, 'setAttributeNS', isStyleText, returnUndefined);
  723. protoOverride(Element, 'setAttributeNode', isStyleAttr, returnUndefined);
  724. protoOverride(Element, 'getAttribute', isStyleText, function(o) {
  725. return o.oldStyle;
  726. });
  727. protoOverride(Element, 'getAttributeNS', isStyleText, returnUndefined);
  728. protoOverride(Element, 'getAttributeNode', isStyleText, function(o){
  729. if (o.oldStyle === null) {
  730. return null;
  731. }
  732. var at = document.createAttribute('style');
  733. at.value = o.oldStyle;
  734. Object.defineProperty(at, 'ownerElement', {
  735. value: this,
  736. enumerable: true
  737. });
  738. return at;
  739. });
  740. if (eventMode) {
  741. var e = document.createEvent('Event');
  742. e.initEvent('protoOverride', false, false);
  743. window.protectedElems = protectedElems;
  744. window.dispatchEvent(e);
  745. } else {
  746. return protectedElems;
  747. }
  748. }
  749. if (isFirefox) {
  750. var s = document.createElement('script');
  751. s.textContent = '(' + styleProtector.toString() + ')(true);' +
  752. 'var s = document.currentScript; if (s) {s.parentNode.removeChild(s);}';
  753. window.addEventListener('protoOverride', function protoOverrideCallback(e){
  754. if (win.protectedElems) {
  755. protectedElems = win.protectedElems;
  756. delete win.protectedElems;
  757. }
  758. document.removeEventListener('protoOverride', protoOverrideCallback, true);
  759. }, true);
  760. document.documentElement.appendChild(s);
  761. } else {
  762. protectedElems = styleProtector(false);
  763. }
  764.  
  765. // clean a page
  766. window.addEventListener('DOMContentLoaded', function(){
  767. var rem, si, itm;
  768. function width(){ return window.innerWidth||document.documentElement.clientWidth||document.body.clientWidth||0; }
  769. function height(){ return window.innerHeight||document.documentElement.clientHeight||document.body.clientHeight||0; }
  770.  
  771.  
  772. if (isForum) {
  773. si = document.querySelector('#logostrip');
  774. if (si) {
  775. remove(si.parentNode.nextSibling);
  776. }
  777. }
  778.  
  779. if (document.location.href.search('/forum/dl/') !== -1) {
  780. document.body.setAttribute('style', (document.body.getAttribute('style')||'')+
  781. ';background-color:black!important');
  782. for (itm of document.querySelectorAll('body>div')) {
  783. if (!itm.querySelector('.dw-fdwlink')) {
  784. remove(itm);
  785. }
  786. }
  787. }
  788.  
  789. if (isForum) { // Do not continue if it's a forum
  790. return;
  791. }
  792.  
  793. si = document.querySelector('#header');
  794. if (si) {
  795. rem = si.previousSibling;
  796. while (rem) {
  797. si = rem.previousSibling;
  798. remove(rem);
  799. rem = si;
  800. }
  801. }
  802.  
  803. for (itm of document.querySelectorAll('#nav li[class]')) {
  804. if (itm && itm.querySelector('a[href^="/tag/"]')) {
  805. remove(itm);
  806. }
  807. }
  808.  
  809. var style, result;
  810. for (itm of document.querySelectorAll('DIV')) {
  811. if (itm.offsetWidth > 0.95 * width() && itm.offsetHeight > 0.8 * height()) {
  812. style = window.getComputedStyle(itm, null);
  813. result = [];
  814. if (style.backgroundImage !== 'none') {
  815. result.push('background-image:none!important');
  816. }
  817. if (style.backgroundColor !== 'transparent' &&
  818. style.backgroundColor !== 'rgba(0, 0, 0, 0)') {
  819. result.push('background-color:transparent!important');
  820. }
  821. if (result.length) {
  822. if (itm.getAttribute('style')) {
  823. result.unshift(itm.getAttribute('style'));
  824. }
  825. (function(){
  826. var fakeStyle = {
  827. 'backgroundImage': itm.style.backgroundImage,
  828. 'backgroundColor': itm.style.backgroundColor
  829. };
  830. try {
  831. Object.defineProperty(itm, 'style', {
  832. value: new Proxy(itm.style, {
  833. get: function(target, prop){
  834. if (fakeStyle.hasOwnProperty(prop)) {
  835. return fakeStyle[prop];
  836. } else {
  837. return target[prop];
  838. }
  839. },
  840. set: function(target, prop, value){
  841. if (fakeStyle.hasOwnProperty(prop)) {
  842. fakeStyle[prop] = value;
  843. } else {
  844. target[prop] = value;
  845. }
  846. return value;
  847. }
  848. }),
  849. enumerable: true
  850. });
  851. } catch (e) {
  852. console.log('Unable to protect style property.', e);
  853. }
  854. })();
  855. if (protectedElems) {
  856. protectedElems.set(itm, {oldStyle: oGA.call(itm, 'style')});
  857. }
  858. oSA.call(itm, 'style', result.join(';'));
  859. }
  860. }
  861. }
  862.  
  863. for (itm of document.querySelectorAll('ASIDE>DIV')) {
  864. if ( ((itm.querySelector('script, iframe, a[href*="/ad/www/"]') ||
  865. itm.querySelector('img[src$=".gif"]:not([height="0"]), img[height="400"]')) &&
  866. !itm.classList.contains('post') ) || !itm.childNodes.length ) {
  867. remove(itm);
  868. }
  869. }
  870.  
  871. document.body.setAttribute('style', (document.body.getAttribute('style')||'')+';background-color:#E6E7E9!important');
  872.  
  873. // display content of the page
  874. afterClean();
  875. });
  876. })();
  877. return;
  878. }
  879.  
  880. // https://greasyfork.org/en/scripts/21937-moonwalk-hdgo-kodik-fix v0.7+ (adapted & fixed)
  881. document.addEventListener ('DOMContentLoaded', function() {
  882. var tmp, t;
  883. function log (e) {
  884. console.log('Moonwalk&HDGo&Kodik FIX: ' + e + ' player in ' + win.location.href);
  885. }
  886. if (win.adv_enabled !== undefined && win.condition_detected !== undefined) { // moonwalk
  887. log('Moonwalk');
  888. if (win.adv_enabled) {
  889. win.adv_enabled = false;
  890. }
  891. win.condition_detected = false;
  892. if (win.MXoverrollCallback) {
  893. document.addEventListener('click', function catcher(e){
  894. e.stopPropagation();
  895. win.MXoverrollCallback.call(window);
  896. document.removeEventListener('click', catcher, true);
  897. }, true);
  898. }
  899. } else if (win.banner_second !== undefined && win.$banner_ads !== undefined) { // hdgo
  900. log('HDGo');
  901. tmp = document.querySelector('#swtf');
  902. if (tmp) {
  903. tmp.style.display = 'none';
  904. }
  905. win.banner_second = 0;
  906. win.$banner_ads = false;
  907. if (win.$new_ads !== undefined) {
  908. win.$new_ads = false;
  909. }
  910. if (win.canRunAds !== undefined && win.canRunAds !== true) {
  911. win.canRunAds = true;
  912. }
  913. } else if (win.MXoverrollCallback && win.iframeSearch !== undefined) { // kodik
  914. log('Kodik');
  915. tmp = document.querySelector('.play_button');
  916. if (tmp) {
  917. tmp.onclick = win.MXoverrollCallback.bind(window);
  918. }
  919. win.IsAdBlock = false;
  920. }
  921. }, false);
  922.  
  923. // function to search and remove nodes by content
  924. // selector - standard CSS selector to define set of nodes to check
  925. // words - regular expression to check content of the suspicious nodes
  926. // params - object with multiple extra parameters:
  927. // .hide - set display to none instead of removing from the page
  928. // .parent - parent node to remove if content is found in the child node
  929. // .siblings - number of simling nodes to remove (excluding text nodes)
  930. function scRemove(e) {e.parentNode.removeChild(e);}
  931. function scHide(e) {
  932. var s = e.getAttribute('style')||'',
  933. h = ';display:none!important;';
  934. if (s.indexOf(h) < 0) {
  935. e.setAttribute('style', s+h);
  936. }
  937. }
  938. function scissors (selector, words, scope, params) {
  939. var remFunc = (params.hide ? scHide : scRemove),
  940. iterFunc = (params.siblings > 0 ?
  941. 'nextSibling' :
  942. 'previousSibling'),
  943. toRemove = [],
  944. siblings,
  945. node;
  946. for (node of scope.querySelectorAll(selector)) {
  947. if (words.test(node.innerHTML) || !node.childNodes.length) {
  948. // drill up to the specified parent node if required
  949. if (params.parent) {
  950. while(node !== scope && !(node.matches(params.parent))) {
  951. node = node.parentNode;
  952. }
  953. }
  954. if (node === scope) {
  955. break;
  956. }
  957. toRemove.push(node);
  958. // add multiple nodes if defined more than one sibling
  959. siblings = Math.abs(params.siblings) || 0;
  960. while (siblings) {
  961. node = node[iterFunc];
  962. toRemove.push(node);
  963. if (node.nodeType === Node.ELEMENT_NODE) {
  964. siblings -= 1; //count only element nodes
  965. }
  966. }
  967. }
  968. }
  969. for (node of toRemove) {
  970. remFunc(node);
  971. }
  972. return toRemove.length;
  973. }
  974.  
  975. // function to perform multiple checks if ads inserted with a delay
  976. // by default does 30 checks withing a 3 seconds unless nonstop mode specified
  977. // also does 1 extra check when a page completely loads
  978. // selector and words - passed dow to scissors
  979. // params - object with multiple extra parameters:
  980. // .root - selector to narrow down scope to scan;
  981. // .observe - if true then check will be performed continuously;
  982. // Other parameters passed down to scissors.
  983. function gardener(selector, words, params) {
  984. params = params || {};
  985. var scope = document.body,
  986. nonstop = false;
  987. // narrow down scope to a specific element
  988. if (params.root) {
  989. scope = scope.querySelector(params.root);
  990. if (!scope) {// exit if the root element is not present on the page
  991. return 0;
  992. }
  993. }
  994. // add observe mode if required
  995. if (params.observe) {
  996. if (typeof MutationObserver === 'function') {
  997. var o = new MutationObserver(function(ms){
  998. for (var m of ms) {
  999. if (m.addedNodes.length) {
  1000. scissors(selector, words, scope, params);
  1001. }
  1002. }
  1003. });
  1004. o.observe(scope, {childList:true, subtree: true});
  1005. } else {
  1006. nonstop = true;
  1007. }
  1008. }
  1009. // wait for a full page load to do one extra cut
  1010. win.addEventListener('load',function(){
  1011. scissors(selector, words, scope, params);
  1012. });
  1013. // do multiple cuts until ads removed
  1014. function cut(sci, s, w, sc, p, i) {
  1015. if (i > 0) {
  1016. i -= 1;
  1017. }
  1018. if (i && !sci(s, w, sc, p)) {
  1019. setTimeout(cut, 100, sci, s, w, sc, p, i);
  1020. }
  1021. }
  1022. cut(scissors, selector, words, scope, params, (nonstop ? -1 : 30));
  1023. }
  1024.  
  1025. function preventBackgroundRedirect() {
  1026. // create "cose_me" event to call high-level window.close()
  1027. var key = Math.random().toString(36).substr(2);
  1028. window.addEventListener('close_me_'+key, function(e) {
  1029. window.close();
  1030. });
  1031.  
  1032. // window.open wrapper
  1033. function pbrLander() {
  1034. var orgOpen = window.open.bind(window);
  1035. function closeWindow(){
  1036. // site went to a new tab and attempts to unload
  1037. // call for high-level close through event
  1038. var event = new CustomEvent("close_me_%key%", {});
  1039. window.dispatchEvent(event);
  1040. }
  1041. function open(){
  1042. var idx = String.prototype.indexOf;
  1043. if (arguments[0] &&
  1044. (idx.call(arguments[0], window.location.host) > -1 ||
  1045. idx.call(arguments[0], '://') === -1)) {
  1046. window.addEventListener('unload', closeWindow, true);
  1047. }
  1048. orgOpen.apply(window, arguments);
  1049. }
  1050. window.open = open.bind(window);
  1051. var s = document.currentScript;
  1052. if (s) {s.parentNode.removeChild(s);}
  1053. }
  1054.  
  1055. // land wrapper on the page
  1056. var script = document.createElement('script');
  1057. script.appendChild(document.createTextNode('('+pbrLander.toString().replace(/%key%/g,key)+')();'));
  1058. document.head.insertBefore(script,document.head.firstChild);
  1059. console.log("Background redirect prevention enabled.");
  1060. }
  1061.  
  1062. function forbidServiceWorker() {
  1063. if (!("serviceWorker" in navigator)) {
  1064. return;
  1065. }
  1066. var svr = navigator.serviceWorker.ready;
  1067. Object.defineProperty(navigator, 'serviceWorker', {
  1068. value: {
  1069. register: function(){
  1070. console.log('Registration of serviceWorker ' + arguments[0] + ' blocked.');
  1071. return new Promise(function(){});
  1072. },
  1073. ready: new Promise(function(){}),
  1074. addEventListener:function(){}
  1075. }
  1076. });
  1077. document.addEventListener('DOMContentLoaded', function() {
  1078. if (!svr) {
  1079. return;
  1080. }
  1081. svr.then(function(sw) {
  1082. console.log('Found existing serviceWorker:', sw);
  1083. console.log('Attempting to unregister...');
  1084. sw.unregister().then(function() {
  1085. console.log('Unregistered! :)');
  1086. }).catch(function(err) {
  1087. console.log('Unregistration failed. :(', err);
  1088. console.log('Try to remove it manually:');
  1089. console.log(' 1. Open: chrome://serviceworker-internals/ (Google Chrome and alike) or about:serviceworkers (Mozilla Firefox) in a new tab.');
  1090. console.log(' 2. Search there for one with "'+document.domain+'" in the name.');
  1091. console.log(' 3. Use buttons in the same block with service you found to stop it and uninstall/unregister.');
  1092. });
  1093. }).catch(function(err) {
  1094. console.log("Lol, it failed on it's own. -_-", err);
  1095. });
  1096. }, false);
  1097. }
  1098.  
  1099. var scripts = {};
  1100. scripts['fs.to'] = function() {
  1101. function skipClicker(i) {
  1102. if (!i) {
  1103. return;
  1104. }
  1105. var skip = document.querySelector('.b-aplayer-banners__close');
  1106. if (skip) {
  1107. skip.click();
  1108. } else {
  1109. setTimeout(skipClicker, 100, i-1);
  1110. }
  1111. }
  1112. setTimeout(skipClicker, 100, 30);
  1113.  
  1114. createStyle([
  1115. '.l-body-branding *,'+
  1116. '.b-styled__item-central,'+
  1117. '.b-styled__content-right,'+
  1118. '.b-styled__section-central,'+
  1119. 'div[id^="adsProxy-"]'+
  1120. '{display:none!important}',
  1121. 'body {background-image:url(data:image/png;base64,'+
  1122. 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAACX'+
  1123. 'BIWXMAAC4jAAAuIwF4pT92AAAADUlEQVR42mOQUdL5DwACMgFq'+
  1124. 'BC3ttwAAAABJRU5ErkJggg==)!important}'
  1125. ]);
  1126.  
  1127. if (/\/(view_iframe|iframeplayer)\//i.test(document.location.pathname)) {
  1128. var p = document.querySelector('#player:not([preload="auto"])'),
  1129. m = document.querySelector('.main'),
  1130. adStepper = function(p) {
  1131. if (p.currentTime < p.duration) {
  1132. p.currentTime += 1;
  1133. }
  1134. },
  1135. adSkipper = function(f, p) {
  1136. f.click();
  1137. p.waitAfterSkip = false;
  1138. p.longerSkipper = false;
  1139. console.log('Пропустили.');
  1140. },
  1141. cl = function(p) {
  1142. var faster = document.querySelector('.b-aplayer__html5-desktop-skip'),
  1143. series = document.querySelector('.b-aplayer__actions-series');
  1144.  
  1145. function clickSelected() {
  1146. var s = document.querySelector('.b-aplayer__popup-series-episodes .selected a');
  1147. if (s) {
  1148. s.click();
  1149. }
  1150. }
  1151.  
  1152. if ((!faster || faster.style.display !== 'block') && series && !p.seriesClicked) {
  1153. series.click();
  1154. p.seriesClicked = true;
  1155. p.longerSkipper = true;
  1156. setTimeout(clickSelected, 1000);
  1157. p.pause();
  1158. }
  1159.  
  1160. function skipListener() {
  1161. if (p.waitAfterSkip) {
  1162. console.log('В процессе пропуска…');
  1163. return;
  1164. }
  1165. p.pause();
  1166. if (!p.classList.contains('m-hidden')) {
  1167. p.classList.add('m-hidden');
  1168. }
  1169. if (faster && p.currentTime &&
  1170. win.getComputedStyle(faster).display === 'block' &&
  1171. !faster.querySelector('.b-aplayer__html5-desktop-skip-timer')) {
  1172. p.waitAfterSkip = true;
  1173. setTimeout(adSkipper, (p.longerSkipper?3:1)*1000, faster, p);
  1174. console.log('Доступен быстрый пропуск…');
  1175. } else {
  1176. setTimeout(adStepper, 1000, p);
  1177. }
  1178. }
  1179.  
  1180. p.addEventListener('timeupdate', skipListener, false);
  1181. },
  1182. o = new MutationObserver(function (ms) {
  1183. var m, node;
  1184. for (m of ms) {
  1185. for (node of m.addedNodes) {
  1186. if (node.id === 'player' &&
  1187. node.nodeName === 'VIDEO' &&
  1188. node.getAttribute('preload') !== 'auto') {
  1189. cl(node);
  1190. }
  1191. }
  1192. }
  1193. });
  1194. if (p.nodeName === 'VIDEO') {
  1195. cl(p);
  1196. } else {
  1197. o.observe(m, {childList: true});
  1198. }
  1199. }
  1200. };
  1201. scripts['brb.to'] = scripts['fs.to'];
  1202. scripts['cxz.to'] = scripts['fs.to'];
  1203.  
  1204. scripts['drive2.ru'] = function() {
  1205. gardener('.c-block:not(.js-recommendations),.o-grid__item', />Реклама<\//i);
  1206. };
  1207.  
  1208. scripts['fishki.net'] = function() {
  1209. gardener('.main-post', /543769|Реклама/);
  1210. };
  1211.  
  1212. scripts['hdgo.cc'] = {
  1213. 'now': function(){
  1214. var o = new MutationObserver(function(ms) {
  1215. var m, node;
  1216. for (m of ms) {
  1217. for (node of m.addedNodes) {
  1218. if (node.tagName === 'SCRIPT' && node.getAttribute('onerror') !== null) {
  1219. node.removeAttribute('onerror');
  1220. }
  1221. }
  1222. }
  1223. });
  1224. o.observe(document, {childList:true, subtree: true});
  1225. }
  1226. };
  1227. scripts['couber.be'] = scripts['hdgo.cc'];
  1228. scripts['46.30.43.38'] = scripts['hdgo.cc'];
  1229.  
  1230. scripts['hdrezka.me'] = {
  1231. 'now': function() {
  1232. Object.defineProperty(win, 'fuckAdBlock', {
  1233. value: {
  1234. onDetected: function() {
  1235. console.log('Pretending to be an ABP detector.');
  1236. }
  1237. }
  1238. });
  1239. Object.defineProperty(win, 'ab', {
  1240. value: false,
  1241. enumerable: true
  1242. });
  1243. },
  1244. 'DOMContentLoaded': function() {
  1245. gardener('div[id][onclick][onmouseup][onmousedown]', /onmouseout/i);
  1246. }
  1247. };
  1248.  
  1249. scripts['megogo.net'] = {
  1250. 'now': function() {
  1251. Object.defineProperty(win, "adBlock", {
  1252. value : false,
  1253. enumerable : true
  1254. });
  1255. Object.defineProperty(win, "showAdBlockMessage", {
  1256. value : function () {},
  1257. enumerable : true
  1258. });
  1259. }
  1260. };
  1261.  
  1262. scripts['naruto-base.su'] = function() {
  1263. gardener('div[id^="entryID"],.block', /href="http.*?target="_blank"/i);
  1264. };
  1265.  
  1266. scripts['overclockers.ru'] = {
  1267. 'now': function() {
  1268. // Following code inspired by:
  1269. // https://greasyfork.org/en/scripts/23922-anti-adblock-killer-for-overclockers-ru
  1270. function antiAntiABP() {
  1271. var o = new MutationObserver(function(ms) {
  1272. var m, node;
  1273. for (m of ms) {
  1274. for (node of m.addedNodes) {
  1275. if (node.nodeType === Node.ELEMENT_NODE && node.onerror) {
  1276. node.onerror = null;
  1277. console.log("Disabled 'onerror' on", node);
  1278. }
  1279. }
  1280. }
  1281. });
  1282. o.observe(document, {childList: true, subtree: true});
  1283. var s = document.currentScript;
  1284. s.parentNode.removeChild(s);
  1285. }
  1286. var s = document.createElement('script');
  1287. s.textContent = '(' + antiAntiABP.toString() + ')();';
  1288. document.documentElement.appendChild(s);
  1289. }
  1290. };
  1291. scripts['forums.overclockers.ru'] = {
  1292. 'now': function() {
  1293. createStyle(['.needblock {position: fixed; left: -10000px}']);
  1294. Object.defineProperty(win, 'adblck', {
  1295. value: 'no',
  1296. enumerable: true
  1297. });
  1298. }
  1299. };
  1300.  
  1301. scripts['pb.wtf'] = function() {
  1302. createStyle(['.reques,#result,tbody.row1:not([id]) {display: none !important}']);
  1303. // image in the slider in the header
  1304. gardener('a[href$="=="]', /img/i, {root:'.release-navbar', observe:true, parent:'div'});
  1305. // ads in blocks on the page
  1306. gardener('a[href^="/"]', /<img\s.*<br>/i, {root:'#main_content', observe:true, parent:'div[class]'});
  1307. // line above topic content
  1308. gardener('.re_top1', /./, {root:'#main_content', parent:'.hidden-sm'});
  1309. };
  1310. scripts['piratbit.org'] = scripts['pb.wtf'];
  1311. scripts['piratbit.ru'] = scripts['pb.wtf'];
  1312.  
  1313. scripts['pikabu.ru'] = function() {
  1314. gardener('.story', /story__sponsor|story__gag|profile\/ads"/i, {root: '.inner_wrap', observe: true});
  1315. };
  1316.  
  1317. scripts['rp5.ru'] = function() {
  1318. var co = document.querySelector('#content'), i, nodes;
  1319. if (!co) {
  1320. return;
  1321. }
  1322. nodes = co.parentNode.childNodes;
  1323. i = nodes.length;
  1324. while (i--) {
  1325. if (nodes[i] !== co) {
  1326. nodes[i].parentNode.removeChild(nodes[i]);
  1327. }
  1328. }
  1329. };
  1330.  
  1331. scripts['rustorka.com'] = {
  1332. 'now':function(){
  1333. win.open = function(){
  1334. console.log('Site attempted to open a new window', arguments);
  1335. };
  1336. },
  1337. 'DOMContentLoaded':function() {
  1338. gardener('span[class],ul[class],span[id],ul[id]', /\/\d{12,}\.php/i, {root:'#sidebar1', observe:true});
  1339. gardener('div[id][style*="!important"]', /!important/i);
  1340. }
  1341. };
  1342. scripts['rumedia.ws'] = scripts['rustorka.com'];
  1343.  
  1344. scripts['sport-express.ru'] = function() {
  1345. gardener('.js-relap__item',/>Реклама\s+<\//, {root:'.container', observe: true});
  1346. };
  1347.  
  1348. scripts['sports.ru'] = function() {
  1349. gardener('.aside-news-list__item', /aside-news-list__advert/i, {root:'.aside-news-block'});
  1350. };
  1351.  
  1352. scripts['turbobit.net'] = {'now': preventBackgroundRedirect};
  1353.  
  1354. scripts['yap.ru'] = function() {
  1355. var words = /member1438|Administration/;
  1356. gardener('form > table[id^="p_row_"]', words);
  1357. gardener('tr > .holder.newsbottom', words, {parent:'tr', siblings:-2});
  1358. };
  1359. scripts['yaplakal.com'] = scripts['yap.ru'];
  1360.  
  1361. scripts['reactor.cc'] = {
  1362. 'now': function() {
  1363. win.open = (function(){ throw new Error('Redirect prevention.'); }).bind(window);
  1364. },
  1365. 'click': function(e) {
  1366. var node = e.target;
  1367. if (node.nodeType === Node.ELEMENT_NODE &&
  1368. node.style.position === 'absolute' &&
  1369. node.style.zIndex > 0)
  1370. node.parentNode.removeChild(node);
  1371. },
  1372. 'DOMContentLoaded': function() {
  1373. var words = new RegExp(
  1374. 'блокировщика рекламы'
  1375. .split('')
  1376. .map(function(e){return e+'[\u200b\u200c\u200d]*';})
  1377. .join('')
  1378. .replace(' ', '\\s*')
  1379. .replace(/[аоре]/g, function(e){return ['[аa]','[оo]','[рp]','[еe]']['аоре'.indexOf(e)];}),
  1380. 'i'),
  1381. can;
  1382. function deeper(spider) {
  1383. var c, l, n;
  1384. if (words.test(spider.innerText)) {
  1385. if (spider.nodeType === Node.TEXT_NODE) {
  1386. return true;
  1387. }
  1388. c = spider.childNodes;
  1389. l = c.length;
  1390. n = 0;
  1391. while(l--) {
  1392. if (deeper(c[l]), can) {
  1393. n++;
  1394. }
  1395. }
  1396. if (n > 0 && n === c.length && spider.offsetHeight < 750) {
  1397. can.push(spider);
  1398. }
  1399. return false;
  1400. }
  1401. return true;
  1402. }
  1403. function probe(){
  1404. if (words.test(document.body.innerText)) {
  1405. can = [];
  1406. deeper(document.body);
  1407. var i = can.length, j, spider;
  1408. while(i--) {
  1409. spider = can[i];
  1410. if (spider.offsetHeight > 10 && spider.offsetHeight < 750) {
  1411. spider.setAttribute('style', 'background:none!important');
  1412. }
  1413. }
  1414. }
  1415. }
  1416. var o = new MutationObserver(probe);
  1417. o.observe(document,{childList:true, subtree:true});
  1418. }
  1419. };
  1420. scripts['joyreactor.cc'] = scripts['reactor.cc'];
  1421. scripts['pornreactor.cc'] = scripts['reactor.cc'];
  1422.  
  1423. scripts['auto.ru'] = function() {
  1424. var words = /Реклама|Яндекс.Директ|yandex_ad_/;
  1425. var userAdsListAds = [
  1426. '.listing-list > .listing-item',
  1427. '.listing-item_type_fixed.listing-item'
  1428. ];
  1429. var catalogAds = [
  1430. 'div[class*="layout_catalog-inline"]',
  1431. 'div[class$="layout_horizontal"]'
  1432. ];
  1433. var otherAds = [
  1434. '.advt_auto',
  1435. '.sidebar-block',
  1436. '.pager-listing + div[class]',
  1437. '.card > div[class][style]',
  1438. '.sidebar > div[class]',
  1439. '.main-page__section + div[class]',
  1440. '.listing > tbody'];
  1441. gardener(userAdsListAds.join(','), words, {root:'.listing-wrap', observe:true});
  1442. gardener(catalogAds.join(','), words, {root:'.catalog__page,.content__wrapper', observe:true});
  1443. gardener(otherAds.join(','), words);
  1444. };
  1445.  
  1446. scripts['online.anidub.com'] = function() {
  1447. var script = document.createElement('script');
  1448. script.type = "text/javascript";
  1449. script.innerHTML = "function ogonekstart1() {}";
  1450. document.getElementsByTagName('head')[0].appendChild(script);
  1451.  
  1452. var style = document.createElement('style');
  1453. style.type = 'text/css';
  1454. style.appendChild(document.createTextNode('.background {background: none!important;}'));
  1455. style.appendChild(document.createTextNode('.background > script + div, .background > script ~ div:not([id]):not([class]) + div[id][class] {display:none!important}'));
  1456. document.head.appendChild(style);
  1457. };
  1458.  
  1459. scripts['rsload.net'] = {
  1460. 'load': function() {
  1461. var dis = document.querySelector('.cb-disable');
  1462. if (dis) {
  1463. dis.click();
  1464. }
  1465. },
  1466. 'click': function(e) {
  1467. var t = e.target;
  1468. if (t && t.href && (/:\/\/\d+\.\d+\.\d+\.\d+\//.test(t.href))) {
  1469. t.href = t.href.replace('://','://rsload.net:rsload.net@');
  1470. }
  1471. }
  1472. };
  1473.  
  1474. scripts['imageban.ru'] = {
  1475. 'now': preventBackgroundRedirect,
  1476. 'DOMContentLoaded': function() {
  1477. win.addEventListener('unload', function() {
  1478. if (!window.location.hash) {
  1479. window.location.replace(window.location+'#');
  1480. } else {
  1481. window.location.hash = '';
  1482. }
  1483. }, true);
  1484. }
  1485. };
  1486.  
  1487. var domain = document.domain, name;
  1488. while (domain.indexOf('.') !== -1) {
  1489. if (scripts.hasOwnProperty(domain)) {
  1490. if (typeof scripts[domain] === 'function') {
  1491. document.addEventListener ('DOMContentLoaded', scripts[domain], false);
  1492. }
  1493. for (name in scripts[domain]) {
  1494. if (name !== 'now') {
  1495. (name === 'load' ? window : document)
  1496. .addEventListener (name, scripts[domain][name], false);
  1497. } else {
  1498. scripts[domain][name]();
  1499. }
  1500. }
  1501. }
  1502. domain = domain.slice(domain.indexOf('.') + 1);
  1503. }
  1504. })();