Greasy Fork 还支持 简体中文。

RU AdList JS Fixes

try to take over the world!

目前為 2018-03-07 提交的版本,檢視 最新版本

  1. // ==UserScript==
  2. // @name RU AdList JS Fixes
  3. // @namespace ruadlist_js_fixes
  4. // @version 20180307.0
  5. // @description try to take over the world!
  6. // @author lainverse & dimisa
  7. // @supportURL https://greasyfork.org/en/scripts/19993-ru-adlist-js-fixes/feedback
  8. // @match *://*/*
  9. // @exclude *://auth.wi-fi.ru/*
  10. // @exclude *://*.alfabank.ru/*
  11. // @exclude *://alfabank.ru/*
  12. // @exclude *://*.unicreditbanking.net/*
  13. // @exclude *://unicreditbanking.net/*
  14. // @exclude *://*.telegram.org/*
  15. // @exclude *://telegram.org/*
  16. // @grant unsafeWindow
  17. // @grant window.close
  18. // @run-at document-start
  19. // ==/UserScript==
  20.  
  21. (function() {
  22. 'use strict';
  23.  
  24. let win = (unsafeWindow || window);
  25.  
  26. // MooTools are crazy enough to replace standard browser object window.Document: https://mootools.net/core
  27. // Occasionally their code runs before my script on some domains and causes all kinds of havoc.
  28. let _Document = Object.getPrototypeOf(HTMLDocument);
  29. // dTree 2.05 in some cases replaces Node object
  30. let _Node = Object.getPrototypeOf(Element);
  31.  
  32. // http://stackoverflow.com/questions/9847580/how-to-detect-safari-chrome-ie-firefox-and-opera-browser
  33. let isOpera = (!!window.opr && !!opr.addons) || !!window.opera || navigator.userAgent.indexOf(' OPR/') >= 0,
  34. isChrome = !!window.chrome && !!window.chrome.webstore,
  35. isSafari = (Object.prototype.toString.call(window.HTMLElement).indexOf('Constructor') > 0 ||
  36. (function (p) { return p.toString() === "[object SafariRemoteNotification]"; })(!window.safari || safari.pushNotification)),
  37. isFirefox = 'InstallTrigger' in win,
  38. ifFirefoxUnder58 = isFirefox && 'StopIteration' in win,
  39. inIFrame = (win.self !== win.top),
  40. _getAttribute = Element.prototype.getAttribute,
  41. _setAttribute = Element.prototype.setAttribute,
  42. _removeAttribute = Element.prototype.removeAttribute,
  43. _de = document.documentElement,
  44. _appendChild = _Document.prototype.appendChild.bind(_de),
  45. _removeChild = _Document.prototype.removeChild.bind(_de),
  46. _createElement = _Document.prototype.createElement.bind(document);
  47.  
  48. if (isFirefox && // Exit on image pages in Fx
  49. document.constructor.prototype.toString() === '[object ImageDocumentPrototype]')
  50. return;
  51.  
  52. // NodeList iterator polyfill (mostly for Safari)
  53. // https://jakearchibald.com/2014/iterators-gonna-iterate/
  54. if (!NodeList.prototype[Symbol.iterator])
  55. NodeList.prototype[Symbol.iterator] = Array.prototype[Symbol.iterator];
  56.  
  57. // Wrapper to run scripts designed to override objects available to other scripts
  58. // Required in old versions of Firefox (<58) or when running with Greasemonkey
  59. let skipLander = true;
  60. try {
  61. skipLander = !(ifFirefoxUnder58 || (isFirefox && GM.info.scriptHandler === 'Greasemonkey'));
  62. } catch(ignore){}
  63. let batchLand = [];
  64. let batchPrepend = [];
  65. let _APIString = 'let win = window, _Document = Object.getPrototypeOf(HTMLDocument), _Node = Object.getPrototypeOf(Element);';
  66. let landScript = (f, pre) => {
  67. let script = _createElement('script');
  68. script.textContent = `(()=>{${_APIString}${(
  69. (pre.length > 0 ? pre.join(';') : '')
  70. )};(${f.join(')();(')})();})();`;
  71. _appendChild(script);
  72. _removeChild(script);
  73. };
  74. let scriptLander = f => f();
  75. if (!skipLander) {
  76. scriptLander = (func, ...prepend) => {
  77. prepend.forEach(
  78. x => batchPrepend.includes(x) ? null : batchPrepend.push(x)
  79. );
  80. batchLand.push(func);
  81. };
  82. document.addEventListener(
  83. 'DOMContentLoaded', ignore => scriptLander = (f, ...prep) => landScript([f], prep), false
  84. );
  85. }
  86.  
  87. function nullTools(opts) {
  88. // jshint validthis:true
  89. let nt = this;
  90. opts = opts || {};
  91. function log() { if (opts.log) console.log(...arguments); }
  92. function trace() { if (opts.log || opts.trace) console.warn(...arguments); }
  93.  
  94. nt.destroy = function(o, destroy)
  95. {
  96. if (!opts.destroy && !destroy && o instanceof Object)
  97. return;
  98. log('cleaning', o);
  99. try {
  100. for (let item in o)
  101. {
  102. if (item instanceof Object)
  103. nt.destroy(item);
  104. delete o[item];
  105. }
  106. } catch (e) {
  107. log('Error in object destructor', e);
  108. }
  109. };
  110.  
  111. nt.define = function(obj, prop, val, enumerable = true)
  112. {
  113. try {
  114. Object.defineProperty(
  115. obj, prop, {
  116. get: () => val,
  117. set: (v) => (v !== val ? (log(`set ${prop} of`, obj, 'to', v), nt.destroy(v)) : null, undefined),
  118. enumerable: enumerable
  119. }
  120. );
  121. } catch (err) {
  122. console.log(`Unable to redefine "${prop}" in `, obj, err);
  123. }
  124. };
  125. nt.proxy = function(obj)
  126. {
  127. return new Proxy(
  128. obj, {
  129. get: (t, p) => p in t ? t[p] : console.warn(`Missing ${p} in`, t),
  130. set: (t, p, v) => (v !== t[p] ? (log(`set ${p} of`, t, 'to', v), nt.destroy(v)) : null, true)
  131. }
  132. );
  133. };
  134. nt.func = (val, name = '') => (...args) => (trace(`call obj.${name}(`, ...args,`) return`, val), val);
  135. }
  136.  
  137. // Debug function, lists all unusual window properties
  138. function getStrangeObjectsList()
  139. {
  140. console.warn('Strangers list start');
  141. let _ts = Function.prototype.toString;
  142. let _skip = 'frames/self/window/webkitStorageInfo'.split('/');
  143. for (let n in win) {
  144. let val = win[n];
  145. if (val && !_skip.includes(n) && (win !== window && val !== window[n] || win === window) &&
  146. (!(val instanceof Function) ||
  147. val instanceof Function &&
  148. !(new RegExp (`^function\\s(${n})?\\(\\)[\\s\\r\\n]*\\{[\\s\\r\\n]*\\[native\\scode\\][\\s\\r\\n]*\\}$`)).test(_ts.call(val))))
  149. console.log(`${n} =`, val);
  150. }
  151. console.warn('Strangers list end');
  152. }
  153.  
  154. // Fake objects of advertisement networks to break their workflow
  155. scriptLander(
  156. function()
  157. {
  158. let nt = new nullTools();
  159. // Popular adblock detector
  160. if (!('fuckAdBlock' in win))
  161. {
  162. let FuckAdBlock = function(options) {
  163. let self = this;
  164. self._options = {
  165. checkOnLoad: false,
  166. resetOnEnd: false,
  167. checking: false
  168. };
  169. self.setOption = function(opt, val)
  170. {
  171. if (val)
  172. self._options[opt] = val;
  173. else
  174. Object.assign(self._options, opt);
  175. };
  176. if (options)
  177. self.setOption(options);
  178.  
  179. self._var = { event: {} };
  180. self.clearEvent = function()
  181. {
  182. self._var.event.detected = [];
  183. self._var.event.notDetected = [];
  184. };
  185. self.clearEvent();
  186.  
  187. self.on = function(detected, fun)
  188. {
  189. self._var.event[detected?'detected':'notDetected'].push(fun);
  190. return self;
  191. };
  192. self.onDetected = function(cb)
  193. {
  194. return self.on(true, cb);
  195. };
  196. self.onNotDetected = function(cb)
  197. {
  198. return self.on(false, cb);
  199. };
  200. self.emitEvent = function()
  201. {
  202. for (let fun of self._var.event.notDetected)
  203. fun();
  204. if (self._options.resetOnEnd)
  205. self.clearEvent();
  206. return self;
  207. };
  208. self._creatBait = () => null;
  209. self._destroyBait = () => null;
  210. self._checkBait = function() {
  211. setTimeout((() => self.emitEvent()), 1);
  212. };
  213. self.check = function() {
  214. self._checkBait();
  215. return true;
  216. };
  217.  
  218. let callback = function()
  219. {
  220. if (self._options.checkOnLoad)
  221. setTimeout(self.check, 1);
  222. };
  223. window.addEventListener('load', callback, false);
  224. };
  225. nt.define(win, 'FuckAdBlock', FuckAdBlock);
  226. nt.define(win, 'fuckAdBlock', new FuckAdBlock({
  227. checkOnLoad: true,
  228. resetOnEnd: true
  229. }));
  230. }
  231.  
  232. // go.onclasrv.com pop-ups/tab-uners
  233. if (!('zfgloadedpopup' in win))
  234. nt.define(win, 'zfgloadedpopup', true);
  235.  
  236. // CoinHive miner stub. Continuous 100% CPU load can easily kill some CPU with overheat.
  237. if (!('CoinHive' in win))
  238. {
  239. if (location.hostname !== 'cnhv.co')
  240. {
  241. // CoinHive stub for cases when it doesn't affect site functionality
  242. let CoinHiveConstructor = function()
  243. {
  244. console.warn('Fake CoinHive miner created.');
  245. this.setThrottle = nt.func(null);
  246. this.start = nt.func(null);
  247. this.on = nt.func(null);
  248. this.getTotalHashes = nt.func(0);
  249. };
  250. let CoinHiveStub = nt.proxy({
  251. Anonymous: CoinHiveConstructor,
  252. User: CoinHiveConstructor,
  253. Token: CoinHiveConstructor,
  254. JobThread: nt.func(null),
  255. IF_EXCLUSIVE_TAB: false
  256. });
  257. nt.define(win, 'CoinHive', CoinHiveStub);
  258. } else {
  259. // CoinHive wrapper to fool sites which expect it to actually work and return results
  260. let CoinHiveObject;
  261. let fishnet = {
  262. apply: (target, thisArg, args) => {
  263. console.log(`miner.${target._name}(${JSON.stringify(args).slice(1,-1)})`);
  264. return target.apply(thisArg, args);
  265. }
  266. };
  267. Object.defineProperty(win, 'CoinHive', {
  268. set: function(obj)
  269. {
  270. if ('Token' in obj)
  271. {
  272. console.log('[CoinHive] Token wrapper applied.');
  273. let _Token = obj.Token.bind(obj);
  274. obj.Token = function(siteKey, goal, params)
  275. {
  276. let _goal = goal;
  277. if (goal > 256)
  278. goal = 256;
  279. console.log(`[CoinHive] Original goal: ${_goal}, new smaller goal ${goal}.`);
  280. console.log(`With smaller goals server may return 'invalid_goal' error and stop working.`);
  281. let miner = _Token(siteKey, goal, params);
  282. miner.setThrottle(0.99);
  283. miner.setThrottle = () => null;
  284. let _start = miner.start.bind(miner);
  285. miner.start = function() {
  286. let res = _start(CoinHive.FORCE_EXCLUSIVE_TAB);
  287. return res;
  288. };
  289. let _getTotalHashes = miner.getTotalHashes;
  290. miner.getTotalHashes = function()
  291. {
  292. return Math.trunc(_getTotalHashes.call(this) / goal * _goal);
  293. };
  294. let __emit = miner._emit;
  295. miner._emit = function(state, props)
  296. {
  297. let _self = this;
  298. console.log('[CoinHive] state:', state, props);
  299. if (state === 'job')
  300. setTimeout(() => {
  301. _self.stop();
  302. _self._emit('accepted', { hashes: goal });
  303. }, 1000);
  304. return __emit.apply(_self, arguments);
  305. };
  306. let _on = miner.on.bind(miner);
  307. miner.on = function(type, callback)
  308. {
  309. if (type === 'accepted')
  310. {
  311. console.log('[CoinHive] "accepted" callback wrapper applied.');
  312. let _callback = callback;
  313. callback = function(params)
  314. {
  315. console.log('[CoinHive] "accepted" callback is called, imitating original goal being reached.');
  316. params.hashes = _goal;
  317. return _callback.apply(this, arguments);
  318. };
  319. miner.stop();
  320. }
  321. return _on(type, callback);
  322. };
  323. return miner;
  324. };
  325. }
  326. CoinHiveObject = obj;
  327. },
  328. get: () => CoinHiveObject
  329. });
  330. }
  331. }
  332.  
  333. // VideoJS player wrapper
  334. VideoJS: {
  335. let _videojs = win.videojs || void 0;
  336. Object.defineProperty(win, 'videojs', {
  337. get: x => _videojs,
  338. set: f => {
  339. if (f === _videojs)
  340. return true;
  341. console.log('videojs =', f);
  342. _videojs = new Proxy(f, {
  343. apply: (tgt, ths, args) => {
  344. console.log('videojs(', ...args, ')');
  345. let params = args[1];
  346. if (params) {
  347. if (params.hasAd)
  348. params.hasAd = false;
  349. if (params.plugins && params.plugins.vastClient)
  350. delete params.plugins.vastClient;
  351. }
  352. let res = tgt.apply(ths, args);
  353. console.log('player = ', res);
  354. return res;
  355. }
  356. });
  357. }
  358. });
  359. }
  360. // Yandex API (ADBTools, Metrika)
  361. let hostname = location.hostname;
  362. if (location.protocol === 'about:' ||
  363. // Thank you, Greasemonkey, now I have to check for this. -_-
  364. hostname.startsWith('google.') || hostname.includes('.google.') ||
  365. // Google likes to define odd global variables like Ya
  366. ((hostname.startsWith('yandex.') || hostname.includes('.yandex.')) &&
  367. /^\/((yand)?search|images)/i.test(location.pathname) &&
  368. !hostname.startsWith('news.')) ||
  369. // Also, Yandex uses their Ya object for a lot of things on their pages and
  370. // wrapping it may cause problems. It's better to skip it in some cases.
  371. hostname.endsWith('github.io') || hostname.endsWith('grimtools.com'))
  372. return;
  373.  
  374. let YaProps = new Set();
  375. function onAdvManager (Ya, rootProp, obj)
  376. {
  377. return new Proxy(obj, {
  378. set: (tgt, prop, val) => {
  379. if (prop === 'AdvManager')
  380. {
  381. console.log(`Ya.${rootProp} = Ya.Context`);
  382. nt.define(Ya, rootProp, Ya.Context);
  383. YaProps.add(rootProp);
  384. }
  385. tgt[prop] = val;
  386. return true;
  387. },
  388. get: (tgt, prop) => tgt[prop]
  389. });
  390. }
  391. let Rum = {};
  392. [
  393. '__timeMarks', '_timeMarks', '__deltaMarks', '_deltaMarks',
  394. '__defRes', '_defRes', '__defTimes', '_defTimes',
  395. 'commonVars'
  396. ].forEach(name => Rum[name] = []);
  397. [
  398. 'send', 'sendRaf', 'sendTimeMark', 'sendResTiming', 'sendTTI',
  399. 'time', 'timeEnd', 'getTime', 'mark', 'init',
  400. 'makeSubPage', 'observeDOMNode', 'isVisibilityChanged'
  401. ].forEach(name => Rum[name] = nt.func(null, name));
  402. [
  403. 'getSettings', 'getVarsList'
  404. ].forEach(name => Rum[name] = nt.func([], name));
  405. [
  406. ['ajaxStart', 0], ['ajaxComplete', 0],
  407. ['enabled', true], ['_tti', null],
  408. ['vsChanged', false], ['vsStart', 'visible']
  409. ].forEach(([prop, val]) => Rum[prop] = val);
  410. Rum = nt.proxy(Rum);
  411. let Ya = new Proxy({}, {
  412. set: function(tgt, prop, val)
  413. {
  414. if (val === tgt[prop])
  415. return true;
  416. if (prop === 'Rum')
  417. {
  418. nt.define(tgt, prop, Rum);
  419. YaProps.add(prop);
  420. Object.assign(val, Rum);
  421. }
  422. if (YaProps.has(prop))
  423. {
  424. console.log(`Ya.${prop} \u2260`, val);
  425. return true;
  426. }
  427. if (val instanceof Object && prop !== '__inline_params__')
  428. val = onAdvManager(Ya, prop, val);
  429. tgt[prop] = val;
  430. console.log(`Ya.${prop} =`, val);
  431. return true;
  432. },
  433. get: (tgt, prop) => tgt[prop]
  434. });
  435. let callWithParams = function(f)
  436. {
  437. f.call(this, Ya.__inline_params__ || {});
  438. Ya.__inline_params__ = null;
  439. };
  440. nt.define(Ya, 'callWithParams', callWithParams);
  441. nt.define(Ya, 'PerfCounters', nt.proxy({
  442. addCacheEvent: nt.func(null),
  443. getTime: nt.func(null),
  444. sendCacheEvents: nt.func(null),
  445. sendResTiming: nt.func(null),
  446. sendTimeMark: nt.func(null),
  447. __cacheEvents: []
  448. }));
  449. nt.define(Ya, '__isSent', true);
  450. nt.define(Ya, 'confirmUrl', '');
  451. nt.define(Ya, 'Direct', nt.proxy({
  452. insertInto: nt.func(null)
  453. }));
  454. nt.define(Ya, 'mediaCode', nt.proxy({
  455. create: function()
  456. {
  457. if (inIFrame)
  458. {
  459. console.log('Removed body of ad-frame.');
  460. document.documentElement.removeChild(document.body);
  461. }
  462. },
  463. moduleLoad: nt.func(null),
  464. setModule: nt.func(null)
  465. }));
  466. let extra = nt.proxy({
  467. extra: nt.proxy({ match: 0, confirm: '', src: '' }),
  468. id: 0, percent: 100, threshold: 1
  469. });
  470. nt.define(Ya, '_exp', nt.proxy({
  471. id: 0, coin: 0,
  472. choose: nt.func(extra),
  473. get: (prop) => extra.hasOwnProperty(prop) ? extra[prop] : null,
  474. getId: nt.func(0),
  475. defaultVersion: extra,
  476. getExtra: nt.func(extra.extra),
  477. getDefaultExtra: nt.func(extra.extra),
  478. versions: [extra]
  479. }));
  480. nt.define(Ya, 'c', nt.func(null));
  481. nt.define(Ya, 'ADBTools', function(){
  482. ['loadContext', 'testAdbStyle'].forEach(name => this[name] = nt.func(null));
  483. this.getCurrentState = nt.func(true);
  484. return nt.proxy(this);
  485. });
  486.  
  487. if (!location.hostname.includes('kinopoisk.ru')) {
  488. // kinopoisk uses adfox wrapped in Yandex code to display self-ads
  489. let adfoxCode = {};
  490. [
  491. 'create', 'reload', 'destroy',
  492. 'createAdaptive', 'moduleLoad',
  493. 'createScroll', 'pr'
  494. ].forEach(name => adfoxCode[name] = nt.func(null, name));
  495. nt.define(Ya, 'adfoxCode', nt.proxy(adfoxCode));
  496. } else {
  497. nt.define(win, 'abExperiments', nt.proxy([]));
  498. }
  499. let AdvManager = function()
  500. {
  501. [
  502. 'renderDirect',
  503. 'getBid', 'releaseBid',
  504. 'getSkipToken',
  505. 'getAdSessionId'
  506. ].forEach(name => this[name] = nt.func(null, name));
  507. this.render = function(o) {
  508. if (!o.renderTo)
  509. return;
  510. let placeholder = document.getElementById(o.renderTo);
  511. let parent = placeholder.parentNode;
  512. placeholder.style = 'display:none!important';
  513. parent.style = (parent.getAttribute('style')||'') + 'height:auto!important';
  514. // fix for Yandex TV pages
  515. if (location.hostname.startsWith('tv.yandex.'))
  516. {
  517. let sibling = placeholder.previousSibling;
  518. if (sibling && sibling.classList && sibling.classList.contains('tv-spin'))
  519. sibling.style.display = 'none';
  520. }
  521. };
  522. return nt.proxy(this);
  523. };
  524. nt.define(Ya, 'Context', nt.proxy({
  525. __longExperiment: null,
  526. _callbacks: nt.proxy([]),
  527. _asyncModeOn: true,
  528. _init: nt.func(null),
  529. isAllowedRepeatAds: nt.func(null),
  530. AdvManager: new AdvManager()
  531. }));
  532. let Metrika = function()
  533. {
  534. [
  535. 'reachGoal', 'replacePhones',
  536. 'trackLinks', 'userParams',
  537. 'hit', 'params', 'clickmap'
  538. ].forEach(name => this[name] = nt.func(null, name));
  539. this.id = 0;
  540. return nt.proxy(this);
  541. };
  542. Metrika.counters = () => Ya._metrika.counters;
  543. nt.define(Ya, 'Metrika', Metrika);
  544. let counter = new Ya.Metrika();
  545. nt.define(Ya, '_metrika', nt.proxy({
  546. counter: counter,
  547. counters: [counter],
  548. hitParam: {},
  549. counterNum: 0,
  550. hitId: 0,
  551. v: 1
  552. }));
  553. nt.define(Ya, '_globalMetrikaHitId', 0);
  554. counter = {};
  555. [
  556. 'cpHitDelayed','wHitDelayed',
  557. 'hitDelayed','makeReq',
  558. 'redir','hit','log','cp','w'
  559. ].forEach(name => counter[name] = nt.func(null, name));
  560. [
  561. 'stringifyParams','_getVars',
  562. 'getUid','getUrl','getHash'
  563. ].forEach(name => counter[name] = nt.func(''));
  564. nt.define(Ya, 'counter', nt.proxy(counter));
  565. nt.define(Ya, 'jserrors', []);
  566. nt.define(Ya, 'onerror', nt.func(null, 'onerror'));
  567. if (win.Ya) {
  568. console.log('Found existing Ya object:', win.Ya);
  569. for (let prop in win.Ya)
  570. Ya[prop] = win.Ya[prop];
  571. }
  572. for (let prop in Ya) if (prop !== '__inline_params__')
  573. YaProps.add(prop);
  574. nt.define(win, 'Ya', Ya);
  575. // Yandex.Metrika callbacks
  576. let yandex_metrika_callbacks = [];
  577. document.addEventListener(
  578. 'DOMContentLoaded',
  579. (e) => {
  580. yandex_metrika_callbacks.forEach((f) => f && f.call(window));
  581. yandex_metrika_callbacks.length = 0;
  582. yandex_metrika_callbacks.push = (f) => setTimeout(f, 0);
  583. },
  584. false
  585. );
  586. nt.define(win, 'yandex_metrika_callbacks', yandex_metrika_callbacks);
  587. }, nullTools
  588. );
  589.  
  590. // Creates and return protected style (unless protection is manually disabled).
  591. // Protected style will re-add itself on removal and remaind enabled on attempt to disable it.
  592. function createStyle(rules, props, skip_protect)
  593. {
  594. props = props || {};
  595. props.type = 'text/css';
  596.  
  597. function _protect(style)
  598. {
  599. if (skip_protect)
  600. return;
  601.  
  602. Object.defineProperty(style, 'sheet', {
  603. value: null,
  604. enumerable: true
  605. });
  606. Object.defineProperty(style, 'disabled', {
  607. get: () => true, //pretend to be disabled
  608. set: () => undefined,
  609. enumerable: true
  610. });
  611. (new MutationObserver(
  612. (ms) => _removeChild(ms[0].target)
  613. )).observe(style, { childList: true });
  614. }
  615.  
  616.  
  617. function _create()
  618. {
  619. let style = _appendChild(_createElement('style'));
  620. Object.assign(style, props);
  621.  
  622. function insertRules(rule)
  623. {
  624. if (rule.forEach)
  625. rule.forEach(insertRules);
  626. else try {
  627. style.sheet.insertRule(rule, 0);
  628. } catch (e) {
  629. console.error(e);
  630. }
  631. }
  632.  
  633. insertRules(rules);
  634. _protect(style);
  635.  
  636. return style;
  637. }
  638.  
  639. let style = _create();
  640. if (skip_protect)
  641. return style;
  642.  
  643. function resolveInANewContext(resolve)
  644. {
  645. setTimeout(
  646. (resolve) => resolve(_create()),
  647. 0, resolve
  648. );
  649. }
  650.  
  651. (new MutationObserver(
  652. function(ms)
  653. {
  654. let m, node;
  655. for (m of ms) for (node of m.removedNodes)
  656. if (node === style)
  657. (new Promise(resolveInANewContext))
  658. .then((st) => (style = st));
  659. }
  660. )).observe(_de, { childList: true });
  661.  
  662. return style;
  663. }
  664.  
  665. // Simplistic WebSocket wrapper for troublesome browsers and
  666. // disable 'onerror' handler for scripts from blacklisted sources
  667. scriptLander(() => {
  668. let masks = [],
  669. isBlocked = url => masks.some(mask => mask.test(url));
  670. for (let filter of [// blacklist
  671. '||185.87.50.147^',
  672. '||10root25.website^', '||24video.xxx^',
  673. '||adlabs.ru^', '||adspayformymortgage.win^', '||aviabay.ru^',
  674. '||bgrndi.com^', '||brokeloy.com^',
  675. '||cnamerutor.ru^',
  676. '||docfilms.info^', '||dreadfula.ru^',
  677. '||et-code.ru^', '||etcodes.com^',
  678. '||franecki.net^', '||film-doma.ru^',
  679. '||free-torrent.org^', '||free-torrent.pw^',
  680. '||free-torrents.org^', '||free-torrents.pw^',
  681. '||game-torrent.info^', '||gocdn.ru^',
  682. '||hdkinoshka.com^', '||hghit.com^', '||hindcine.net^',
  683. '||joyreactor.cc^', '||pornreactor.cc^', '||reactor.cc^',
  684. '||kiev.ua^', '||kinotochka.net^',
  685. '||kinott.com^', '||kinott.ru^', '||kuveres.com^',
  686. '||lepubs.com^', '||luxadv.com^', '||luxup.ru^', '||luxupcdna.com^',
  687. '||mail.ru^', '||marketgid.com^', '||mebablo.com^', '||mixadvert.com^', '||mxtads.com^',
  688. '||nickhel.com^',
  689. '||oconner.biz^', '||oconner.link^', '||octoclick.net^', '||octozoon.org^',
  690. '||pkpojhc.com^',
  691. '||psma01.com^', '||psma02.com^', '||psma03.com^',
  692. '||recreativ.ru^', '||redtram.com^', '||regpole.com^',
  693. '||rootmedia.ws^', '||ruttwind.com^', '||rutvind.com^',
  694. '||skidl.ru^',
  695. '||torvind.com^', '||traffic-media.co^', '||trafmag.com^', '||ttarget.ru^',
  696. '||webadvert-gid.ru^', '||webadvertgid.ru^',
  697. '||xxuhter.ru^',
  698. '||yuiout.online^',
  699. '||zoom-film.ru^'])
  700. masks.push(new RegExp(
  701. filter.replace(/([\\\/\[\].*+?(){}$])/g, '\\$1')
  702. .replace(/\^(?!$)/g,'\\.?[^\\w%._-]')
  703. .replace(/\^$/,'\\.?([^\\w%._-]|$)')
  704. .replace(/^\|\|/,'^(ws|http)s?:\\/+([^\/.]+\\.)*'),
  705. 'i'));
  706.  
  707. let _createElement = _Document.prototype.createElement,
  708. _addEventListener = Element.prototype.addEventListener,
  709. _removeEventListener = Element.prototype.removeEventListener;
  710.  
  711. let scriptMap = new WeakMap();
  712. scriptMap.isBlocked = isBlocked;
  713. let onErrorWrapper = {
  714. set: function(val)
  715. {
  716. if (scriptMap.has(this))
  717. {
  718. _removeEventListener.call(this, 'error', scriptMap.get(this).wrp, false);
  719. scriptMap.delete(this);
  720. }
  721. if (!val || typeof val !== 'function')
  722. return val;
  723.  
  724. scriptMap.set(this, {
  725. org: val,
  726. wrp: function(...args)
  727. {
  728. if (scriptMap.isBlocked(this.src))
  729. console.log('[WSI] Blocked "onerror" callback from', this.src);
  730. else
  731. scriptMap.get(this).org.apply(this, args);
  732. }
  733. });
  734. _addEventListener.call(this, 'error', scriptMap.get(this).wrp, false);
  735. },
  736. get: function()
  737. {
  738. return scriptMap.has(this) ? scriptMap.get(this).org : null;
  739. },
  740. enumerable: true
  741. };
  742. _Document.prototype.createElement = function createElement(...args) {
  743. let el = _createElement.apply(this, args);
  744. if (el.tagName === 'SCRIPT')
  745. Object.defineProperty(el, 'onerror', onErrorWrapper);
  746. return el;
  747. };
  748. // Simplistic WebSocket wrapper for Maxthon and Firefox before v58
  749. WSWrap: {
  750. if (/Maxthon/.test(navigator.appVersion) ||
  751. 'InstallTrigger' in win && 'StopIteration' in win) {
  752. let _ws = Object.getOwnPropertyDescriptor(win, 'WebSocket');
  753. if (!_ws)
  754. break WSWrap;
  755. _ws.value = new Proxy(_ws.value, {
  756. construct: (ws, args) => {
  757. if (isBlocked(args[0])) {
  758. console.log('[WSI] Blocked WS connection:', args[0]);
  759. return {};
  760. }
  761. return new ws(...args);
  762. }
  763. });
  764. Object.defineProperty(win, 'WebSocket', _ws);
  765. }
  766. }
  767. });
  768.  
  769. if (!isFirefox)
  770. { // scripts for non-Firefox browsers
  771. // https://greasyfork.org/scripts/14720-it-s-not-important
  772. {
  773. let imptt = /((display|(margin|padding)(-top|-bottom)?)\s*:[^;!]*)!\s*important/ig,
  774. ret_b = (a,b) => b,
  775. _toLowerCase = String.prototype.toLowerCase,
  776. protectedNodes = new WeakSet(),
  777. log = false;
  778.  
  779. let logger = function()
  780. {
  781. if (log)
  782. console.log('Some page elements became a bit less important.');
  783. log = false;
  784. };
  785.  
  786. let unimportanter = function(node)
  787. {
  788. let style = (node.nodeType === _Node.ELEMENT_NODE) ?
  789. _getAttribute.call(node, 'style') : null;
  790.  
  791. if (!style || !imptt.test(style) || node.style.display === 'none' ||
  792. (node.src && node.src.slice(0,17) === 'chrome-extension:')) // Web of Trust IFRAME and similar
  793. return false; // get out if we have nothing to do here
  794.  
  795. protectedNodes.add(node);
  796. _setAttribute.call(node, 'style',
  797. style.replace(imptt, ret_b));
  798. log = true;
  799. };
  800.  
  801. (new MutationObserver(
  802. function(mutations)
  803. {
  804. setTimeout(
  805. function(ms)
  806. {
  807. let m, node;
  808. for (m of ms) for (node of m.addedNodes)
  809. unimportanter(node);
  810. logger();
  811. }, 0, mutations
  812. );
  813. }
  814. )).observe(document, {
  815. childList : true,
  816. subtree : true
  817. });
  818.  
  819. Element.prototype.setAttribute = function setAttribute(name, value)
  820. {
  821. "[native code]";
  822. let replaced = value;
  823. if (_toLowerCase.call(name) === 'style' && protectedNodes.has(this))
  824. replaced = value.replace(imptt, ret_b);
  825. log = (replaced !== value);
  826. logger();
  827. return _setAttribute.call(this, name, replaced);
  828. };
  829.  
  830. win.addEventListener (
  831. 'load', function()
  832. {
  833. for (let imp of document.querySelectorAll('[style*="!"]'))
  834. unimportanter(imp);
  835. logger();
  836. }, false
  837. );
  838. }
  839.  
  840. // Naive ABP Style protector
  841. {
  842. let _querySelector = _Document.prototype.querySelector.bind(document);
  843. let _removeChild = _Node.prototype.removeChild;
  844. let _appendChild = _Node.prototype.appendChild;
  845. let createShadow = () => _createElement('shadow');
  846. // Prevent adding fake content entry point
  847. _Node.prototype.appendChild = function(child)
  848. {
  849. if (this instanceof ShadowRoot &&
  850. child instanceof HTMLContentElement)
  851. return _appendChild.call(this, createShadow());
  852. return _appendChild.apply(this, arguments);
  853. };
  854. {
  855. let _shadowSelector = ShadowRoot.prototype.querySelector;
  856. let _innerHTML = Object.getOwnPropertyDescriptor(ShadowRoot.prototype, 'innerHTML');
  857. let _parentNode = Object.getOwnPropertyDescriptor(_Node.prototype, 'parentNode');
  858. if (_innerHTML && _parentNode)
  859. {
  860. let _set = _innerHTML.set;
  861. let _getParent = _parentNode.get;
  862. _innerHTML.configurable = false;
  863. _innerHTML.set = function()
  864. {
  865. _set.apply(this, arguments);
  866. let content = _shadowSelector.call(this, 'content');
  867. if (content)
  868. {
  869. let parent = _getParent.call(content);
  870. _removeChild.call(parent, content);
  871. _appendChild.call(parent, createShadow());
  872. }
  873. };
  874. }
  875. Object.defineProperty(ShadowRoot.prototype, 'innerHTML', _innerHTML);
  876. }
  877. // Locate and apply extra protection to a style on top of what ABP does
  878. let style;
  879. (new Promise(
  880. function(resolve, reject)
  881. {
  882. let getStyle = () => _querySelector('::shadow style');
  883. style = getStyle();
  884. if (style)
  885. return resolve(style);
  886. let intv = setInterval(
  887. function()
  888. {
  889. style = getStyle();
  890. if (!style)
  891. return;
  892. intv = clearInterval(intv);
  893. return resolve(style);
  894. }, 0
  895. );
  896. document.addEventListener(
  897. 'DOMContentLoaded',
  898. function()
  899. {
  900. if (intv)
  901. clearInterval(intv);
  902. style = getStyle();
  903. return style ? resolve(style) : reject();
  904. },
  905. false
  906. );
  907. }
  908. )).then(
  909. function(style)
  910. {
  911. let emptyArr = [],
  912. nullStr = {
  913. get: () => '',
  914. set: () => undefined
  915. };
  916. let shadow = style.parentNode;
  917. Object.defineProperties(shadow, {
  918. childElementCount: { value: 0 },
  919. styleSheets: { value: emptyArr },
  920. firstChild: { value: null },
  921. firstElementChild: { value: null },
  922. lastChild: { value: null },
  923. lastElementChild: { value: null },
  924. childNodes: { value: emptyArr },
  925. children: { value: emptyArr },
  926. innerHTML: { value: nullStr },
  927. });
  928. Object.defineProperties(style, {
  929. innerHTML: { value: nullStr },
  930. textContent: { value: nullStr },
  931. ownerDocument: { value: null },
  932. parentNode: {value: null },
  933. previousElementSibling: { value: null },
  934. previousSibling: { value: null },
  935. disabled: { get: () => true, set: x => null }
  936. });
  937. Object.defineProperties(style.sheet, {
  938. deleteRule: { value: () => null },
  939. disabled: { get: () => true, set: x => null },
  940. cssRules: { value: emptyArr },
  941. rules: { value: emptyArr }
  942. });
  943. }
  944. ).catch(()=>null);
  945. _Node.prototype.removeChild = function(child)
  946. {
  947. if (child === style)
  948. return;
  949. return _removeChild.apply(this, arguments);
  950. };
  951. }
  952. }
  953. if (/^https?:\/\/(mail\.yandex\.|music\.yandex\.|news\.yandex\.|(www\.)?yandex\.[^\/]+\/(yand)?search[\/?])/i.test(win.location.href) ||
  954. /^https?:\/\/tv\.yandex\./i.test(win.location.href))
  955. {
  956. // https://greasyfork.org/en/scripts/809-no-yandex-ads
  957. let yadWord = /Яндекс.Директ/i,
  958. adWords = /Реклама|Ad/i;
  959. let _querySelector = document.querySelector.bind(document),
  960. _querySelectorAll = document.querySelectorAll.bind(document),
  961. _getAttribute = Element.prototype.getAttribute,
  962. _setAttribute = Element.prototype.setAttribute;
  963. // Function to attach an observer to monitor dynamic changes on the page
  964. let pageUpdateObserver = (func, obj, params) => {
  965. if (obj)
  966. (new MutationObserver(func))
  967. .observe(obj, (params || { childList:true, subtree:true }));
  968. };
  969. // Short name for parentNode.removeChild
  970. let remove = (node) => {
  971. if (!node || !node.parentNode)
  972. return false;
  973. console.log('Removed node.');
  974. node.parentNode.removeChild(node);
  975. };
  976. // Yandex search ads in Google Chrome
  977. if ('attachShadow' in Element.prototype)
  978. {
  979. let _attachShadow = Element.prototype.attachShadow;
  980. Element.prototype.attachShadow = function()
  981. {
  982. let node = this,
  983. root = _attachShadow.apply(node, arguments);
  984. pageUpdateObserver(
  985. (ms) => {
  986. for (let m of ms) if (m.addedNodes.length)
  987. if (adWords.test(root.textContent))
  988. remove(node.closest('.serp-item'));
  989. }, root
  990. );
  991. return root;
  992. };
  993. }
  994. // prevent/defuse adblock detector
  995. setInterval(()=>{
  996. localStorage.ic = '';
  997. localStorage._mt__data = '';
  998. },100);
  999. let _doc_proto = ('cookie' in _Document.prototype) ? _Document.prototype : Object.getPrototypeOf(document);
  1000. let _cookie = Object.getOwnPropertyDescriptor(_doc_proto, 'cookie');
  1001. if (_cookie)
  1002. {
  1003. let _set_cookie = Function.prototype.call.bind(_cookie.set);
  1004. _cookie.set = function(value)
  1005. {
  1006. if (/^(mda=|yp=|ys=|yabs-|__)/.test(value))
  1007. {
  1008. // remove value, set expired
  1009. if (!value.startsWith('yp=')) {
  1010. value = value.replace(/^([^=]+=)[^;]+/,'$1').replace(/(expires=)[\w\s\d,]+/,'$1Thu, 01 Jan 1970 00');
  1011. console.log('expire cookie', value.match(/^[^=]+/)[0]);
  1012. } else {
  1013. let parts = value.split(';');
  1014. let values = parts[0].split('#').filter(part => /\.sp\./.test(part));
  1015. if (values.length)
  1016. values[0] = values[0].replace(/^yp=/, '');
  1017. parts[0] = `yp=${values.join('#')}`;
  1018. value = parts.join(';');
  1019. console.log(`set cookie ${parts[0]}`);
  1020. }
  1021. //return null;
  1022. }
  1023. return _set_cookie(this, value);
  1024. };
  1025. Object.defineProperty(_doc_proto, 'cookie', _cookie);
  1026. }
  1027. // other ads
  1028. document.addEventListener(
  1029. 'DOMContentLoaded', function()
  1030. {
  1031. { // Generic ads removal and fixes
  1032. let node = _querySelector('.serp-header');
  1033. if (node)
  1034. node.style.marginTop = '0';
  1035. for (node of _querySelectorAll(
  1036. '.serp-adv__head + .serp-item,'+
  1037. '#adbanner,'+
  1038. '.serp-adv,'+
  1039. '.b-spec-adv,'+
  1040. 'div[class*="serp-adv__"]:not(.serp-adv__found):not(.serp-adv__displayed)'
  1041. )) remove(node);
  1042. }
  1043. // Search ads
  1044. function removeSearchAds()
  1045. {
  1046. for (let node of _querySelectorAll('.serp-item'))
  1047. if (_getAttribute.call(node, 'role') === 'complementary' ||
  1048. adWords.test((node.querySelector('.label')||{}).textContent))
  1049. remove(node);
  1050. }
  1051. // News ads
  1052. function removeNewsAds()
  1053. {
  1054. let node, block, item, items, mask, classes,
  1055. masks = [
  1056. { class: '.ads__wrapper', regex: /[^,]*?,[^,]*?\.ads__wrapper/ },
  1057. { class: '.ads__pool', regex: /[^,]*?,[^,]*?\.ads__pool/ }
  1058. ];
  1059. for (node of _querySelectorAll('style[nonce]'))
  1060. {
  1061. classes = node.innerText.replace(/\{[^}]+\}+/ig, '|').split('|');
  1062. for (block of classes) for (mask of masks)
  1063. if (block.includes(mask.class))
  1064. {
  1065. block = block.match(mask.regex)[0];
  1066. items = _querySelectorAll(block);
  1067. for (item of items)
  1068. remove(items[0]);
  1069. }
  1070. }
  1071. }
  1072. // Music ads
  1073. function removeMusicAds()
  1074. {
  1075. for (let node of _querySelectorAll('.ads-block'))
  1076. remove(node);
  1077. }
  1078. // Mail ads
  1079. function removeMailAds()
  1080. {
  1081. let slice = Array.prototype.slice,
  1082. nodes = slice.call(_querySelectorAll('.ns-view-folders')),
  1083. node, len, cls;
  1084.  
  1085. for (node of nodes)
  1086. if (!len || len > node.classList.length)
  1087. len = node.classList.length;
  1088.  
  1089. node = nodes.pop();
  1090. while (node)
  1091. {
  1092. if (node.classList.length > len)
  1093. for (cls of slice.call(node.classList))
  1094. if (cls.indexOf('-') === -1)
  1095. {
  1096. remove(node);
  1097. break;
  1098. }
  1099. node = nodes.pop();
  1100. }
  1101. }
  1102. // News fixes
  1103. function removePageAdsClass()
  1104. {
  1105. if (document.body.classList.contains("b-page_ads_yes"))
  1106. {
  1107. document.body.classList.remove("b-page_ads_yes");
  1108. console.log('Page ads class removed.');
  1109. }
  1110. }
  1111. // TV fixes
  1112. function removeTVAds()
  1113. {
  1114. for (let node of _querySelectorAll('div[class^="_"][data-reactid] > div'))
  1115. if (yadWord.test(node.textContent) || node.querySelector('iframe:not([src])'))
  1116. {
  1117. if (node.offsetWidth)
  1118. {
  1119. let pad = document.createElement('div');
  1120. _setAttribute.call(pad, 'style', `width:${node.offsetWidth}px`);
  1121. node.parentNode.appendChild(pad);
  1122. }
  1123. remove(node);
  1124. }
  1125. }
  1126.  
  1127. if (location.hostname.startsWith('mail.')) {
  1128. pageUpdateObserver(
  1129. function(ms, o)
  1130. {
  1131. let aside = _querySelector('.mail-Layout-Aside');
  1132. if (aside) {
  1133. o.disconnect();
  1134. pageUpdateObserver(removeMailAds, aside);
  1135. }
  1136. }, document.body
  1137. );
  1138. removeMailAds();
  1139. } else if (location.hostname.startsWith('music.')) {
  1140. pageUpdateObserver(removeMusicAds, _querySelector('.sidebar'));
  1141. removeMusicAds();
  1142. } else if (location.hostname.startsWith('news.')) {
  1143. pageUpdateObserver(removeNewsAds, document.body);
  1144. pageUpdateObserver(removePageAdsClass, document.body, { attributes:true, attributesFilter:['class'] });
  1145. removeNewsAds();
  1146. removePageAdsClass();
  1147. } else if (location.hostname.startsWith('tv.')) {
  1148. pageUpdateObserver(removeTVAds, document.body);
  1149. removeTVAds();
  1150. } else {
  1151. pageUpdateObserver(removeSearchAds, _querySelector('.main__content'));
  1152. removeSearchAds();
  1153. }
  1154. }
  1155. );
  1156. }
  1157.  
  1158. // Yandex Link Tracking
  1159. if (/^https?:\/\/([^.]+\.)*yandex\.[^\/]+/i.test(win.location.href))
  1160. {
  1161. // remove banner on the start page
  1162. scriptLander(() => {
  1163. let nt = new nullTools({log: false, trace: true});
  1164. let AwapsJsonAPI_Json_prototype = {};
  1165. let AwapsJsonAPI_Json = function(...args) {
  1166. console.log('>> new AwapsJsonAPI.Json(', ...args, ')');
  1167. };
  1168. [
  1169. 'setID', 'addImageContent',
  1170. 'sendCounts', 'expand', 'refreshAd'
  1171. ].forEach(name => AwapsJsonAPI_Json.prototype[name] = nt.proxy(nt.func(null, name)));
  1172. AwapsJsonAPI_Json.prototype.checkBannerVisibility = nt.proxy(nt.func(true, 'checkBannerVisibility'));
  1173. AwapsJsonAPI_Json.prototype.addIframeContent = nt.proxy(function(...args) {
  1174. try {
  1175. let frame = args[1][0].parentNode;
  1176. frame.parentNode.removeChild(frame);
  1177. console.log(`Removed banner placeholder.`);
  1178. } catch(ignore) {
  1179. console.log(`Can't locate frame object to remove.`);
  1180. }
  1181. });
  1182. AwapsJsonAPI_Json.prototype.getHTML = nt.proxy(nt.func('', 'getHTML'));
  1183. AwapsJsonAPI_Json.prototype = nt.proxy(AwapsJsonAPI_Json.prototype);
  1184. AwapsJsonAPI_Json = nt.proxy(AwapsJsonAPI_Json);
  1185. if ('AwapsJsonAPI' in win) {
  1186. console.log('Oops! AwapsJsonAPI already defined.');
  1187. let f = win.AwapsJsonAPI.Json;
  1188. win.AwapsJsonAPI.Json = AwapsJsonAPI_Json;
  1189. if (f && f.prototype)
  1190. f.prototype = AwapsJsonAPI_Json.prototype;
  1191. } else {
  1192. nt.define(win, 'AwapsJsonAPI', nt.proxy({
  1193. Json: AwapsJsonAPI_Json
  1194. }));
  1195. }
  1196.  
  1197. let home = win.home || {};
  1198. let parseExport = x => {
  1199. if (!x)
  1200. return x;
  1201. // remove banner placeholder
  1202. if (x.banner && x.banner.cls) {
  1203. let _parent = `.${x.banner.cls.banner__parent}`;
  1204. document.addEventListener('DOMContentLoaded', () => {
  1205. for (let banner of document.querySelectorAll(_parent)) {
  1206. _setAttribute.call(banner, 'style', 'display:none!important');
  1207. console.log('Hid banner placeholder.');
  1208. }
  1209. }, false);
  1210. }
  1211.  
  1212. // remove banner data and some other stuff
  1213. delete x.banner;
  1214. delete x.consistency;
  1215. delete x['i-bannerid'];
  1216. delete x['i-counter'];
  1217. delete x['ga-counter'];
  1218. delete x['promo-curtain'];
  1219.  
  1220. return x;
  1221. };
  1222. let home_export = parseExport(home.export);
  1223. Object.defineProperty(home, 'export', {
  1224. get: x => home_export,
  1225. set: x => {
  1226. home_export = parseExport(x);
  1227. }
  1228. });
  1229. nt.define(win, 'home', home);
  1230. }, nullTools, '_setAttribute = Element.prototype.setAttribute');
  1231.  
  1232. if ('attachShadow' in Element.prototype) {
  1233. let fakeRoot = () => ({
  1234. firstChild: null,
  1235. appendChild: ()=>null,
  1236. querySelector: ()=>null,
  1237. querySelectorAll: ()=>null
  1238. });
  1239. Element.prototype.createShadowRoot = fakeRoot;
  1240. let shadows = new WeakMap();
  1241. let _attachShadow = Object.getOwnPropertyDescriptor(Element.prototype, 'attachShadow');
  1242. let _call_attachShadow = _attachShadow.value;
  1243. _attachShadow.value = function() {
  1244. return shadows.set(this, fakeRoot()).get(this);
  1245. };
  1246. Object.defineProperty(Element.prototype, 'attachShadow', _attachShadow);
  1247. let _shadowRoot = Object.getOwnPropertyDescriptor(Element.prototype, 'shadowRoot');
  1248. _shadowRoot.set = () => null;
  1249. _shadowRoot.get = function() {
  1250. return shadows.has(this) ? shadows.get(this) : void 0;
  1251. };
  1252. Object.defineProperty(Element.prototype, 'shadowRoot', _shadowRoot);
  1253. }
  1254. // Partially based on https://greasyfork.org/en/scripts/22737-remove-yandex-redirect
  1255. let selectors = (
  1256. 'A[onmousedown*="/jsredir"],'+
  1257. 'A[data-vdir-href],'+
  1258. 'A[data-counter]'
  1259. );
  1260. let removeTrackingAttributes = function(link)
  1261. {
  1262. link.removeAttribute('onmousedown');
  1263. if (link.hasAttribute('data-vdir-href')) {
  1264. link.removeAttribute('data-vdir-href');
  1265. link.removeAttribute('data-orig-href');
  1266. }
  1267. if (link.hasAttribute('data-counter')) {
  1268. link.removeAttribute('data-counter');
  1269. link.removeAttribute('data-bem');
  1270. }
  1271. };
  1272. let removeTracking = function(scope)
  1273. {
  1274. for (let link of scope.querySelectorAll(selectors))
  1275. removeTrackingAttributes(link);
  1276. };
  1277. document.addEventListener('DOMContentLoaded', (e) => removeTracking(e.target));
  1278. (new MutationObserver(
  1279. function(ms)
  1280. {
  1281. let m, node;
  1282. for (m of ms) for (node of m.addedNodes) if (node.nodeType === _Node.ELEMENT_NODE)
  1283. if (node.tagName === 'A' && node.matches(selectors)) {
  1284. removeTrackingAttributes(node);
  1285. } else {
  1286. removeTracking(node);
  1287. }
  1288. }
  1289. )).observe(_de, { childList: true, subtree: true });
  1290. }
  1291.  
  1292. // https://greasyfork.org/en/scripts/21937-moonwalk-hdgo-kodik-fix v0.8 (adapted)
  1293. document.addEventListener(
  1294. 'DOMContentLoaded', function()
  1295. {//createPlayer();
  1296. function log (name) {
  1297. console.log(`Player FIX: Detected ${name} player in ${location.href}`);
  1298. }
  1299. if (win.adv_enabled !== undefined && win.condition_detected !== undefined)
  1300. {
  1301. log('Moonwalk');
  1302. if (win.adv_enabled)
  1303. win.adv_enabled = false;
  1304. win.condition_detected = false;
  1305. if (win.MXoverrollCallback)
  1306. document.addEventListener(
  1307. 'click', function catcher(e)
  1308. {
  1309. e.stopPropagation();
  1310. win.MXoverrollCallback.call(window);
  1311. document.removeEventListener('click', catcher, true);
  1312. }, true
  1313. );
  1314. }
  1315. else if (win.stat_url !== undefined && win.is_html5 !== undefined && win.is_wp8 !== undefined)
  1316. {
  1317. log('HDGo');
  1318. document.body.onclick = null;
  1319. let tmp = document.querySelector('#swtf');
  1320. if (tmp)
  1321. tmp.style.display = 'none';
  1322. if (win.banner_second !== undefined)
  1323. win.banner_second = 0;
  1324. if (win.$banner_ads !== undefined)
  1325. win.$banner_ads = false;
  1326. if (win.$new_ads !== undefined)
  1327. win.$new_ads = false;
  1328. if (win.createCookie !== undefined)
  1329. win.createCookie('popup', 'true', '999');
  1330. if (win.canRunAds !== undefined && win.canRunAds !== true)
  1331. win.canRunAds = true;
  1332. }
  1333. else if (win.MXoverrollCallback && win.iframeSearch !== undefined)
  1334. {
  1335. log('Kodik');
  1336. let tmp = document.querySelector('.play_button');
  1337. if (tmp)
  1338. tmp.onclick = win.MXoverrollCallback.bind(window);
  1339. win.IsAdBlock = false;
  1340. }
  1341. else if (win.getnextepisode && win.uppodEvent)
  1342. {
  1343. log('Share-Serials.net');
  1344. scriptLander(
  1345. function()
  1346. {
  1347. let _setInterval = win.setInterval,
  1348. _setTimeout = win.setTimeout;
  1349. win.setInterval = function(func)
  1350. {
  1351. if (func instanceof Function && func.toString().indexOf('_delay') > -1)
  1352. {
  1353. let intv = _setInterval.call(
  1354. this, function()
  1355. {
  1356. _setTimeout.call(
  1357. this, function(intv)
  1358. {
  1359. clearInterval(intv);
  1360. let timer = document.querySelector('#timer');
  1361. if (timer)
  1362. timer.click();
  1363. }, 100, intv);
  1364. func.call(this);
  1365. }, 5
  1366. );
  1367.  
  1368. return intv;
  1369. }
  1370. return _setInterval.apply(this, arguments);
  1371. };
  1372. win.setTimeout = function(func) {
  1373. if (func instanceof Function && func.toString().indexOf('adv_showed') > -1)
  1374. {
  1375. return _setTimeout.call(this, func, 0);
  1376. }
  1377. return _setTimeout.apply(this, arguments);
  1378. };
  1379. }
  1380. );
  1381. } else if ('ADC' in win)
  1382. {
  1383. log('vjs-creatives plugin in');
  1384. let replacer = (obj) => {
  1385. for (let name in obj)
  1386. if (obj[name] instanceof Function)
  1387. obj[name] = () => null;
  1388. };
  1389. replacer(win.ADC);
  1390. replacer(win.currentAdSlot);
  1391. }
  1392. UberVK: {
  1393. if (!inIFrame)
  1394. break UberVK;
  1395. let oddNames = 'HD' in win &&
  1396. !Object.getOwnPropertyNames(win).every(n => !n.startsWith('_0x'));
  1397. if (!oddNames)
  1398. break UberVK;
  1399. log('UberVK');
  1400. XMLHttpRequest.prototype.open = () => { throw 404; };
  1401. }
  1402. }, false
  1403. );
  1404.  
  1405. // piguiqproxy.com circumvention prevention
  1406. scriptLander(
  1407. () => {
  1408. let _open = XMLHttpRequest.prototype.open;
  1409. // blacklist of third-party domains requests to which are ignored
  1410. let blacklist = /[/.@](amgload\.net|dsn-fishki\.ru|piguiqproxy\.com|rcdn\.pro)[:/]/i;
  1411. // blacklist of domains where all third-party requests are ignored
  1412. let ondomains = /(^|[/.@])oane\.ws($|[:/])/i;
  1413. // highly suspicious URLs
  1414. let suspicious = /^https?:\/\/[a-z0-9]{6}\.ru\/([a-z0-9\/]{45,}|[a-z0-9]{8,}|ad\/banner\/.+)$/i;
  1415.  
  1416. XMLHttpRequest.prototype.open = function(method, url)
  1417. {
  1418. if (method === 'GET' &&
  1419. (blacklist.test(url) || suspicious.test(url) ||
  1420. ondomains.test(location.hostname) && !ondomains.test(url)))
  1421. {
  1422. this.send = () => null;
  1423. this.setRequestHeader = () => null;
  1424. console.log('Blocked request: ', url);
  1425. return;
  1426. }
  1427. return _open.apply(this, arguments);
  1428. };
  1429. }
  1430. );
  1431.  
  1432. // === Helper functions ===
  1433.  
  1434. // function to search and remove nodes by content
  1435. // selector - standard CSS selector to define set of nodes to check
  1436. // words - regular expression to check content of the suspicious nodes
  1437. // params - object with multiple extra parameters:
  1438. // .log - display log in the console
  1439. // .hide - set display to none instead of removing from the page
  1440. // .parent - parent node to remove if content is found in the child node
  1441. // .siblings - number of simling nodes to remove (excluding text nodes)
  1442. let scRemove = (node) => node.parentNode.removeChild(node);
  1443. let scHide = function(node)
  1444. {
  1445. let style = _getAttribute.call(node, 'style') || '',
  1446. hide = ';display:none!important;';
  1447. if (style.indexOf(hide) < 0)
  1448. _setAttribute.call(node, 'style', style + hide);
  1449. };
  1450.  
  1451. function scissors (selector, words, scope, params)
  1452. {
  1453. let logger = function() { return params.log ? console.log(...arguments) : null; };
  1454. if (!scope.contains(document.body))
  1455. logger('[s] scope', scope);
  1456. let remFunc = (params.hide ? scHide : scRemove),
  1457. iterFunc = (params.siblings > 0 ? 'nextElementSibling' : 'previousElementSibling'),
  1458. toRemove = [],
  1459. siblings;
  1460. for (let node of scope.querySelectorAll(selector))
  1461. {
  1462. // drill up to a parent node if specified, break if not found
  1463. if (params.parent)
  1464. {
  1465. let old = node;
  1466. node = node.closest(params.parent);
  1467. if (node === null || node.contains(scope))
  1468. {
  1469. logger('[s] went out of scope with', old);
  1470. continue;
  1471. }
  1472. }
  1473. logger('[s] processing', node);
  1474. if (toRemove.includes(node))
  1475. continue;
  1476. if (words.test(node.innerHTML))
  1477. {
  1478. // skip node if already marked for removal
  1479. logger('[s] marked for removal');
  1480. toRemove.push(node);
  1481. // add multiple nodes if defined more than one sibling
  1482. siblings = Math.abs(params.siblings) || 0;
  1483. while (siblings)
  1484. {
  1485. node = node[iterFunc];
  1486. if (!node) break; // can't go any further - exit
  1487. logger('[s] adding sibling node', node);
  1488. toRemove.push(node);
  1489. siblings -= 1;
  1490. }
  1491. }
  1492. }
  1493. let toSkip = [];
  1494. for (let node of toRemove)
  1495. if (!toRemove.every(other => other === node || !node.contains(other)))
  1496. toSkip.push(node);
  1497. if (toRemove.length)
  1498. logger(`[s] proceeding with ${params.hide?'hide':'removal'} of`, toRemove, `skip`, toSkip);
  1499. for (let node of toRemove) if (!toSkip.includes(node))
  1500. remFunc(node);
  1501. }
  1502.  
  1503. // function to perform multiple checks if ads inserted with a delay
  1504. // by default does 30 checks withing a 3 seconds unless nonstop mode specified
  1505. // also does 1 extra check when a page completely loads
  1506. // selector and words - passed dow to scissors
  1507. // params - object with multiple extra parameters:
  1508. // .log - display log in the console
  1509. // .root - selector to narrow down scope to scan;
  1510. // .observe - if true then check will be performed continuously;
  1511. // Other parameters passed down to scissors.
  1512. function gardener(selector, words, params)
  1513. {
  1514. let logger = function() { return params.log ? console.log(...arguments) : null; };
  1515. params = params || {};
  1516. logger(`[gardener] selector: '${selector}' detector: ${words} options: ${JSON.stringify(params)}`);
  1517. let scope;
  1518. let globalScope = [_de];
  1519. let domLoaded = false;
  1520. let getScope = root => root ? _de.querySelectorAll(root) : globalScope;
  1521. let onevent = e => {
  1522. logger(`[gardener] cleanup on ${Object.getPrototypeOf(e)} "${e.type}"`);
  1523. for (let node of scope)
  1524. scissors(selector, words, node, params);
  1525. };
  1526. let repeater = n => {
  1527. if (!domLoaded && n) {
  1528. setTimeout(repeater, 500, n - 1);
  1529. scope = getScope(params.root);
  1530. if (!scope) // exit if the root element is not present on the page
  1531. return 0;
  1532. onevent({type: 'Repeater'});
  1533. }
  1534. };
  1535. repeater(20);
  1536. document.addEventListener(
  1537. 'DOMContentLoaded', (e) => {
  1538. domLoaded = true;
  1539. // narrow down scope to a specific element
  1540. scope = getScope(params.root);
  1541. if (!scope) // exit if the root element is not present on the page
  1542. return 0;
  1543. logger('[g] scope', scope);
  1544. // add observe mode if required
  1545. if (params.observe)
  1546. {
  1547. let params = { childList:true, subtree: true };
  1548. let observer = new MutationObserver(
  1549. function(ms)
  1550. {
  1551. for (let m of ms)
  1552. if (m.addedNodes.length)
  1553. onevent(m);
  1554. }
  1555. );
  1556. for (let node of scope)
  1557. observer.observe(node, params);
  1558. logger('[g] observer enabled');
  1559. }
  1560. onevent(e);
  1561. }, false);
  1562. // wait for a full page load to do one extra cut
  1563. win.addEventListener('load', onevent, false);
  1564. }
  1565.  
  1566. // wrap popular methods to open a new tab to catch specific behaviours
  1567. function createWindowOpenWrapper(openFunc, onClickFunc)
  1568. {
  1569. let _createElement = _Document.prototype.createElement,
  1570. _appendChild = Element.prototype.appendChild,
  1571. fakeNative = (f) => (f.toString = () => `function ${f.name}() { [native code] }`);
  1572.  
  1573. let nt = new nullTools();
  1574. fakeNative(openFunc);
  1575.  
  1576. let parser = _createElement.call(document, 'a');
  1577. let openWhitelist = (url, parent) => {
  1578. parser.href = url;
  1579. return parser.hostname === 'www.imdb.com' || parser.hostname === 'www.kinopoisk.ru' ||
  1580. parent.hostname === 'radikal.ru' && url === void 0;
  1581. };
  1582.  
  1583. let redefineOpen = (root) => {
  1584. if ('open' in root) {
  1585. let _open = root.open.bind(root);
  1586. nt.define(root, 'open', (...args) => {
  1587. if (openWhitelist(args[0], location)) {
  1588. console.log('Whitelisted popup:', ...args);
  1589. return _open(...args);
  1590. }
  1591. return openFunc(...args);
  1592. });
  1593. }
  1594. };
  1595. redefineOpen(win);
  1596.  
  1597. function createElement(name) {
  1598. '[native code]';
  1599. // jshint validthis:true
  1600. let el = _createElement.apply(this, arguments);
  1601. // click-dispatch check for Google Chrome and similar browsers
  1602. if (el instanceof HTMLAnchorElement)
  1603. el.addEventListener('click', onClickFunc, false);
  1604. // redefine window.open in first-party frames
  1605. if (el instanceof HTMLIFrameElement || el instanceof HTMLObjectElement)
  1606. el.addEventListener('load', (e) => {
  1607. try {
  1608. redefineOpen(e.target.contentWindow);
  1609. } catch(ignore) {}
  1610. }, false);
  1611. return el;
  1612. }
  1613. fakeNative(createElement);
  1614.  
  1615. let redefineCreateElement = (obj) => {
  1616. for (let root of [obj.document, _Document.prototype]) if ('createElement' in root)
  1617. nt.define(root, 'createElement', createElement);
  1618. };
  1619. redefineCreateElement(win);
  1620.  
  1621. // wrap window.open in newly added first-party frames
  1622. Element.prototype.appendChild = function appendChild()
  1623. {
  1624. '[native code]';
  1625. let el = _appendChild.apply(this, arguments);
  1626. if (el instanceof HTMLIFrameElement) {
  1627. try {
  1628. redefineOpen(el.contentWindow);
  1629. redefineCreateElement(el.contentWindow);
  1630. } catch(ignore) {}
  1631. }
  1632. return el;
  1633. };
  1634. fakeNative(Element.prototype.appendChild);
  1635. }
  1636.  
  1637. // Function to catch and block various methods to open a new window with 3rd-party content.
  1638. // Some advertisement networks went way past simple window.open call to circumvent default popup protection.
  1639. // This funciton blocks window.open, ability to restore original window.open from an IFRAME object,
  1640. // ability to perform an untrusted (not initiated by user) click on a link, click on a link without a parent
  1641. // node or simply a link with piece of javascript code in the HREF attribute.
  1642. function preventPopups()
  1643. {
  1644. // call sandbox-me if in iframe and not whitelisted
  1645. if (inIFrame) {
  1646. win.top.postMessage({ name: 'sandbox-me', href: win.location.href }, '*');
  1647. return;
  1648. }
  1649.  
  1650. scriptLander(() => {
  1651. let open = (...args) => {
  1652. '[native code]';
  1653. console.warn('Site attempted to open a new window', args);
  1654. if (new RegExp(`^https?://${location.hostname}/`).test(args[0])) // skip extra click in case of blocked popunder
  1655. location.assign(args[0]);
  1656. return {
  1657. document: {
  1658. write: () => {},
  1659. writeln: () => {}
  1660. },
  1661. location: {}
  1662. };
  1663. };
  1664.  
  1665. let clickHandler = (e) => {
  1666. let link = e.target;
  1667. if (!link.parentNode || !e.isTrusted ||
  1668. (link.href && link.href.trim().toLowerCase().indexOf('javascript') === 0))
  1669. {
  1670. e.preventDefault();
  1671. console.warn('Blocked suspicious click event', e, 'on', e.target);
  1672. }
  1673. };
  1674.  
  1675. createWindowOpenWrapper(open, clickHandler);
  1676.  
  1677. console.log('Popup prevention enabled.');
  1678. }, nullTools, createWindowOpenWrapper);
  1679. }
  1680.  
  1681. // Helper function to close background tab if site opens itself in a new tab and then
  1682. // loads a 3rd-party page in the background one (thus performing background redirect).
  1683. function preventPopunders()
  1684. {
  1685. // create "close_me" event to call high-level window.close()
  1686. let eventName = `close_me_${Math.random().toString(36).substr(2)}`;
  1687. let callClose = () => (console.log('close call'), window.close());
  1688. window.addEventListener(eventName, callClose, true);
  1689.  
  1690. scriptLander(() => {
  1691. // get host of a provided URL with help of an anchor object
  1692. // unfortunately new URL(url, window.location) generates wrong URL in some cases
  1693. let parseURL = document.createElement('A');
  1694. let getHost = (url) => (parseURL.href = url, parseURL.hostname);
  1695. // site went to a new tab and attempts to unload
  1696. // call for high-level close through event
  1697. let closeWindow = () => window.dispatchEvent(new CustomEvent(eventName, {}));
  1698. // check is URL local or goes to different site
  1699. let isLocal = (url) => {
  1700. if (url === location.pathname || url === location.href)
  1701. return true; // URL points to current pathname or full address
  1702. let host = getHost(url);
  1703. let site = location.hostname;
  1704. return host !== '' && // URLs with unusual protocol may have empty 'host'
  1705. (site === host || site.endsWith(`.${host}`) || host.endsWith(`.${site}`));
  1706. };
  1707.  
  1708. let _open = window.open.bind(window);
  1709. let open = (...args) => {
  1710. '[native code]';
  1711. let url = args[0];
  1712. if (url && isLocal(url))
  1713. window.addEventListener('beforeunload', closeWindow, true);
  1714. // jshint validthis:true
  1715. return _open(...args);
  1716. };
  1717.  
  1718. let clickHandler = (e) => {
  1719. if (!e.target.parentNode || !e.isTrusted)
  1720. window.addEventListener('beforeunload', closeWindow, true);
  1721. };
  1722.  
  1723. createWindowOpenWrapper(open, clickHandler);
  1724.  
  1725. console.log("Background redirect prevention enabled.");
  1726. }, `let eventName="${eventName}"`, nullTools, createWindowOpenWrapper);
  1727. }
  1728.  
  1729. // Mix between check for popups and popunders
  1730. // Significantly more agressive than both and can't be used as universal solution
  1731. function preventPopMix()
  1732. {
  1733. if (inIFrame)
  1734. {
  1735. win.top.postMessage({ name: 'sandbox-me', href: win.location.href }, '*');
  1736. return;
  1737. }
  1738.  
  1739. // create "close_me" event to call high-level window.close()
  1740. let eventName = `close_me_${Math.random().toString(36).substr(2)}`;
  1741. let callClose = () => (console.log('close call'), window.close());
  1742. window.addEventListener(eventName, callClose, true);
  1743.  
  1744. scriptLander(() => {
  1745. let _open = window.open,
  1746. parseURL = document.createElement('A');
  1747. // get host of a provided URL with help of an anchor object
  1748. // unfortunately new URL(url, window.location) generates wrong URL in some cases
  1749. let getHost = (url) => (parseURL.href = url, parseURL.host);
  1750. // site went to a new tab and attempts to unload
  1751. // call for high-level close through event
  1752. let closeWindow = () => (_open(window.location,'_self'), window.dispatchEvent(new CustomEvent(eventName, {})));
  1753. // check is URL local or goes to different site
  1754. function isLocal(url)
  1755. {
  1756. let loc = window.location;
  1757. if (url === loc.pathname || url === loc.href)
  1758. return true; // URL points to current pathname or full address
  1759. let host = getHost(url),
  1760. site = loc.host;
  1761. if (host === '')
  1762. return false; // URLs with unusual protocol may have empty 'host'
  1763. if (host.length > site.length)
  1764. [site, host] = [host, site];
  1765. return site.includes(host, site.length - host.length);
  1766. }
  1767.  
  1768. // add check for redirect for 5 seconds, then disable it
  1769. function checkRedirect()
  1770. {
  1771. window.addEventListener('beforeunload', closeWindow, true);
  1772. setTimeout(closeWindow=>window.removeEventListener('beforeunload', closeWindow, true), 5000, closeWindow);
  1773. }
  1774.  
  1775. function open(url, name)
  1776. {
  1777. '[native code]';
  1778. if (url && isLocal(url) && (!name || name === '_blank'))
  1779. {
  1780. console.warn('Suspicious local new window', arguments);
  1781. checkRedirect();
  1782. // jshint validthis:true
  1783. return _open.apply(this, arguments);
  1784. }
  1785. console.warn('Blocked attempt to open a new window', arguments);
  1786. return {
  1787. document: {
  1788. write: () => {},
  1789. writeln: () => {}
  1790. }
  1791. };
  1792. }
  1793.  
  1794. function clickHandler(e)
  1795. {
  1796. let link = e.target,
  1797. url = link.href||'';
  1798. if (e.targetParentNode && e.isTrusted || link.target !== '_blank')
  1799. {
  1800. console.log('Link', link, 'were created dinamically, but looks fine.');
  1801. return true;
  1802. }
  1803. if (isLocal(url) && link.target === '_blank')
  1804. {
  1805. console.log('Suspicious local link', link);
  1806. checkRedirect();
  1807. return;
  1808. }
  1809. console.log('Blocked suspicious click on a link', link);
  1810. e.stopPropagation();
  1811. e.preventDefault();
  1812. }
  1813.  
  1814. createWindowOpenWrapper(open, clickHandler);
  1815.  
  1816. console.log("Mixed popups prevention enabled.");
  1817. }, `let eventName="${eventName}"`, createWindowOpenWrapper);
  1818. }
  1819. // External listener for case when site known to open popups were loaded in iframe
  1820. // It will sandbox any iframe which will send message 'forbid.popups' (preventPopups sends it)
  1821. // Some sites replace frame's window.location with data-url to run in clean context
  1822. if (!inIFrame)
  1823. {
  1824. window.addEventListener(
  1825. 'message', function(e)
  1826. {
  1827. if (!e.data || e.data.name !== 'sandbox-me' || !e.data.href)
  1828. return;
  1829. let src = e.data.href;
  1830. for (let frame of document.querySelectorAll('iframe'))
  1831. if (frame.contentWindow === e.source)
  1832. {
  1833. if (frame.hasAttribute('sandbox'))
  1834. {
  1835. if (!frame.sandbox.contains('allow-popups'))
  1836. return; // exit frame since it's already sandboxed and popups are blocked
  1837. // remove allow-popups if frame already sandboxed
  1838. frame.sandbox.remove('allow-popups');
  1839. } else {
  1840. // set sandbox mode for troublesome frame and allow scripts, forms and a few other actions
  1841. // technically allowing both scripts and same-origin allows removal of the sandbox attribute,
  1842. // but to apply content must be reloaded and this script will re-apply it in the result
  1843. frame.setAttribute('sandbox','allow-forms allow-scripts allow-presentation allow-top-navigation allow-same-origin');
  1844. }
  1845. console.log('Disallowed popups from iframe', frame);
  1846.  
  1847. // reload frame content to apply restrictions
  1848. if (!src) {
  1849. src = frame.src;
  1850. console.log('Unable to get current iframe location, reloading from src', src);
  1851. } else
  1852. console.log('Reloading iframe with URL', src);
  1853. frame.src = 'about:blank';
  1854. frame.src = src;
  1855. }
  1856. }, false
  1857. );
  1858. }
  1859.  
  1860. function selectiveEval() {
  1861. scriptLander(() => {
  1862. let nt = new nullTools();
  1863. let _eval = win.eval.bind(window);
  1864. nt.define(win, 'eval', function(...args) {
  1865. if (/_0x|location\s*?=|location.href\s*?=|location.assign\(|open\(/i.test(args[0])) {
  1866. console.log(`Skipped eval of ${args[0].slice(0, 512)}\u2026`);
  1867. return null;
  1868. }
  1869. return _eval(...args);
  1870. });
  1871. }, nullTools);
  1872. }
  1873.  
  1874. // === Scripts for specific domains ===
  1875.  
  1876. let scripts = {};
  1877. // prevent popups and redirects block
  1878. // Popups
  1879. scripts.preventPopups = {
  1880. other: [
  1881. 'biqle.ru',
  1882. 'chaturbate.com',
  1883. 'dfiles.ru',
  1884. 'hentaiz.org',
  1885. 'mirrorcreator.com',
  1886. 'online-multy.ru',
  1887. 'radikal.ru', 'rumedia.ws',
  1888. 'seedoff.cc', 'seedoff.tv',
  1889. 'thepiratebay.org', 'torseed.net',
  1890. 'unionpeer.com',
  1891. 'zippyshare.com'
  1892. ],
  1893. now: preventPopups
  1894. };
  1895. // Popunders (background redirect)
  1896. scripts.preventPopunders = {
  1897. other: [
  1898. 'lostfilm-online.ru',
  1899. 'mediafire.com', 'megapeer.org', 'megapeer.ru',
  1900. 'perfectgirls.net'
  1901. ],
  1902. now: preventPopunders
  1903. };
  1904. // PopMix (both types of popups encountered on site)
  1905. scripts['openload.co'] = {
  1906. other: ['oload.tv', 'oload.info'],
  1907. now: () => {
  1908. let nt = new nullTools();
  1909. nt.define(win, 'CNight', win.CoinHive);
  1910. if (location.pathname.startsWith('/embed/'))
  1911. {
  1912. nt.define(win, 'BetterJsPop', {
  1913. add: ((a, b) => console.warn('BetterJsPop.add', a, b)),
  1914. config: ((o) => console.warn('BetterJsPop.config', o)),
  1915. Browser: { isChrome: true }
  1916. });
  1917. nt.define(win, 'isSandboxed', nt.func(null));
  1918. nt.define(win, 'adblock', false);
  1919. nt.define(win, 'adblock2', false);
  1920. } else
  1921. preventPopMix();
  1922. }
  1923. };
  1924. scripts['turbobit.net'] = preventPopMix;
  1925.  
  1926. // workaround for moradu.com/apu.php load error handler script, not sure which ad network is this
  1927. scripts['tapochek.net'] = () => {
  1928. let _appendChild = Object.getOwnPropertyDescriptor(_Node.prototype, 'appendChild');
  1929. let _appendChild_value = _appendChild.value;
  1930. _appendChild.value = function appendChild(node) {
  1931. if (this === win.document.body)
  1932. if ((node instanceof HTMLScriptElement || node instanceof HTMLStyleElement) &&
  1933. /^https?:\/\/[0-9a-f]{15}\.com\/\d+(\/|\.css)$/.test(node.src) ||
  1934. node instanceof HTMLDivElement && node.style.zIndex > 900000 &&
  1935. node.style.backgroundImage.includes('R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7'))
  1936. throw '...eenope!';
  1937. return _appendChild_value.apply(this, arguments);
  1938. };
  1939. Object.defineProperty(_Node.prototype, 'appendChild', _appendChild);
  1940.  
  1941. preventPopups();
  1942. };
  1943.  
  1944. scripts['rustorka.com'] = {
  1945. other: ['rustorka.lib'],
  1946. now: () => scriptLander(() => {
  1947. let nt = new nullTools({trace: true});
  1948. nt.define(win, 'syka', false);
  1949. nt.define(win, '_692293176244', location.href);
  1950. [
  1951. 'MTLuxup', 'MTAdSniper', 'MTutarg', 'MTUAatar', 'MTcityAds', 'MTmxMark',
  1952. 'MTmxMark2', 'MTmdnt', 'MTrfDumedia', 'MXsmTDS', 'MTritorno', 'MTadvice',
  1953. 'cyka', 'MTAdTraff', 'MTExebid'
  1954. ].forEach(p => nt.define(win, p, nt.func(null, p)));
  1955. let _eval_def = Object.getOwnPropertyDescriptor(win, 'eval');
  1956. if (!_eval_def)
  1957. return;
  1958. let _eval_val = _eval_def.value;
  1959. _eval_def.value = (...args) => {
  1960. if (args[0] && args[0].includes('antiadblock'))
  1961. return console.log('Anti-AdBlock script may run another day, but not today.');
  1962. return _eval_val.apply(this, args);
  1963. };
  1964. Object.defineProperty(win, 'eval', _eval_def);
  1965. win.open = (...args) => {
  1966. console.warn(`Site attempted to open "${args[0]}" in a new window.`);
  1967. location.replace(location.href);
  1968. return null;
  1969. };
  1970. window.addEventListener('DOMContentLoaded', () => {
  1971. let link = void 0;
  1972. document.body.addEventListener('mousedown', e => {
  1973. link = e.target.closest('a, select, #fancybox-title-wrap');
  1974. }, false);
  1975. let _open = window.open.bind(window);
  1976. let _getAttribute = Element.prototype.getAttribute;
  1977. win.open = (...args) => {
  1978. let url = args[0];
  1979. let allow = false;
  1980. if (link instanceof HTMLAnchorElement) {
  1981. // third-party post links
  1982. let href = _getAttribute.call(link, 'href');
  1983. if (link.classList.contains('postLink') &&
  1984. !link.matches(`a[href*="${location.hostname}"]`) &&
  1985. (href === url || link.href === url)) {
  1986. return _open(...args);
  1987. }
  1988. // onclick # links
  1989. if (href === '#' && /window\.open/.test(_getAttribute.call(link, 'onclick'))) {
  1990. return _open(...args);
  1991. }
  1992. // force local links to load in the current window
  1993. if (href[0] === '/' || href.startsWith('./') || href.includes(`//${location.hostname}/`))
  1994. location.assign(href);
  1995. }
  1996. // list of image hostings under upload picture button (new comment)
  1997. if (link instanceof HTMLSelectElement &&
  1998. !url.includes(location.hostname) &&
  1999. link.value === url) {
  2000. return _open(...args);
  2001. }
  2002. // open screenshot in a new window
  2003. if (link instanceof HTMLSpanElement &&
  2004. link.id === 'fancybox-title-wrap') {
  2005. return _open(...args);
  2006. }
  2007. // looks like tabunder
  2008. if (link === null && url === location.href)
  2009. location.replace(url); // reload current page
  2010. // other cases
  2011. console.warn(`Site attempted to open "${url}" in a new window. Source: `, link);
  2012. return {};
  2013. };
  2014. }, true);
  2015. }, nullTools)
  2016. };
  2017.  
  2018. // other
  2019. scripts['1tv.ru'] = {
  2020. other: ['yastatic.net'],
  2021. now: () => scriptLander(() => {
  2022. let nt = new nullTools();
  2023. nt.define(win, 'EUMPAntiblockConfig', nt.proxy({url: '//www.1tv.ru/favicon.ico'}));
  2024. let _EUMPConfig = { plugins: [] };
  2025. let disablePlugins = {
  2026. 'antiblock': false,
  2027. 'stat1tv': false
  2028. };
  2029. Object.defineProperty(win, 'EUMPConfig', {
  2030. enumerable: true,
  2031. get: x => _EUMPConfig,
  2032. set: x => {
  2033. let plugins = x.plugins;
  2034. if (plugins) {
  2035. let id;
  2036. for (let plugin in disablePlugins) {
  2037. id = plugins.indexOf(plugin);
  2038. if (id > -1) {
  2039. plugins.splice(id, 1);
  2040. disablePlugins[plugin] = true;
  2041. }
  2042. }
  2043. console.warn(`Player plugins: active [${plugins}], disabled [${Object.keys(disablePlugins).filter(x => disablePlugins[x])}]`);
  2044. }
  2045. _EUMPConfig = x;
  2046. }
  2047. });
  2048. }, nullTools)
  2049. }
  2050.  
  2051. scripts['2picsun.ru'] = {
  2052. other: [
  2053. 'pics2sun.ru', '3pics-img.ru'
  2054. ],
  2055. now: () => {
  2056. Object.defineProperty(navigator, 'userAgent', {value: 'googlebot'});
  2057. }
  2058. };
  2059.  
  2060. scripts['4pda.ru'] = {
  2061. now: () => {
  2062. // https://greasyfork.org/en/scripts/14470-4pda-unbrender
  2063. let hStyle,
  2064. isForum = document.location.href.search('/forum/') !== -1,
  2065. remove = (node) => (node ? node.parentNode.removeChild(node) : null),
  2066. afterClean = () => remove(hStyle);
  2067.  
  2068. function beforeClean()
  2069. {
  2070. // attach styles before document displayed
  2071. hStyle = createStyle([
  2072. 'html { overflow-y: scroll }',
  2073. 'article + aside * { display: none !important }',
  2074. `section[id] {${(
  2075. 'position: absolute;'+
  2076. 'width: 100%'
  2077. )}}`,
  2078. `#header + div:after {${(
  2079. 'content: "";'+
  2080. 'position: fixed;'+
  2081. 'top: 0;'+
  2082. 'left: 0;'+
  2083. 'width: 100%;'+
  2084. 'height: 100%;'+
  2085. 'background-color: #E6E7E9'
  2086. )}}`,
  2087. // http://codepen.io/Beaugust/pen/DByiE
  2088. '@keyframes spin { 100% { transform: rotate(360deg) } }',
  2089. `article + aside:after {${(
  2090. 'content: "";'+
  2091. 'position: absolute;'+
  2092. 'width: 150px;'+
  2093. 'height: 150px;'+
  2094. 'top: 150px;'+
  2095. 'left: 50%;'+
  2096. 'margin-top: -75px;'+
  2097. 'margin-left: -75px;'+
  2098. 'box-sizing: border-box;'+
  2099. 'border-radius: 100%;'+
  2100. 'border: 10px solid rgba(0, 0, 0, 0.2);'+
  2101. 'border-top-color: rgba(0, 0, 0, 0.6);'+
  2102. 'animation: spin 2s infinite linear'
  2103. )}}`
  2104. ], {id:'ubrHider'}, true);
  2105.  
  2106. // display content of a page if time to load a page is more than 2 seconds to avoid
  2107. // blocking access to a page if it is loading for too long or stuck in a loading state
  2108. setTimeout(2000, afterClean);
  2109. }
  2110.  
  2111. createStyle([
  2112. '#nav .use-ad { display: block !important }',
  2113. 'article:not(.post) + article:not(#id),'+
  2114. 'html:not(#id)>body:not(#id) a[target="_blank"] img[height="90"] { display: none !important }'
  2115. ]);
  2116.  
  2117. if (!isForum)
  2118. beforeClean();
  2119.  
  2120. // save links to non-overridden functions to use later
  2121. let protectedElems;
  2122. // protect/hide changed attributes in case site attempt to restore them
  2123. function styleProtector(eventMode)
  2124. {
  2125. let _toLowerCase = String.prototype.toLowerCase,
  2126. isStyleText = (t) => (_toLowerCase.call(t) === 'style'),
  2127. protectedElems = new WeakMap();
  2128. function protoOverride(element, functionName, isStyleCheck, returnIfProtected)
  2129. {
  2130. let originalFunction = element.prototype[functionName];
  2131. element.prototype[functionName] = function wrapper()
  2132. {
  2133. if (protectedElems.has(this) && isStyleCheck(arguments[0]))
  2134. return returnIfProtected(this, arguments);
  2135. return originalFunction.apply(this, arguments);
  2136. };
  2137. }
  2138. protoOverride(Element, 'removeAttribute', isStyleText, () => undefined);
  2139. protoOverride(Element, 'hasAttribute', isStyleText, (_this) => protectedElems.get(_this) !== null);
  2140. protoOverride(Element, 'setAttribute', isStyleText, (_this, args) => protectedElems.set(_this, args[1]));
  2141. protoOverride(Element, 'getAttribute', isStyleText, (_this) => protectedElems.get(_this));
  2142. if (!eventMode)
  2143. return protectedElems;
  2144. else
  2145. {
  2146. let e = document.createEvent('Event');
  2147. e.initEvent('protoOverride', false, false);
  2148. window.protectedElems = protectedElems;
  2149. window.dispatchEvent(e);
  2150. }
  2151. }
  2152. if (!isFirefox)
  2153. protectedElems = styleProtector(false);
  2154. else
  2155. {
  2156. let script = document.createElement('script');
  2157. script.textContent = `(${styleProtector.toString()})(true);`;
  2158. window.addEventListener(
  2159. 'protoOverride', function protoOverrideCallback(e)
  2160. {
  2161. if (win.protectedElems) {
  2162. protectedElems = win.protectedElems;
  2163. delete win.protectedElems;
  2164. }
  2165. document.removeEventListener('protoOverride', protoOverrideCallback, true);
  2166. }, true
  2167. );
  2168. _appendChild(script);
  2169. _removeChild(script);
  2170. }
  2171.  
  2172. // clean a page
  2173. window.addEventListener(
  2174. 'DOMContentLoaded', function()
  2175. {
  2176. let width = () => window.innerWidth || _de.clientWidth || document.body.clientWidth || 0;
  2177. let height = () => window.innerHeight || _de.clientHeight || document.body.clientHeight || 0;
  2178.  
  2179. if (isForum)
  2180. {
  2181. let si = document.querySelector('#logostrip');
  2182. if (si)
  2183. remove(si.parentNode.nextSibling);
  2184. }
  2185.  
  2186. // clear background in the download frame
  2187. if (location.pathname.startsWith('/forum/dl/')) {
  2188. let setBackground = node => _setAttribute.call(
  2189. node,
  2190. 'style', (_getAttribute.call(node, 'style') || '') +
  2191. ';background-color:#4ebaf6!important'
  2192. );
  2193. setBackground(document.body);
  2194. for (let itm of document.querySelectorAll('body > div'))
  2195. if (!itm.querySelector('.dw-fdwlink, .content') && !itm.classList.contains('footer')) {
  2196. remove(itm);
  2197. } else {
  2198. setBackground(itm);
  2199. }
  2200. }
  2201.  
  2202. if (isForum) // Do not continue if it's a forum
  2203. return;
  2204.  
  2205. {
  2206. let si = document.querySelector('#header');
  2207. if (si)
  2208. {
  2209. let rem = si.previousSibling;
  2210. while (rem)
  2211. {
  2212. si = rem.previousSibling;
  2213. remove(rem);
  2214. rem = si;
  2215. }
  2216. }
  2217. }
  2218.  
  2219. for (let itm of document.querySelectorAll('#nav li[class]'))
  2220. if (itm && itm.querySelector('a[href^="/tag/"]'))
  2221. remove(itm);
  2222.  
  2223. let style, result,
  2224. fakeStyles = new WeakMap(),
  2225. styleProxy = {
  2226. get: function(target, prop)
  2227. {
  2228. let fakeStyle = fakeStyles.get(target);
  2229. return ((prop in fakeStyle) ? fakeStyle : target)[prop];
  2230. },
  2231. set: function(target, prop, value)
  2232. {
  2233. let fakeStyle = fakeStyles.get(target);
  2234. ((prop in fakeStyle) ? fakeStyle : target)[prop] = value;
  2235. return true;
  2236. }
  2237. };
  2238. for (let itm of document.querySelectorAll('DIV, A'))
  2239. {
  2240. if (itm.tagName ==='DIV' &&
  2241. itm.offsetWidth > 0.95 * width() &&
  2242. itm.offsetHeight > 0.85 * height())
  2243. {
  2244. style = window.getComputedStyle(itm, null);
  2245. result = [];
  2246.  
  2247. if (style.backgroundImage !== 'none')
  2248. result.push('background-image:none!important');
  2249.  
  2250. if (style.backgroundColor !== 'transparent' &&
  2251. style.backgroundColor !== 'rgba(0, 0, 0, 0)')
  2252. result.push('background-color:transparent!important');
  2253.  
  2254. if (result.length)
  2255. {
  2256. if (itm.getAttribute('style'))
  2257. result.unshift(itm.getAttribute('style'));
  2258.  
  2259. fakeStyles.set(itm.style, {
  2260. 'backgroundImage': itm.style.backgroundImage,
  2261. 'backgroundColor': itm.style.backgroundColor
  2262. });
  2263.  
  2264. try {
  2265. Object.defineProperty(itm, 'style', {
  2266. value: new Proxy(itm.style, styleProxy),
  2267. enumerable: true
  2268. });
  2269. } catch (e) {
  2270. console.log('Unable to protect style property.', e);
  2271. }
  2272.  
  2273. if (protectedElems)
  2274. protectedElems.set(itm, _getAttribute.call(itm, 'style'));
  2275.  
  2276. _setAttribute.call(itm, 'style', result.join(';'));
  2277. }
  2278. }
  2279. if (itm.tagName ==='A' &&
  2280. (itm.offsetWidth > 0.95 * width() ||
  2281. itm.offsetHeight > 0.85 * height()))
  2282. {
  2283. if (protectedElems)
  2284. protectedElems.set(itm, _getAttribute.call(itm, 'style'));
  2285.  
  2286. _setAttribute.call(itm, 'style', 'display:none!important');
  2287. }
  2288. }
  2289.  
  2290. for (let itm of document.querySelectorAll('ASIDE>DIV'))
  2291. if ( ((itm.querySelector('script, iframe, a[href*="/ad/www/"]') ||
  2292. itm.querySelector('img[src$=".gif"]:not([height="0"]), img[height="400"]')) &&
  2293. !itm.classList.contains('post') ) || !itm.childNodes.length )
  2294. remove(itm);
  2295.  
  2296. document.body.setAttribute('style', (document.body.getAttribute('style')||'')+';background-color:#E6E7E9!important');
  2297.  
  2298. // display content of the page
  2299. afterClean();
  2300. }
  2301. );
  2302. }
  2303. };
  2304.  
  2305. scripts['adhands.ru'] = () => scriptLander(() => {
  2306. let nt = new nullTools();
  2307. try {
  2308. let _adv;
  2309. Object.defineProperty(win, 'adv', {
  2310. get: () => _adv,
  2311. set: (v) => {
  2312. console.log('Blocked advert on adhands.ru.');
  2313. nt.define(v, 'advert', '');
  2314. _adv = v;
  2315. }
  2316. });
  2317. } catch (ignore) {
  2318. if (!win.adv)
  2319. console.log('Unable to locate advert on adhands.ru.');
  2320. else {
  2321. console.log('Blocked advert on adhands.ru.');
  2322. nt.define(win.adv, 'advert', '');
  2323. }
  2324. }
  2325. }, nullTools);
  2326.  
  2327. scripts['all-episodes.tv'] = () => {
  2328. let nt = new nullTools();
  2329. nt.define(win, 'perX1', 2);
  2330. createStyle('#advtss, #ad3, a[href*="/ad.admitad.com/"] { display:none!important }');
  2331. };
  2332.  
  2333. scripts['allhentai.ru'] = () => {
  2334. selectiveEval();
  2335. preventPopups();
  2336. scriptLander(() => {
  2337. let _onerror = Object.getOwnPropertyDescriptor(HTMLElement.prototype, 'onerror');
  2338. if (!_onerror)
  2339. return;
  2340. _onerror.set = (...args) => console.log(args[0].toString());
  2341. Object.defineProperty(HTMLElement.prototype, 'onerror', _onerror);
  2342. });
  2343. };
  2344.  
  2345. scripts['allmovie.pro'] = {
  2346. other: ['rufilmtv.org'],
  2347. dom: function()
  2348. {
  2349. // pretend to be Android to make site use different played for ads
  2350. if (isSafari)
  2351. return;
  2352. Object.defineProperty(navigator, 'userAgent', {
  2353. 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'; },
  2354. enumerable: true
  2355. });
  2356. }
  2357. };
  2358.  
  2359. scripts['anidub-online.ru'] = {
  2360. other: ['online.anidub.com'],
  2361. dom: function()
  2362. {
  2363. if (win.ogonekstart1)
  2364. win.ogonekstart1 = () => console.log("Fire in the hole!");
  2365. },
  2366. now: () => createStyle([
  2367. '.background {background: none!important;}',
  2368. '.background > script + div,'+
  2369. '.background > script ~ div:not([id]):not([class]) + div[id][class]'+
  2370. '{display:none!important}'
  2371. ])
  2372. };
  2373.  
  2374. scripts['drive2.ru'] = () => gardener('.c-block:not([data-metrika="recomm"]),.o-grid__item', />Реклама<\//i);
  2375.  
  2376. scripts['fishki.net'] = () => {
  2377. scriptLander(() => {
  2378. let nt = new nullTools();
  2379. let fishki = {};
  2380. nt.define(fishki, 'adv', nt.proxy({
  2381. afterAdblockCheck: nt.func(null),
  2382. refreshFloat: nt.func(null)
  2383. }));
  2384. nt.define(fishki, 'is_adblock', false);
  2385. nt.define(win, 'fishki', fishki);
  2386. }, nullTools);
  2387. gardener('.drag_list > .drag_element, .list-view > .paddingtop15, .post-wrap', /543769|Новости\sпартнеров|Полезная\sреклама/);
  2388. };
  2389.  
  2390. scripts['gidonline.club'] = () => createStyle('.tray > div[style] {display: none!important}');
  2391.  
  2392. scripts['hdgo.cc'] = {
  2393. other: ['46.30.43.38', 'couber.be'],
  2394. now: () => (new MutationObserver(
  2395. (ms) => {
  2396. let m, node;
  2397. for (m of ms) for (node of m.addedNodes)
  2398. if (node.tagName instanceof HTMLScriptElement && _getAttribute.call(node, 'onerror') !== null)
  2399. node.removeAttribute('onerror');
  2400. }
  2401. )).observe(document.documentElement, { childList:true, subtree: true })
  2402. };
  2403.  
  2404. scripts['gismeteo.ru'] = {
  2405. other: ['gismeteo.ua'],
  2406. now: () => gardener('div > script', /AdvManager/i, { observe: true, parent: 'div' })
  2407. };
  2408.  
  2409. scripts['hdrezka.ag'] = () => {
  2410. Object.defineProperty(win, 'ab', { value: false, enumerable: true });
  2411. gardener('div[id][onclick][onmouseup][onmousedown]', /onmouseout/i);
  2412. };
  2413.  
  2414. scripts['hideip.me'] = {
  2415. now: () => scriptLander(() => {
  2416. let _innerHTML = Object.getOwnPropertyDescriptor(Element.prototype, 'innerHTML');
  2417. let _set_innerHTML = _innerHTML.set;
  2418. let _innerText = Object.getOwnPropertyDescriptor(HTMLElement.prototype, 'innerText');
  2419. let _get_innerText = _innerText.get;
  2420. let div = document.createElement('div');
  2421. _innerHTML.set = function(...args) {
  2422. _set_innerHTML.call(div, args[0].replace('i','a'));
  2423. if (args[0] && /[рp][еe]кл/.test(_get_innerText.call(div))||
  2424. /(\d\d\d?\.){3}\d\d\d?\:\d/.test(_get_innerText.call(this)) ) {
  2425. console.log('Anti-Adblock killed.');
  2426. return true;
  2427. }
  2428. _set_innerHTML.apply(this, args);
  2429. };
  2430. Object.defineProperty(Element.prototype, 'innerHTML', _innerHTML);
  2431. Object.defineProperty(win, 'adblock', {
  2432. get: x => false,
  2433. set: x => null,
  2434. enumerable: true
  2435. });
  2436. let _$ = {};
  2437. let _$_map = new WeakMap();
  2438. let _gOPD = Object.getOwnPropertyDescriptor(Object, 'getOwnPropertyDescriptor');
  2439. let _val_gOPD = _gOPD.value;
  2440. _gOPD.value = function(...args) {
  2441. let _res = _val_gOPD.apply(this, args);
  2442. if (args[0] instanceof Window && (args[1] === '$' || args[1] === 'jQuery')) {
  2443. delete _res.get;
  2444. delete _res.set;
  2445. _res.value = win[args[1]];
  2446. }
  2447. return _res;
  2448. };
  2449. Object.defineProperty(Object, 'getOwnPropertyDescriptor', _gOPD);
  2450. let getJQWrap = (n) => {
  2451. let name = n;
  2452. return {
  2453. enumerable: true,
  2454. get: x => _$[name],
  2455. set: x => {
  2456. if (_$_map.has(x)) {
  2457. _$[name] = _$_map.get(x);
  2458. return true;
  2459. }
  2460. if (x === _$.$ || x === _$.jQuery) {
  2461. _$[name] = x;
  2462. return true;
  2463. }
  2464. _$[name] = new Proxy(x, {
  2465. apply: (t, o, args) => {
  2466. let _res = t.apply(o, args);
  2467. if (_$_map.has(_res.is)) {
  2468. _res.is = _$_map.get(_res.is);
  2469. } else {
  2470. let _is = _res.is;
  2471. _res.is = function(...args) {
  2472. if (args[0] === ':hidden')
  2473. return false;
  2474. return _is.apply(this, args);
  2475. };
  2476. _$_map.set(_is, _res.is);
  2477. }
  2478. return _res;
  2479. }
  2480. });
  2481. _$_map.set(x, _$[name]);
  2482. return true;
  2483. }
  2484. };
  2485. };
  2486. Object.defineProperty(win, '$', getJQWrap('$'));
  2487. Object.defineProperty(win, 'jQuery', getJQWrap('jQuery'));
  2488. let _dP = Object.defineProperty;
  2489. Object.defineProperty = function(...args) {
  2490. if (args[0] instanceof Window && (args[1] === '$' || args[1] === 'jQuery'))
  2491. return void 0;
  2492. return _dP.apply(this, args);
  2493. };
  2494. })
  2495. };
  2496.  
  2497. scripts['igra-prestoloff.cx'] = () => scriptLander(() => {
  2498. let nt = new nullTools();
  2499. /*jslint evil: true */ // yes, evil, I know
  2500. let _write = document.write.bind(document);
  2501. /*jslint evil: false */
  2502. nt.define(document, 'write', t => {
  2503. let id = t.match(/jwplayer\("(\w+)"\)/i);
  2504. if (id && id[1]) {
  2505. return _write(`<div id="${id[1]}"></div>${t}`);
  2506. } else {
  2507. return _write('');
  2508. }
  2509. });
  2510. });
  2511.  
  2512. scripts['imageban.ru'] = {
  2513. now: () => {
  2514. Object.defineProperty(win, 'V7x1J', { get: () => null });
  2515. //preventPopunders();
  2516. }
  2517. };
  2518.  
  2519. scripts['kinopoisk.ru'] = {
  2520. now: () => {
  2521. // set no-branding body style
  2522. createStyle('body:not(#id) { background: #d5d5d5 url(/images/noBrandBg.jpg) 50% 0 no-repeat !important }');
  2523. },
  2524. dom: () => {
  2525. (style => style ? style.parentNode.removeChild(style) : console.log('Unable to locate branding style.')
  2526. )(_de.querySelector('#branding-style'));
  2527. }
  2528. };
  2529.  
  2530. scripts['korrespondent.net'] = {
  2531. now: () => scriptLander(() => {
  2532. let nt = new nullTools();
  2533. nt.define(win, 'holder', function(id) {
  2534. let div = document.getElementById(id);
  2535. if (!div)
  2536. return;
  2537. if (div.parentNode.classList.contains('col__sidebar')) {
  2538. div.parentNode.appendChild(div);
  2539. div.style.height = '300px';
  2540. }
  2541. });
  2542. }, nullTools),
  2543. dom: () => {
  2544. for (let frame of document.querySelectorAll('.unit-side-informer > iframe'))
  2545. frame.parentNode.style.width = '1px';
  2546. }
  2547. };
  2548.  
  2549. scripts['mail.ru'] = () => scriptLander(() => {
  2550. let nt = new nullTools();
  2551. // Trick to prevent mail.ru from removing 3rd-party styles
  2552. nt.define(Object.prototype, 'restoreVisibility', nt.func(null), false);
  2553. // Disable some of their counters
  2554. nt.define(win, 'rb_counter', nt.func(null, 'rb_counter'));
  2555. if (location.hostname !== 'e.mail.ru')
  2556. nt.define(win, 'createRadar', nt.func(nt.func(null, 'aRadar'), 'createRadar'));
  2557. else
  2558. nt.define(win, 'aRadar', nt.func(null, 'aRadar'));
  2559.  
  2560. // Disable page scrambler on mail.ru to let extensions easily block ads there
  2561. function defineLocator(root)
  2562. {
  2563. let _locator;
  2564. let fishnet = {
  2565. apply: (target, thisArg, args) => {
  2566. console.log(`locator.${target._name}(${JSON.stringify(args).slice(1,-1)})`);
  2567. return target.apply(thisArg, args);
  2568. }
  2569. };
  2570.  
  2571. function wrapLocator(locator)
  2572. {
  2573. if ('setup' in locator)
  2574. {
  2575. let _setup = locator.setup;
  2576. locator.setup = function(o)
  2577. {
  2578. if ('enable' in o)
  2579. {
  2580. o.enable = false;
  2581. console.log('Disable mimic mode.');
  2582. }
  2583. if ('links' in o)
  2584. {
  2585. o.links = [];
  2586. console.log('Call with empty list of sheets.');
  2587. }
  2588. return _setup.call(this, o);
  2589. };
  2590. locator.insertSheet = () => console.log('Ignore insertSheet.');
  2591. locator.wrap = () => console.log('Ignore wrap.');
  2592. }
  2593. try {
  2594. let names = [];
  2595. for (let name in locator)
  2596. if (locator[name] instanceof Function) {
  2597. locator[name]._name = name;
  2598. locator[name] = new Proxy(locator[name], fishnet);
  2599. names.push(name);
  2600. }
  2601. console.log(`[locator] wrapped properties: ${names.join(', ')}`);
  2602. } catch(e) {
  2603. console.log(e);
  2604. }
  2605. _locator = locator;
  2606. }
  2607.  
  2608. if ('locator' in root && root.locator)
  2609. {
  2610. console.log('Found existing "locator" object. :|');
  2611. _locator = root.locator;
  2612. wrapLocator(root.locator);
  2613. }
  2614.  
  2615. let loc_desc = Object.getOwnPropertyDescriptor(root, 'locator');
  2616. if (!loc_desc || loc_desc.set !== wrapLocator)
  2617. try {
  2618. Object.defineProperty(root, 'locator', {
  2619. set: wrapLocator,
  2620. get: () => _locator
  2621. });
  2622. } catch (err) {
  2623. console.log('Unable to redefine "locator" object!!!', err);
  2624. }
  2625. }
  2626.  
  2627. function defineDetector(mr)
  2628. {
  2629. let __ = mr._ || {};
  2630.  
  2631. if ('HONEYPOT' in __)
  2632. {
  2633. console.log('Disarming existing detector instance. :|', JSON.stringify(__));
  2634. nt.define(__, 'HONEYPOT', '.honeypot_fake_class_to_miss');
  2635. nt.define(__, 'STUCK_IN_POT', false);
  2636. }
  2637.  
  2638. __ = new Proxy(__, {
  2639. get: (t, p) => t[p],
  2640. set: (t, p, v) => {
  2641. console.log(`mr._.${p} =`, v);
  2642. if (['HONEYPOT', 'STUCK_IN_POT'].includes(p))
  2643. console.log('Not changed.');
  2644. t[p] = v; // setter in nt.define will prevent this when needed
  2645. return true;
  2646. }
  2647. });
  2648. Object.defineProperty(mr, '_', {
  2649. enumerable: true,
  2650. value: __
  2651. });
  2652. }
  2653.  
  2654. if (location.hostname === 'e.mail.ru')
  2655. defineLocator(win);
  2656. else {
  2657. try {
  2658. let _mr;
  2659. Object.defineProperty(win, 'mr', {
  2660. enumerable: true,
  2661. get: () => _mr,
  2662. set: (v) => {
  2663. if (v === _mr)
  2664. return true;
  2665. console.log('Trapped new "mr" object.');
  2666. defineLocator(v.mimic ? v.mimic : v);
  2667. defineDetector(v);
  2668. _mr = v;
  2669. }
  2670. });
  2671. if (!('mr' in win))
  2672. throw 'Wat!?';
  2673. } catch (e) {
  2674. console.log('Found existing "mr" object.', e instanceof TypeError ? '' : e);
  2675. defineLocator(win.mr);
  2676. defineDetector(win.mr);
  2677. }
  2678. }
  2679. }, nullTools);
  2680.  
  2681. scripts['megogo.net'] = {
  2682. now: () => {
  2683. let nt = new nullTools();
  2684. nt.define(win, 'adBlock', false);
  2685. nt.define(win, 'showAdBlockMessage', nt.func(null));
  2686. }
  2687. };
  2688.  
  2689. scripts['naruto-base.su'] = () => gardener('div[id^="entryID"],.block', /href="http.*?target="_blank"/i);
  2690.  
  2691. scripts['overclockers.ru'] = {
  2692. now: () => scriptLander(() => {
  2693. let _innerHTML = Object.getOwnPropertyDescriptor(Element.prototype, 'innerHTML');
  2694. let _set_innerHTML = _innerHTML.set;
  2695. _innerHTML.set = function() {
  2696. if (this === document.body) {
  2697. console.log('Anti-Adblock killed.');
  2698. return true;
  2699. }
  2700. _set_innerHTML.apply(this, arguments);
  2701. };
  2702. Object.defineProperty(Element.prototype, 'innerHTML', _innerHTML);
  2703. })
  2704. };
  2705. scripts['forums.overclockers.ru'] = {
  2706. now: () => {
  2707. createStyle('.needblock {position: fixed; left: -10000px}');
  2708. Object.defineProperty(win, 'adblck', {
  2709. get: () => 'no',
  2710. set: () => undefined,
  2711. enumerable: true
  2712. });
  2713. }
  2714. };
  2715.  
  2716. scripts['pb.wtf'] = {
  2717. other: ['piratbit.org', 'piratbit.ru'],
  2718. now: () => {
  2719. // line above topic content and images in the slider in the header
  2720. gardener(
  2721. 'a[href^="/exit/"], a[href^="/fxt/"], a[href$="=="]',
  2722. /img|Реклама|center/i,
  2723. { root: '.release-navbar,#page_content', observe: true, parent: 'div,tr' }
  2724. );
  2725. // ads in comments
  2726. gardener('img[data-name="PiraBo"]', /./i, {root:'#main_content .table', observe:true, parent:'tr'});
  2727. }
  2728. };
  2729.  
  2730. scripts['pikabu.ru'] = () => gardener('.story', /story__author[^>]+>ads</i, {root: '.inner_wrap', observe: true});
  2731.  
  2732. scripts['peka2.tv'] = () => {
  2733. let bodyClass = 'body--branding';
  2734. let checkNode = node => {
  2735. for (let className of node.classList)
  2736. if (className.includes('banner') || className === bodyClass) {
  2737. _removeAttribute.call(node, 'style');
  2738. node.classList.remove(className);
  2739. for (let attr of Array.from(node.attributes)) {
  2740. if (attr.name.startsWith('advert'))
  2741. _removeAttribute.call(node, attr.name);
  2742. }
  2743. }
  2744. };
  2745. (new MutationObserver(ms => {
  2746. let m, node;
  2747. for (m of ms) for (node of m.addedNodes)
  2748. if (node instanceof HTMLElement)
  2749. checkNode(node);
  2750. })).observe(_de, {childList: true, subtree: true});
  2751. (new MutationObserver(ms => {
  2752. for (let m of ms)
  2753. checkNode(m.target);
  2754. })).observe(_de, {attributes: true, subtree: true, attributeFilter: ['class']});
  2755. };
  2756.  
  2757. scripts['qrz.ru'] = {
  2758. now: () => {
  2759. let nt = new nullTools();
  2760. nt.define(win, 'ab', false);
  2761. nt.define(win, 'tryMessage', nt.func(null));
  2762. }
  2763. };
  2764.  
  2765. scripts['razlozhi.ru'] = {
  2766. now: () => {
  2767. for (let func of ['createShadowRoot', 'attachShadow'])
  2768. if (func in Element.prototype)
  2769. Element.prototype[func] = function(){ return this.cloneNode(); };
  2770. }
  2771. };
  2772.  
  2773. scripts['rbc.ru'] = {
  2774. dom: () => {
  2775. let _preventDefault = Event.prototype.preventDefault;
  2776. Event.prototype.preventDefault = function preventDefault()
  2777. {
  2778. let t = this.target;
  2779. if (t instanceof HTMLAnchorElement || t.closest('A'))
  2780. throw new Error('an.yandex redirect prevention');
  2781. return _preventDefault.call(this);
  2782. };
  2783.  
  2784. function cleaner(nodes)
  2785. {
  2786. for (let node of nodes)
  2787. {
  2788. if (!node.classList || !node.classList.contains('js-yandex-counter'))
  2789. continue;
  2790. node.classList.remove('js-yandex-counter');
  2791. node.removeAttribute('data-yandex-name');
  2792. node.removeAttribute('data-yandex-params');
  2793. }
  2794. }
  2795. cleaner(_de.querySelectorAll('.js-yandex-counter'));
  2796.  
  2797. (new MutationObserver(
  2798. ms => { for (let m of ms) cleaner(m.addedNodes); }
  2799. )).observe(_de, {childList: true, subtree: true});
  2800. }
  2801. };
  2802.  
  2803. scripts['rp5.ru'] = {
  2804. other: ['rp5.by', 'rp5.kz', 'rp5.ua'],
  2805. now: () => gardener('div[id][class]', /\?AdvertMgmt=|adsbygoogle/, { root: '#content-wrapper', log: true })
  2806. };
  2807.  
  2808. scripts['rutube.ru'] = () => scriptLander(() => {
  2809. let _parse = JSON.parse.bind(JSON);
  2810. let _skip_enabled = false;
  2811. JSON.parse = (...args) => {
  2812. let res = _parse(...args),
  2813. log = false;
  2814. if (!res)
  2815. return res;
  2816. // parse player configuration
  2817. if ('appearance' in res || 'video_balancer' in res) {
  2818. log = true;
  2819. if ('appearance' in res) {
  2820. res.appearance.forbid_seek = false;
  2821. res.appearance.forbid_timeline_preview = false;
  2822. }
  2823. _skip_enabled = !!res.remove_unseekable_blocks;
  2824. res.advert = [];
  2825. for (let limit of res.limits)
  2826. limit.limit = 0;
  2827. res.yast = null;
  2828. res.yast_live_online = null;
  2829. Object.defineProperty(res, 'stat', {
  2830. get: x => [],
  2831. set: x => true,
  2832. enumerable: true
  2833. });
  2834. }
  2835.  
  2836. // parse video configuration
  2837. if ('video_url' in res) {
  2838. log = true;
  2839. if ('cuepoints' in res && !_skip_enabled)
  2840. for (let point of res.cuepoints) {
  2841. point.is_pause = false;
  2842. point.show_navigation = true;
  2843. point.forbid_seek = false;
  2844. }
  2845. }
  2846.  
  2847. if (log)
  2848. console.log('[rutube]', res);
  2849. return res;
  2850. };
  2851. });
  2852.  
  2853. scripts['simpsonsua.com.ua'] = () => scriptLander(() => {
  2854. let _addEventListener = Object.getPrototypeOf(HTMLDocument).prototype.addEventListener;
  2855. document.addEventListener = function(event, callback) {
  2856. if (event === 'DOMContentLoaded' && callback.toString().includes('show_warning'))
  2857. return;
  2858. return _addEventListener.apply(this, arguments);
  2859. };
  2860. });
  2861.  
  2862. scripts['spaces.ru'] = () => {
  2863. gardener('div:not(.f-c_fll) > a[href*="spaces.ru/?Cl="]', /./, { parent: 'div' });
  2864. gardener('.js-banner_rotator', /./, { parent: '.widgets-group' });
  2865. };
  2866.  
  2867. scripts['spam-club.blogspot.co.uk'] = () => {
  2868. let _clientHeight = Object.getOwnPropertyDescriptor(Element.prototype, 'clientHeight'),
  2869. _clientWidth = Object.getOwnPropertyDescriptor(Element.prototype, 'clientWidth');
  2870. let wrapGetter = (getter) => {
  2871. let _getter = getter;
  2872. return function()
  2873. {
  2874. let _size = _getter.apply(this, arguments);
  2875. return _size ? _size : 1;
  2876. };
  2877. };
  2878. _clientHeight.get = wrapGetter(_clientHeight.get);
  2879. _clientWidth.get = wrapGetter(_clientWidth.get);
  2880. Object.defineProperty(Element.prototype, 'clientHeight', _clientHeight);
  2881. Object.defineProperty(Element.prototype, 'clientWidth', _clientWidth);
  2882. let _onload = Object.getOwnPropertyDescriptor(HTMLElement.prototype, 'onload'),
  2883. _set_onload = _onload.set;
  2884. _onload.set = function()
  2885. {
  2886. if (this instanceof HTMLImageElement)
  2887. return true;
  2888. _set_onload.apply(this, arguments);
  2889. };
  2890. Object.defineProperty(HTMLElement.prototype, 'onload', _onload);
  2891. };
  2892.  
  2893. scripts['sport-express.ru'] = () => gardener('.js-relap__item',/>Реклама\s+<\//, {root:'.container', observe: true});
  2894.  
  2895. scripts['sports.ru'] = {
  2896. now: () => {
  2897. gardener('.aside-news-list__item', /aside-news-list__advert/i, {root:'.columns-layout__left', observe: true});
  2898. gardener('.material-list__item', /Реклама/i, {root:'.columns-layout', observe: true});
  2899. // extra functionality: shows/hides panel at the top depending on scroll direction
  2900. createStyle([
  2901. '.user-panel__fixed { transition: top 0.2s ease-in-out!important; }',
  2902. '.user-panel-up { top: -40px!important }'
  2903. ], {id: 'userPanelSlide'}, false);
  2904. },
  2905. dom: () => {
  2906. (function lookForPanel()
  2907. {
  2908. let panel = document.querySelector('.user-panel__fixed');
  2909. if (!panel)
  2910. setTimeout(lookForPanel, 100);
  2911. else
  2912. window.addEventListener(
  2913. 'wheel', function(e)
  2914. {
  2915. if (e.deltaY > 0 && !panel.classList.contains('user-panel-up'))
  2916. panel.classList.add('user-panel-up');
  2917. else if (e.deltaY < 0 && panel.classList.contains('user-panel-up'))
  2918. panel.classList.remove('user-panel-up');
  2919. }, false
  2920. );
  2921. })();
  2922. }
  2923. };
  2924.  
  2925. scripts['stealthz.ru'] = {
  2926. dom: () => {
  2927. // skip timeout
  2928. let $ = document.querySelector.bind(document);
  2929. let [timer_1, timer_2] = [$('#timer_1'), $('#timer_2')];
  2930. if (!timer_1 || !timer_2)
  2931. return;
  2932. timer_1.style.display = 'none';
  2933. timer_2.style.display = 'block';
  2934. }
  2935. };
  2936.  
  2937. scripts['yap.ru'] = {
  2938. other: ['yaplakal.com'],
  2939. now: () => {
  2940. gardener('form > table[id^="p_row_"]:nth-of-type(2)', /member1438|Administration/);
  2941. gardener('.icon-comments', /member1438|Administration|\/go\/\?http/, {parent:'tr', siblings:-2});
  2942. }
  2943. };
  2944.  
  2945. scripts['rambler.ru'] = {
  2946. other: ['championat.com','gazeta.ru','media.eagleplatform.com','lenta.ru', 'quto.ru'],
  2947. now: () => scriptLander(() => {
  2948. // Prevent autoplay
  2949. if (!('EaglePlayer' in win)) {
  2950. let _EaglePlayer = void 0;
  2951. Object.defineProperty(win, 'EaglePlayer', {
  2952. enumerable: true,
  2953. get: x => _EaglePlayer,
  2954. set: x => {
  2955. if (x === _EaglePlayer)
  2956. return true;
  2957. _EaglePlayer = x;
  2958. let _init = void 0;
  2959. Object.defineProperty(_EaglePlayer.prototype, 'init', {
  2960. enumerable: true,
  2961. set: x => _init = x,
  2962. get: function() {
  2963. let _self = this;
  2964. if (_self.options) {
  2965. Object.defineProperty(this.options, 'autoplay', {
  2966. enumerable: true,
  2967. get: x => false,
  2968. set: x => null
  2969. });
  2970. }
  2971. if (_self.options && _self.options.el && inIFrame) {
  2972. let addListener = (player) => {
  2973. console.log('Attached autostop');
  2974. player.addEventListener('canplay', e => {
  2975. e.target.play = () => console.log('Applied autostop.');
  2976. setTimeout(player => {
  2977. delete player.play;
  2978. console.log('Detached autostop');
  2979. }, 1500, e.target);
  2980. }, false);
  2981. };
  2982. (new MutationObserver(ms => {
  2983. let m, node;
  2984. for (m of ms) for (node of m.addedNodes)
  2985. if (node instanceof HTMLVideoElement)
  2986. addListener(node);
  2987. })).observe(this.options.el, { childList: true, subtree: true });
  2988. }
  2989. return _init;
  2990. }
  2991. });
  2992. }
  2993. });
  2994. let _setAttribute = Element.prototype.setAttribute;
  2995. let isAutoplay = /^autoplay$/i;
  2996. Element.prototype.setAttribute = function setAttribute(name)
  2997. {
  2998. if (!this._stopped && isAutoplay.test(name))
  2999. {
  3000. console.log('Prevented assigning autoplay attribute.');
  3001. return null;
  3002. }
  3003. return _setAttribute.apply(this, arguments);
  3004. };
  3005. } else if (inIFrame) {
  3006. let _setAttribute = Element.prototype.setAttribute;
  3007. let isAutoplay = /^autoplay$/i;
  3008. Element.prototype.setAttribute = function setAttribute(name)
  3009. {
  3010. if (!this._stopped && isAutoplay.test(name))
  3011. {
  3012. console.log('Prevented assigning autoplay attribute.');
  3013. this._stopped = true;
  3014. this.play = () => {
  3015. console.log('Prevented attempt to force-start playback.');
  3016. delete this.play;
  3017. };
  3018. return null;
  3019. }
  3020. return _setAttribute.apply(this, arguments);
  3021. };
  3022. }
  3023. if (location.hostname.endsWith('.media.eagleplatform.com'))
  3024. return;
  3025. let CSSRuleProto = 'cssText' in CSSRule.prototype ? CSSRule.prototype : CSSStyleRule.prototype;
  3026. let _cssText = Object.getOwnPropertyDescriptor(CSSRuleProto, 'cssText');
  3027. let _cssText_get = _cssText.get;
  3028. _cssText.configurable = false;
  3029. _cssText.get = function()
  3030. {
  3031. let cssText = _cssText_get.call(this);
  3032. if (cssText.includes('content:'))
  3033. {
  3034. console.log('Blocked access to suspicious cssText:', cssText.slice(0,60), '\u2026', cssText.length);
  3035. return null;
  3036. }
  3037. return cssText;
  3038. };
  3039. Object.defineProperty(CSSRuleProto, 'cssText', _cssText);
  3040. // fake global Adf object
  3041. let nt = new nullTools();
  3042. let Adf_banner = {};
  3043. [
  3044. 'reloadssp', 'sspScroll',
  3045. 'sspRich', 'ssp'
  3046. ].forEach(name => Adf_banner[name] = nt.proxy(() => new Promise((r,j) => r({status: true}))));
  3047. nt.define(win, 'Adf', nt.proxy({
  3048. banner: nt.proxy(Adf_banner)
  3049. }));
  3050. // extra script to remove partner news on gazeta.ru
  3051. if (!location.hostname.includes('gazeta.ru'))
  3052. return;
  3053. (new MutationObserver(
  3054. (ms) => {
  3055. let m, node, header;
  3056. for (m of ms) for (node of m.addedNodes)
  3057. if (node instanceof HTMLDivElement && node.matches('.sausage'))
  3058. {
  3059. header = node.querySelector('.sausage-header');
  3060. if (header && /новости\s+партн[её]ров/i.test(header.textContent))
  3061. node.style.display = 'none';
  3062. }
  3063. }
  3064. )).observe(document.documentElement, { childList:true, subtree: true });
  3065. }, `let inIFrame = ${inIFrame}`, nullTools)
  3066. };
  3067.  
  3068. scripts['reactor.cc'] = {
  3069. other: ['joyreactor.cc', 'pornreactor.cc'],
  3070. now: () => {
  3071. selectiveEval();
  3072. scriptLander(() => {
  3073. let nt = new nullTools();
  3074. win.open = (function(){ throw new Error('Redirect prevention.'); }).bind(window);
  3075. nt.define(win, 'Worker', function(){});
  3076. nt.define(win, 'JRCH', win.CoinHive);
  3077. }, nullTools);
  3078. },
  3079. click: function(e)
  3080. {
  3081. let node = e.target;
  3082. if (node.nodeType === _Node.ELEMENT_NODE &&
  3083. node.style.position === 'absolute' &&
  3084. node.style.zIndex > 0)
  3085. node.parentNode.removeChild(node);
  3086. },
  3087. dom: function()
  3088. {
  3089. let words = new RegExp(
  3090. 'блокировщик рекламы'
  3091. .split('')
  3092. .map(function(e){return e+'[\u200b\u200c\u200d]*';})
  3093. .join('')
  3094. .replace(' ', '\\s*')
  3095. .replace(/[аоре]/g, function(e){return ['[аa]','[оo]','[рp]','[еe]']['аоре'.indexOf(e)];}),
  3096. 'i'),
  3097. can;
  3098. function deeper(spider)
  3099. {
  3100. let c, l, n;
  3101. if (words.test(spider.innerText))
  3102. {
  3103. if (spider.nodeType === _Node.TEXT_NODE)
  3104. return true;
  3105. c = spider.childNodes;
  3106. l = c.length;
  3107. n = 0;
  3108. while(l--)
  3109. if (deeper(c[l]), can)
  3110. n++;
  3111. if (n > 0 && n === c.length && spider.offsetHeight < 750)
  3112. can.push(spider);
  3113. return false;
  3114. }
  3115. return true;
  3116. }
  3117. function probe()
  3118. {
  3119. if (words.test(document.body.innerText))
  3120. {
  3121. can = [];
  3122. deeper(document.body);
  3123. let i = can.length, spider;
  3124. while(i--) {
  3125. spider = can[i];
  3126. if (spider.offsetHeight > 10 && spider.offsetHeight < 750)
  3127. _setAttribute.call(spider, 'style', 'background:none!important');
  3128. }
  3129. }
  3130. }
  3131. (new MutationObserver(probe))
  3132. .observe(document, { childList:true, subtree:true });
  3133. }
  3134. };
  3135.  
  3136. scripts['auto.ru'] = () => {
  3137. let words = /Реклама|Яндекс.Директ|yandex_ad_/;
  3138. let userAdsListAds = (
  3139. '.listing-list > .listing-item,'+
  3140. '.listing-item_type_fixed.listing-item'
  3141. );
  3142. let catalogAds = (
  3143. 'div[class*="layout_catalog-inline"],'+
  3144. 'div[class$="layout_horizontal"]'
  3145. );
  3146. let otherAds = (
  3147. '.advt_auto,'+
  3148. '.sidebar-block,'+
  3149. '.pager-listing + div[class],'+
  3150. '.card > div[class][style],'+
  3151. '.sidebar > div[class],'+
  3152. '.main-page__section + div[class],'+
  3153. '.listing > tbody'
  3154. );
  3155. gardener(userAdsListAds, words, {root:'.listing-wrap', observe:true});
  3156. gardener(catalogAds, words, {root:'.catalog__page,.content__wrapper', observe:true});
  3157. gardener(otherAds, words);
  3158. };
  3159.  
  3160. scripts['rsload.net'] = {
  3161. load: () => {
  3162. let dis = document.querySelector('label[class*="cb-disable"]');
  3163. if (dis)
  3164. dis.click();
  3165. },
  3166. click: () => {
  3167. let t = e.target;
  3168. if (t && t.href && (/:\/\/\d+\.\d+\.\d+\.\d+\//.test(t.href)))
  3169. t.href = t.href.replace('://','://rsload.net:rsload.net@');
  3170. }
  3171. };
  3172.  
  3173. let domain;
  3174. // add alternative domain names if present and wrap functions into objects
  3175. for (let name in scripts)
  3176. {
  3177. if (scripts[name] instanceof Function)
  3178. scripts[name] = { now: scripts[name] };
  3179. for (domain of (scripts[name].other||[]))
  3180. {
  3181. if (domain in scripts)
  3182. console.log('Error in scripts list. Script for', name, 'replaced script for', domain);
  3183. scripts[domain] = scripts[name];
  3184. }
  3185. delete scripts[name].other;
  3186. }
  3187. // look for current domain in the list and run appropriate code
  3188. domain = document.domain;
  3189. while (domain.indexOf('.') > -1)
  3190. {
  3191. if (domain in scripts) for (let when in scripts[domain])
  3192. switch(when)
  3193. {
  3194. case 'now':
  3195. scripts[domain][when]();
  3196. break;
  3197. case 'dom':
  3198. document.addEventListener('DOMContentLoaded', scripts[domain][when], false);
  3199. break;
  3200. default:
  3201. document.addEventListener (when, scripts[domain][when], false);
  3202. }
  3203. domain = domain.slice(domain.indexOf('.') + 1);
  3204. }
  3205.  
  3206. // Batch script lander
  3207. if (!skipLander)
  3208. landScript(batchLand, batchPrepend);
  3209.  
  3210. { // JS Fixes Tools Menu
  3211. let openOptions = function()
  3212. {
  3213. let ovl = _createElement('div'),
  3214. inner = _createElement('div');
  3215. ovl.style = (
  3216. 'position: fixed;'+
  3217. 'top:0; left:0;'+
  3218. 'bottom: 0; right: 0;'+
  3219. 'background: rgba(0,0,0,0.85);'+
  3220. 'z-index: 2147483647;'+
  3221. 'padding: 5em'
  3222. );
  3223. inner.style = (
  3224. 'background: whitesmoke;'+
  3225. 'font-size: 10pt;'+
  3226. 'color: black;'+
  3227. 'padding: 1em'
  3228. );
  3229. inner.textContent = 'JS Fixes Tools';
  3230. inner.appendChild(_createElement('br'));
  3231. inner.appendChild(_createElement('br'));
  3232. ovl.addEventListener(
  3233. 'click', function(e)
  3234. {
  3235. if (e.target === ovl) {
  3236. ovl.parentNode.removeChild(ovl);
  3237. e.preventDefault();
  3238. }
  3239. e.stopPropagation();
  3240. }, false
  3241. );
  3242.  
  3243. let sObjBtn = _createElement('button');
  3244. sObjBtn.onclick = getStrangeObjectsList;
  3245. sObjBtn.textContent = 'Print (in console) list of unusual window properties';
  3246. inner.appendChild(_createElement('br'));
  3247. inner.appendChild(sObjBtn);
  3248.  
  3249. document.body.appendChild(ovl);
  3250. ovl.appendChild(inner);
  3251. };
  3252.  
  3253. // monitor keys pressed for Ctrl+Alt+Shift+J > s > f code
  3254. let opPos = 0, opKey = ['KeyJ','KeyS','KeyF'];
  3255. document.addEventListener(
  3256. 'keydown', function(e)
  3257. {
  3258. if ((e.code === opKey[opPos] || e.location) &&
  3259. (!!opPos || e.altKey && e.ctrlKey && e.shiftKey))
  3260. {
  3261. opPos += e.location ? 0 : 1;
  3262. e.stopPropagation();
  3263. e.preventDefault();
  3264. } else {
  3265. opPos = 0;
  3266. }
  3267. if (opPos === opKey.length)
  3268. {
  3269. opPos = 0;
  3270. openOptions();
  3271. }
  3272. }, false
  3273. );
  3274. }
  3275. })();