RU AdList JS Fixes

try to take over the world!

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

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