RU AdList JS Fixes

try to take over the world!

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

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