RU AdList JS Fixes

try to take over the world!

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

  1. // ==UserScript==
  2. // @name RU AdList JS Fixes
  3. // @namespace ruadlist_js_fixes
  4. // @version 20161219.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['tapochek.net'] = preventPopupsNow;
  880. scripts['thepiratebay.org'] = preventPopupsNow;
  881. scripts['zippyshare.com'] = preventPopupsNow;
  882.  
  883. // other
  884. scripts['4pda.ru'] = {
  885. 'now': function() {
  886. // https://greasyfork.org/en/scripts/14470-4pda-unbrender
  887. var isForum = document.location.href.search('/forum/') !== -1,
  888. hStyle;
  889.  
  890. function remove(n) {
  891. if (n) {
  892. n.parentNode.removeChild(n);
  893. }
  894. }
  895.  
  896. function afterClean() {
  897. hStyle.disabled = true;
  898. remove(hStyle);
  899. }
  900.  
  901. function beforeClean() {
  902. // attach styles before document displayed
  903. hStyle = createStyle([
  904. 'html { overflow-y: scroll }',
  905. 'section[id] {'+(
  906. 'position: absolute;'+
  907. 'width: 100%'
  908. )+'}',
  909. 'article + aside * { display: none !important }',
  910. '#header + div:after {'+(
  911. 'content: "";'+
  912. 'position: fixed;'+
  913. 'top: 0;'+
  914. 'left: 0;'+
  915. 'width: 100%;'+
  916. 'height: 100%;'+
  917. 'background-color: #E6E7E9'
  918. )+'}',
  919. // http://codepen.io/Beaugust/pen/DByiE
  920. '@keyframes spin { 100% { transform: rotate(360deg) } }',
  921. 'article + aside:after {'+(
  922. 'content: "";'+
  923. 'position: absolute;'+
  924. 'width: 150px;'+
  925. 'height: 150px;'+
  926. 'top: 150px;'+
  927. 'left: 50%;'+
  928. 'margin-top: -75px;'+
  929. 'margin-left: -75px;'+
  930. 'box-sizing: border-box;'+
  931. 'border-radius: 100%;'+
  932. 'border: 10px solid rgba(0, 0, 0, 0.2);'+
  933. 'border-top-color: rgba(0, 0, 0, 0.6);'+
  934. 'animation: spin 2s infinite linear'
  935. )+'}'
  936. ], {id:'ubrHider'}, true);
  937.  
  938. // display content of a page if time to load a page is more than 2 seconds to avoid
  939. // blocking access to a page if it is loading for too long or stuck in a loading state
  940. setTimeout(2000, afterClean);
  941. }
  942.  
  943. createStyle([
  944. '#nav .use-ad { display: block !important }',
  945. 'article:not(.post) + article:not(#id), a[target="_blank"] img[height="90"] { display: none !important }'
  946. ]);
  947.  
  948. if (!isForum) {
  949. beforeClean();
  950. }
  951.  
  952. // save links to non-overridden functions to use later
  953. var oGA = Element.prototype.getAttribute,
  954. oSA = Element.prototype.setAttribute,
  955. protectedElems;
  956. // protect/hide changed attributes in case site attempt to restore them
  957. function styleProtector(eventMode) {
  958. var oRAN = Element.prototype.removeAttributeNode,
  959. isStyleText = function(t){ return t === 'style'; },
  960. isStyleAttr = function(a){ return a instanceof Attr && a.nodeName === 'style'; },
  961. returnUndefined = function(){},
  962. protectedElems = new WeakMap();
  963. function protoOverride(element, functionName, isStyleCheck, returnIfProtected) {
  964. var oF = element.prototype[functionName];
  965. element.prototype[functionName] = function(){
  966. if (protectedElems.get(this) !== undefined && isStyleCheck(arguments[0])) {
  967. return returnIfProtected(protectedElems.get(this), arguments, this);
  968. }
  969. return oF.apply(this, arguments);
  970. };
  971. }
  972. protoOverride(Element, 'removeAttribute', isStyleText, returnUndefined);
  973. protoOverride(Element, 'hasAttribute', isStyleText, function(o) {
  974. return o.oldStyle !== null;
  975. });
  976. protoOverride(Element, 'setAttribute', isStyleText, function(o, args) {
  977. o.oldStyle = args[1];
  978. });
  979. protoOverride(Element, 'getAttribute', isStyleText, function(o) {
  980. return o.oldStyle;
  981. });
  982. if (eventMode) {
  983. var e = document.createEvent('Event');
  984. e.initEvent('protoOverride', false, false);
  985. window.protectedElems = protectedElems;
  986. window.dispatchEvent(e);
  987. } else {
  988. return protectedElems;
  989. }
  990. }
  991. if (isFirefox) {
  992. var s = document.createElement('script');
  993. s.textContent = '(' + styleProtector.toString() + ')(true);' +
  994. 'var s = document.currentScript; if (s) {s.parentNode.removeChild(s);}';
  995. window.addEventListener('protoOverride', function protoOverrideCallback(e){
  996. if (win.protectedElems) {
  997. protectedElems = win.protectedElems;
  998. delete win.protectedElems;
  999. }
  1000. document.removeEventListener('protoOverride', protoOverrideCallback, true);
  1001. }, true);
  1002. document.documentElement.appendChild(s);
  1003. } else {
  1004. protectedElems = styleProtector(false);
  1005. }
  1006.  
  1007. // clean a page
  1008. window.addEventListener('DOMContentLoaded', function(){
  1009. var rem, si, itm;
  1010. function width(){ return window.innerWidth||document.documentElement.clientWidth||document.body.clientWidth||0; }
  1011. function height(){ return window.innerHeight||document.documentElement.clientHeight||document.body.clientHeight||0; }
  1012.  
  1013.  
  1014. if (isForum) {
  1015. si = document.querySelector('#logostrip');
  1016. if (si) {
  1017. remove(si.parentNode.nextSibling);
  1018. }
  1019. }
  1020.  
  1021. if (document.location.href.search('/forum/dl/') !== -1) {
  1022. document.body.setAttribute('style', (document.body.getAttribute('style')||'')+
  1023. ';background-color:black!important');
  1024. for (itm of document.querySelectorAll('body>div')) {
  1025. if (!itm.querySelector('.dw-fdwlink')) {
  1026. remove(itm);
  1027. }
  1028. }
  1029. }
  1030.  
  1031. if (isForum) { // Do not continue if it's a forum
  1032. return;
  1033. }
  1034.  
  1035. si = document.querySelector('#header');
  1036. if (si) {
  1037. rem = si.previousSibling;
  1038. while (rem) {
  1039. si = rem.previousSibling;
  1040. remove(rem);
  1041. rem = si;
  1042. }
  1043. }
  1044.  
  1045. for (itm of document.querySelectorAll('#nav li[class]')) {
  1046. if (itm && itm.querySelector('a[href^="/tag/"]')) {
  1047. remove(itm);
  1048. }
  1049. }
  1050.  
  1051. var style, result;
  1052. for (itm of document.querySelectorAll('DIV, A')) {
  1053. if (itm.tagName ==='DIV' && itm.offsetWidth > 0.95 * width() && itm.offsetHeight > 0.85 * height()) {
  1054. style = window.getComputedStyle(itm, null);
  1055. result = [];
  1056. if (style.backgroundImage !== 'none') {
  1057. result.push('background-image:none!important');
  1058. }
  1059. if (style.backgroundColor !== 'transparent' &&
  1060. style.backgroundColor !== 'rgba(0, 0, 0, 0)') {
  1061. result.push('background-color:transparent!important');
  1062. }
  1063. if (result.length) {
  1064. if (itm.getAttribute('style')) {
  1065. result.unshift(itm.getAttribute('style'));
  1066. }
  1067. (function(){
  1068. var fakeStyle = {
  1069. 'backgroundImage': itm.style.backgroundImage,
  1070. 'backgroundColor': itm.style.backgroundColor
  1071. };
  1072. try {
  1073. Object.defineProperty(itm, 'style', {
  1074. value: new Proxy(itm.style, {
  1075. get: function(target, prop){
  1076. if (fakeStyle.hasOwnProperty(prop)) {
  1077. return fakeStyle[prop];
  1078. } else {
  1079. return target[prop];
  1080. }
  1081. },
  1082. set: function(target, prop, value){
  1083. if (fakeStyle.hasOwnProperty(prop)) {
  1084. fakeStyle[prop] = value;
  1085. } else {
  1086. target[prop] = value;
  1087. }
  1088. return value;
  1089. }
  1090. }),
  1091. enumerable: true
  1092. });
  1093. } catch (e) {
  1094. console.log('Unable to protect style property.', e);
  1095. }
  1096. })();
  1097. if (protectedElems) {
  1098. protectedElems.set(itm, {oldStyle: oGA.call(itm, 'style')});
  1099. }
  1100. oSA.call(itm, 'style', result.join(';'));
  1101. }
  1102. }
  1103. if (itm.tagName ==='A' && (itm.offsetWidth > 0.95 * width() || itm.offsetHeight > 0.85 * height())) {
  1104. if (protectedElems) {
  1105. protectedElems.set(itm, {oldStyle: oGA.call(itm, 'style')});
  1106. }
  1107. oSA.call(itm, 'style', 'display:none!important');
  1108. }
  1109. }
  1110.  
  1111. for (itm of document.querySelectorAll('ASIDE>DIV')) {
  1112. if ( ((itm.querySelector('script, iframe, a[href*="/ad/www/"]') ||
  1113. itm.querySelector('img[src$=".gif"]:not([height="0"]), img[height="400"]')) &&
  1114. !itm.classList.contains('post') ) || !itm.childNodes.length ) {
  1115. remove(itm);
  1116. }
  1117. }
  1118.  
  1119. document.body.setAttribute('style', (document.body.getAttribute('style')||'')+';background-color:#E6E7E9!important');
  1120.  
  1121. // display content of the page
  1122. afterClean();
  1123. });
  1124. }
  1125. };
  1126.  
  1127. scripts['anidub-online.ru'] = function() {
  1128. var script = document.createElement('script');
  1129. script.type = "text/javascript";
  1130. script.innerHTML = "function ogonekstart1() {}";
  1131. document.getElementsByTagName('head')[0].appendChild(script);
  1132.  
  1133. var style = document.createElement('style');
  1134. style.type = 'text/css';
  1135. style.appendChild(document.createTextNode('.background {background: none!important;}'));
  1136. style.appendChild(document.createTextNode('.background > script + div, .background > script ~ div:not([id]):not([class]) + div[id][class] {display:none!important}'));
  1137. document.head.appendChild(style);
  1138. };
  1139. scripts['online.anidub.com'] = scripts['anidub-online.ru'];
  1140.  
  1141. scripts['fs.to'] = function() {
  1142. function skipClicker(i) {
  1143. if (!i) {
  1144. return;
  1145. }
  1146. var skip = document.querySelector('.b-aplayer-banners__close');
  1147. if (skip) {
  1148. skip.click();
  1149. } else {
  1150. setTimeout(skipClicker, 100, i-1);
  1151. }
  1152. }
  1153. setTimeout(skipClicker, 100, 30);
  1154.  
  1155. createStyle([
  1156. '.l-body-branding *,'+
  1157. '.b-styled__item-central,'+
  1158. '.b-styled__content-right,'+
  1159. '.b-styled__section-central,'+
  1160. 'div[id^="adsProxy-"]'+
  1161. '{display:none!important}',
  1162. 'body {background-image:url(data:image/png;base64,'+
  1163. 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAACX'+
  1164. 'BIWXMAAC4jAAAuIwF4pT92AAAADUlEQVR42mOQUdL5DwACMgFq'+
  1165. 'BC3ttwAAAABJRU5ErkJggg==)!important}'
  1166. ]);
  1167.  
  1168. if (/\/(view_iframe|iframeplayer)\//i.test(document.location.pathname)) {
  1169. var p = document.querySelector('#player:not([preload="auto"])'),
  1170. m = document.querySelector('.main'),
  1171. adStepper = function(p) {
  1172. if (p.currentTime < p.duration) {
  1173. p.currentTime += 1;
  1174. }
  1175. },
  1176. adSkipper = function(f, p) {
  1177. f.click();
  1178. p.waitAfterSkip = false;
  1179. p.longerSkipper = false;
  1180. console.log('Пропустили.');
  1181. },
  1182. cl = function(p) {
  1183. var faster = document.querySelector('.b-aplayer__html5-desktop-skip'),
  1184. series = document.querySelector('.b-aplayer__actions-series');
  1185.  
  1186. function clickSelected() {
  1187. var s = document.querySelector('.b-aplayer__popup-series-episodes .selected a');
  1188. if (s) {
  1189. s.click();
  1190. }
  1191. }
  1192.  
  1193. if ((!faster || faster.style.display !== 'block') && series && !p.seriesClicked) {
  1194. series.click();
  1195. p.seriesClicked = true;
  1196. p.longerSkipper = true;
  1197. setTimeout(clickSelected, 1000);
  1198. p.pause();
  1199. }
  1200.  
  1201. function skipListener() {
  1202. if (p.waitAfterSkip) {
  1203. console.log('В процессе пропуска…');
  1204. return;
  1205. }
  1206. p.pause();
  1207. if (!p.classList.contains('m-hidden')) {
  1208. p.classList.add('m-hidden');
  1209. }
  1210. if (faster && p.currentTime &&
  1211. win.getComputedStyle(faster).display === 'block' &&
  1212. !faster.querySelector('.b-aplayer__html5-desktop-skip-timer')) {
  1213. p.waitAfterSkip = true;
  1214. setTimeout(adSkipper, (p.longerSkipper?3:1)*1000, faster, p);
  1215. console.log('Доступен быстрый пропуск…');
  1216. } else {
  1217. setTimeout(adStepper, 1000, p);
  1218. }
  1219. }
  1220.  
  1221. p.addEventListener('timeupdate', skipListener, false);
  1222. },
  1223. o = new MutationObserver(function (ms) {
  1224. var m, node;
  1225. for (m of ms) {
  1226. for (node of m.addedNodes) {
  1227. if (node.id === 'player' &&
  1228. node.nodeName === 'VIDEO' &&
  1229. node.getAttribute('preload') !== 'auto') {
  1230. cl(node);
  1231. }
  1232. }
  1233. }
  1234. });
  1235. if (p.nodeName === 'VIDEO') {
  1236. cl(p);
  1237. } else {
  1238. o.observe(m, {childList: true});
  1239. }
  1240. }
  1241. };
  1242. scripts['brb.to'] = scripts['fs.to'];
  1243. scripts['cxz.to'] = scripts['fs.to'];
  1244.  
  1245. scripts['drive2.ru'] = function() {
  1246. gardener('.c-block:not([data-metrika="recomm"]),.o-grid__item', />Реклама<\//i);
  1247. };
  1248.  
  1249. scripts['fishki.net'] = function() {
  1250. gardener('.main-post', /543769|Реклама/);
  1251. };
  1252.  
  1253. scripts['gidonline.club'] = {
  1254. 'now': function() {
  1255. createStyle('.tray > div[style] {display: none!important}');
  1256. }
  1257. };
  1258. scripts['gidonlinekino.com'] = scripts['gidonline.club'];
  1259.  
  1260. scripts['hdgo.cc'] = {
  1261. 'now': function(){
  1262. var o = new MutationObserver(function(ms) {
  1263. var m, node;
  1264. for (m of ms) {
  1265. for (node of m.addedNodes) {
  1266. if (node.tagName === 'SCRIPT' && node.getAttribute('onerror') !== null) {
  1267. node.removeAttribute('onerror');
  1268. }
  1269. }
  1270. }
  1271. });
  1272. o.observe(document, {childList:true, subtree: true});
  1273. }
  1274. };
  1275. scripts['couber.be'] = scripts['hdgo.cc'];
  1276. scripts['46.30.43.38'] = scripts['hdgo.cc'];
  1277.  
  1278. scripts['gismeteo.ru'] = {
  1279. 'DOMContentLoaded': function() {
  1280. gardener('div > a[target^="_"]', /Яндекс\.Директ/i, { root: 'body', observe: true, parent: 'div[class*="frame"]' });
  1281. }
  1282. };
  1283.  
  1284. scripts['hdrezka.me'] = {
  1285. 'now': function() {
  1286. Object.defineProperty(win, 'fuckAdBlock', {
  1287. value: {
  1288. onDetected: function() {
  1289. console.log('Pretending to be an ABP detector.');
  1290. }
  1291. }
  1292. });
  1293. Object.defineProperty(win, 'ab', {
  1294. value: false,
  1295. enumerable: true
  1296. });
  1297. },
  1298. 'DOMContentLoaded': function() {
  1299. gardener('div[id][onclick][onmouseup][onmousedown]', /onmouseout/i);
  1300. }
  1301. };
  1302.  
  1303. scripts['imageban.ru'] = {
  1304. 'now': preventBackgroundRedirect,
  1305. 'DOMContentLoaded': function() {
  1306. win.addEventListener('unload', function() {
  1307. if (!window.location.hash) {
  1308. window.location.replace(window.location+'#');
  1309. } else {
  1310. window.location.hash = '';
  1311. }
  1312. }, true);
  1313. }
  1314. };
  1315.  
  1316. scripts['megogo.net'] = {
  1317. 'now': function() {
  1318. Object.defineProperty(win, "adBlock", {
  1319. value : false,
  1320. enumerable : true
  1321. });
  1322. Object.defineProperty(win, "showAdBlockMessage", {
  1323. value : function () {},
  1324. enumerable : true
  1325. });
  1326. }
  1327. };
  1328.  
  1329. scripts['naruto-base.su'] = function() {
  1330. gardener('div[id^="entryID"],.block', /href="http.*?target="_blank"/i);
  1331. };
  1332.  
  1333. scripts['overclockers.ru'] = {
  1334. 'now': function() {
  1335. createStyle('#contentplace > [class^="decoblock"] {'+(
  1336. 'position: fixed!important;'+
  1337. 'top: -10000px!important;'+
  1338. 'left: -10000px!important;'
  1339. )+'}');
  1340. if (!isChrome && !isOpera) {
  1341. return; // Looks like my code works only in Chrome-like browsers
  1342. }
  1343. var noContentYet = true;
  1344. function jWrap() {
  1345. var _$ = win.$, _e = _$.extend;
  1346. win.$ = function() {
  1347. var _ret = _$.apply(window, arguments);
  1348. if (_ret[0] === document.body) {
  1349. _ret.html = function() {
  1350. console.log('Anti-adblock prevented.');
  1351. };
  1352. }
  1353. return _ret;
  1354. };
  1355. win.$.extend = function() {
  1356. return _e.apply(_$, arguments);
  1357. }
  1358. win.jQuery = win.$;
  1359. }
  1360. (function jReady() {
  1361. if (!win.$ && noContentYet) {
  1362. setTimeout(jReady, 0);
  1363. } else {
  1364. jWrap();
  1365. }
  1366. })();
  1367. document.addEventListener ('DOMContentLoaded', function(){
  1368. noContentYet = false;
  1369. }, false);
  1370. }
  1371. };
  1372. scripts['forums.overclockers.ru'] = {
  1373. 'now': function() {
  1374. createStyle('.needblock {position: fixed; left: -10000px}');
  1375. Object.defineProperty(win, 'adblck', {
  1376. value: 'no',
  1377. enumerable: true
  1378. });
  1379. }
  1380. };
  1381.  
  1382. scripts['pb.wtf'] = function() {
  1383. createStyle('.reques,#result,tbody.row1:not([id]) {display: none !important}');
  1384. // image in the slider in the header
  1385. gardener('a[href$="=="]', /img/i, {root:'.release-navbar', observe:true, parent:'div'});
  1386. // ads in blocks on the page
  1387. gardener('a[href^="/"]', /<img\s.*<br>/i, {root:'#main_content', observe:true, parent:'div[class]'});
  1388. // line above topic content
  1389. gardener('.re_top1', /./, {root:'#main_content', parent:'.hidden-sm'});
  1390. };
  1391. scripts['piratbit.org'] = scripts['pb.wtf'];
  1392. scripts['piratbit.ru'] = scripts['pb.wtf'];
  1393.  
  1394. scripts['pikabu.ru'] = function() {
  1395. gardener('.story', /story__sponsor|story__gag|profile\/ads"/i, {root: '.inner_wrap', observe: true});
  1396. };
  1397.  
  1398. scripts['rp5.ru'] = function() {
  1399. createStyle('#bannerBottom {display: none!important}');
  1400. var co = document.querySelector('#content'), i, nodes;
  1401. if (!co) {
  1402. return;
  1403. }
  1404. nodes = co.parentNode.childNodes;
  1405. i = nodes.length;
  1406. while (i--) {
  1407. if (nodes[i] !== co) {
  1408. nodes[i].parentNode.removeChild(nodes[i]);
  1409. }
  1410. }
  1411. };
  1412. scripts['rp5.by'] = scripts['rp5.ru'];
  1413. scripts['rp5.ua'] = scripts['rp5.ru'];
  1414.  
  1415. scripts['rustorka.com'] = {
  1416. 'now': function() {
  1417. createStyle('.header > div:not(.head-block) a, #sidebar1 img, #logo img {opacity:0!important}', {
  1418. id: 'tempHidingStyles'
  1419. }, true);
  1420. preventPopups();
  1421. },
  1422. 'DOMContentLoaded': function() {
  1423. for (var o of document.querySelectorAll('IMG, A')) {
  1424. if ((o.clientWidth === 728 && o.clientHeight === 90) ||
  1425. (o.clientWidth === 300 && o.clientHeight === 250)) {
  1426. while (o && o.tagName !== 'A') {
  1427. o = o.parentNode;
  1428. }
  1429. if (o) {
  1430. o.setAttribute('style', 'display: none !important');
  1431. }
  1432. }
  1433. }
  1434. var s = document.querySelector('#tempHidingStyles');
  1435. s.parentNode.removeChild(s);
  1436. }
  1437. };
  1438. scripts['rumedia.ws'] = scripts['rustorka.com'];
  1439.  
  1440. scripts['sport-express.ru'] = function() {
  1441. gardener('.js-relap__item',/>Реклама\s+<\//, {root:'.container', observe: true});
  1442. };
  1443.  
  1444. scripts['sports.ru'] = function() {
  1445. gardener('.aside-news-list__item', /aside-news-list__advert/i, {root:'.aside-news-block'});
  1446. };
  1447.  
  1448. scripts['turbobit.net'] = { 'now': preventBackgroundRedirect };
  1449.  
  1450. scripts['yap.ru'] = function() {
  1451. var words = /member1438|Administration/;
  1452. gardener('form > table[id^="p_row_"]', words);
  1453. gardener('tr > .holder.newsbottom', words, {parent:'tr', siblings:-2});
  1454. };
  1455. scripts['yaplakal.com'] = scripts['yap.ru'];
  1456.  
  1457. scripts['reactor.cc'] = {
  1458. 'now': function() {
  1459. win.open = (function(){ throw new Error('Redirect prevention.'); }).bind(window);
  1460. },
  1461. 'click': function(e) {
  1462. var node = e.target;
  1463. if (node.nodeType === Node.ELEMENT_NODE &&
  1464. node.style.position === 'absolute' &&
  1465. node.style.zIndex > 0)
  1466. node.parentNode.removeChild(node);
  1467. },
  1468. 'DOMContentLoaded': function() {
  1469. var words = new RegExp(
  1470. 'блокировщика рекламы'
  1471. .split('')
  1472. .map(function(e){return e+'[\u200b\u200c\u200d]*';})
  1473. .join('')
  1474. .replace(' ', '\\s*')
  1475. .replace(/[аоре]/g, function(e){return ['[аa]','[оo]','[рp]','[еe]']['аоре'.indexOf(e)];}),
  1476. 'i'),
  1477. can;
  1478. function deeper(spider) {
  1479. var c, l, n;
  1480. if (words.test(spider.innerText)) {
  1481. if (spider.nodeType === Node.TEXT_NODE) {
  1482. return true;
  1483. }
  1484. c = spider.childNodes;
  1485. l = c.length;
  1486. n = 0;
  1487. while(l--) {
  1488. if (deeper(c[l]), can) {
  1489. n++;
  1490. }
  1491. }
  1492. if (n > 0 && n === c.length && spider.offsetHeight < 750) {
  1493. can.push(spider);
  1494. }
  1495. return false;
  1496. }
  1497. return true;
  1498. }
  1499. function probe(){
  1500. if (words.test(document.body.innerText)) {
  1501. can = [];
  1502. deeper(document.body);
  1503. var i = can.length, j, spider;
  1504. while(i--) {
  1505. spider = can[i];
  1506. if (spider.offsetHeight > 10 && spider.offsetHeight < 750) {
  1507. spider.setAttribute('style', 'background:none!important');
  1508. }
  1509. }
  1510. }
  1511. }
  1512. var o = new MutationObserver(probe);
  1513. o.observe(document,{childList:true, subtree:true});
  1514. }
  1515. };
  1516. scripts['joyreactor.cc'] = scripts['reactor.cc'];
  1517. scripts['pornreactor.cc'] = scripts['reactor.cc'];
  1518.  
  1519. scripts['auto.ru'] = function() {
  1520. var words = /Реклама|Яндекс.Директ|yandex_ad_/;
  1521. var userAdsListAds = [
  1522. '.listing-list > .listing-item',
  1523. '.listing-item_type_fixed.listing-item'
  1524. ];
  1525. var catalogAds = [
  1526. 'div[class*="layout_catalog-inline"]',
  1527. 'div[class$="layout_horizontal"]'
  1528. ];
  1529. var otherAds = [
  1530. '.advt_auto',
  1531. '.sidebar-block',
  1532. '.pager-listing + div[class]',
  1533. '.card > div[class][style]',
  1534. '.sidebar > div[class]',
  1535. '.main-page__section + div[class]',
  1536. '.listing > tbody'];
  1537. gardener(userAdsListAds.join(','), words, {root:'.listing-wrap', observe:true});
  1538. gardener(catalogAds.join(','), words, {root:'.catalog__page,.content__wrapper', observe:true});
  1539. gardener(otherAds.join(','), words);
  1540. };
  1541.  
  1542. scripts['rsload.net'] = {
  1543. 'load': function() {
  1544. var dis = document.querySelector('.cb-disables');
  1545. if (dis) {
  1546. dis.click();
  1547. }
  1548. },
  1549. 'click': function(e) {
  1550. var t = e.target;
  1551. if (t && t.href && (/:\/\/\d+\.\d+\.\d+\.\d+\//.test(t.href))) {
  1552. t.href = t.href.replace('://','://rsload.net:rsload.net@');
  1553. }
  1554. }
  1555. };
  1556.  
  1557. var domain = document.domain, name;
  1558. while (domain.indexOf('.') !== -1) {
  1559. if (scripts.hasOwnProperty(domain)) {
  1560. if (typeof scripts[domain] === 'function') {
  1561. document.addEventListener ('DOMContentLoaded', scripts[domain], false);
  1562. }
  1563. for (name in scripts[domain]) {
  1564. if (name !== 'now') {
  1565. (name === 'load' ? window : document)
  1566. .addEventListener (name, scripts[domain][name], false);
  1567. } else {
  1568. scripts[domain][name]();
  1569. }
  1570. }
  1571. }
  1572. domain = domain.slice(domain.indexOf('.') + 1);
  1573. }
  1574. })();