RU AdList JS Fixes

try to take over the world!

当前为 2019-02-05 提交的版本,查看 最新版本

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