RU AdList JS Fixes

try to take over the world!

当前为 2017-02-09 提交的版本,查看 最新版本

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