Greasy Fork 还支持 简体中文。

RU AdList JS Fixes

try to take over the world!

目前為 2019-02-08 提交的版本,檢視 最新版本

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