RU AdList JS Fixes

try to take over the world!

当前为 2018-09-19 提交的版本,查看 最新版本

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