RU AdList JS Fixes

try to take over the world!

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

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