RU AdList JS Fixes

try to take over the world!

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

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