RU AdList JS Fixes

try to take over the world!

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

  1. // ==UserScript==
  2. // @name RU AdList JS Fixes
  3. // @namespace ruadlist_js_fixes
  4. // @version 20190204.2
  5. // @description try to take over the world!
  6. // @author lainverse & dimisa
  7. // @supportURL https://greasyfork.org/en/scripts/19993-ru-adlist-js-fixes/feedback
  8. // @match *://*/*
  9. // @exclude *://auth.wi-fi.ru/*
  10. // @exclude *://*.alfabank.ru/*
  11. // @exclude *://alfabank.ru/*
  12. // @exclude *://*.unicreditbanking.net/*
  13. // @exclude *://unicreditbanking.net/*
  14. // @exclude *://*.telegram.org/*
  15. // @exclude *://telegram.org/*
  16. // @grant unsafeWindow
  17. // @grant window.close
  18. // @run-at document-start
  19. // ==/UserScript==
  20.  
  21. (function() {
  22. 'use strict';
  23.  
  24. let win = (unsafeWindow || window);
  25.  
  26. // MooTools are crazy enough to replace standard browser object window.Document: https://mootools.net/core
  27. // Occasionally their code runs before my script on some domains and causes all kinds of havoc.
  28. let _Document = Object.getPrototypeOf(HTMLDocument.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. scriptLander(() => {
  1095. selectiveCookies('bltsr|blcrm');
  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. captureMessage: nt.func(null, 'Raven.captureMessage'),
  1182. config: nt.func({
  1183. install: nt.func(null, 'Raven.config().install')
  1184. }, 'Raven.config')
  1185. }));
  1186. }, nullTools, selectiveCookies, 'let _setAttribute = Function.prototype.call.bind(_Element.setAttribute)');
  1187.  
  1188. if ('attachShadow' in _Element) {
  1189. let fakeRoot = () => ({
  1190. firstChild: null,
  1191. appendChild: () => null,
  1192. querySelector: () => null,
  1193. querySelectorAll: () => null
  1194. });
  1195. _Element.createShadowRoot = fakeRoot;
  1196. let shadows = new WeakMap();
  1197. let _attachShadow = Object.getOwnPropertyDescriptor(_Element, 'attachShadow');
  1198. _attachShadow.value = function() {
  1199. return shadows.set(this, fakeRoot()).get(this);
  1200. };
  1201. Object.defineProperty(_Element, 'attachShadow', _attachShadow);
  1202. let _shadowRoot = Object.getOwnPropertyDescriptor(_Element, 'shadowRoot');
  1203. _shadowRoot.set = () => null;
  1204. _shadowRoot.get = function() {
  1205. return shadows.has(this) ? shadows.get(this) : void 0;
  1206. };
  1207. Object.defineProperty(_Element, 'shadowRoot', _shadowRoot);
  1208. }
  1209.  
  1210. // Disable banner styleSheet (on main page)
  1211. document.addEventListener('DOMContentLoaded', () => {
  1212. for (let sheet of document.styleSheets)
  1213. try {
  1214. for (let rule of sheet.cssRules)
  1215. if (rule.cssText.includes(' 728px 90px')) {
  1216. rule.parentStyleSheet.disabled = true;
  1217. _console.log('Disabled banner styleSheet:', rule.parentStyleSheet);
  1218. }
  1219. } catch(ignore) {}
  1220. }, false);
  1221.  
  1222. // Partially based on https://greasyfork.org/en/scripts/22737-remove-yandex-redirect
  1223. let selectors = (
  1224. 'A[onmousedown*="/jsredir"],'+
  1225. 'A[data-vdir-href],'+
  1226. 'A[data-counter]'
  1227. );
  1228. let removeTrackingAttributes = function(link) {
  1229. link.removeAttribute('onmousedown');
  1230. if (link.hasAttribute('data-vdir-href')) {
  1231. link.removeAttribute('data-vdir-href');
  1232. link.removeAttribute('data-orig-href');
  1233. }
  1234. if (link.hasAttribute('data-counter')) {
  1235. link.removeAttribute('data-counter');
  1236. link.removeAttribute('data-bem');
  1237. }
  1238. };
  1239. let removeTracking = function(scope) {
  1240. if (scope instanceof Element)
  1241. for (let link of scope.querySelectorAll(selectors))
  1242. removeTrackingAttributes(link);
  1243. };
  1244. _document.addEventListener('DOMContentLoaded', (e) => removeTracking(e.target));
  1245. (new MutationObserver(
  1246. function(ms) {
  1247. let m, node;
  1248. for (m of ms) for (node of m.addedNodes)
  1249. if (node instanceof HTMLAnchorElement && node.matches(selectors))
  1250. removeTrackingAttributes(node);
  1251. else
  1252. removeTracking(node);
  1253. }
  1254. )).observe(_de, { childList: true, subtree: true });
  1255. }
  1256.  
  1257. // https://greasyfork.org/en/scripts/21937-moonwalk-hdgo-kodik-fix v0.8 (adapted)
  1258. _document.addEventListener(
  1259. 'DOMContentLoaded', function() {
  1260. let log = name => _console.log(`Player FIX: Detected ${name} player in ${location.href}`);
  1261. function removeVast (data) {
  1262. if (data && (data.vast || data.reserve_vast || data.vast_button)) {
  1263. _console.log('Removed:\ndata.vast', data.vast, '\ndata.reserve_vast', data.reserve_vast, '\ndata.vast_button', data.vast_button);
  1264. delete data.vast;
  1265. delete data.reserve_vast;
  1266. delete data.vast_button;
  1267. if (data.chain) {
  1268. let need = [],
  1269. drop = [],
  1270. links = data.chain.split('.');
  1271. for (let link of links)
  1272. if (!/^vast_|_vast_|_vast$/.test(link))
  1273. need.push(link);
  1274. else
  1275. drop.push(link);
  1276. _console.log('Dropped from the chain:', ...drop);
  1277. data.chain = need.join('.');
  1278. }
  1279. }
  1280. return data;
  1281. }
  1282. if (win.video_balancer !== void 0 && win.event_callback !== void 0) {
  1283. log('Moonwalk');
  1284. if (video_balancer.adv_loader)
  1285. removeVast(video_balancer.adv_loader.options);
  1286. if ('_mw_adb' in win)
  1287. Object.defineProperty(win, '_mw_adb', {
  1288. get: () => false,
  1289. set: () => true
  1290. });
  1291. /*} else if (win.stat_url !== undefined && win.is_html5 !== undefined && win.is_wp8 !== undefined) {
  1292. log('HDGo');
  1293. _document.body.onclick = null;
  1294. let tmp = _document.querySelector('#swtf');
  1295. if (tmp)
  1296. tmp.style.display = 'none';
  1297. if (win.banner_second !== void 0)
  1298. win.banner_second = 0;
  1299. if (win.$banner_ads !== void 0)
  1300. win.$banner_ads = false;
  1301. if (win.$new_ads !== void 0)
  1302. win.$new_ads = false;
  1303. if (win.createCookie !== void 0)
  1304. win.createCookie('popup', 'true', '999');
  1305. if (win.canRunAds !== void 0 && win.canRunAds !== true)
  1306. win.canRunAds = true;*/
  1307. } else if (win.startKodikPlayer !== void 0) {
  1308. log('Kodik');
  1309. // skip attempt to block access to HD resolutions
  1310. let chainCall = new Proxy({}, { get: () => () => chainCall });
  1311. if ($ && $.prototype && $.prototype.addClass) {
  1312. let $addClass = $.prototype.addClass;
  1313. $.prototype.addClass = function (className) {
  1314. if (className === 'blocked')
  1315. return chainCall;
  1316. return $addClass.apply(this, arguments);
  1317. };
  1318. }
  1319. // remove ad links from the metadata
  1320. let _ajax = win.$.ajax;
  1321. win.$.ajax = (params, ...args) => {
  1322. if (params.success) {
  1323. let _s = params.success;
  1324. params.success = (data, ...args) => _s(removeVast(data), ...args);
  1325. }
  1326. return _ajax(params, ...args);
  1327. }
  1328. } else if (win.getnextepisode && win.uppodEvent) {
  1329. log('Share-Serials.net');
  1330. scriptLander(
  1331. function() {
  1332. let _setInterval = win.setInterval,
  1333. _setTimeout = win.setTimeout,
  1334. _toString = Function.prototype.call.bind(Function.prototype.toString);
  1335. win.setInterval = function(func) {
  1336. if (func instanceof Function && _toString(func).includes('_delay')) {
  1337. let intv = _setInterval.call(
  1338. this, function() {
  1339. _setTimeout.call(
  1340. this, function(intv) {
  1341. clearInterval(intv);
  1342. let timer = _document.querySelector('#timer');
  1343. if (timer)
  1344. timer.click();
  1345. }, 100, intv);
  1346. func.call(this);
  1347. }, 5
  1348. );
  1349.  
  1350. return intv;
  1351. }
  1352. return _setInterval.apply(this, arguments);
  1353. };
  1354. win.setTimeout = function(func) {
  1355. if (func instanceof Function && _toString(func).includes('adv_showed'))
  1356. return _setTimeout.call(this, func, 0);
  1357. return _setTimeout.apply(this, arguments);
  1358. };
  1359. }
  1360. );
  1361. } else if ('ADC' in win) {
  1362. log('vjs-creatives plugin in');
  1363. let replacer = (obj) => {
  1364. for (let name in obj)
  1365. if (obj[name] instanceof Function)
  1366. obj[name] = () => null;
  1367. };
  1368. replacer(win.ADC);
  1369. replacer(win.currentAdSlot);
  1370. }
  1371. UberVK: {
  1372. if (!inIFrame)
  1373. break UberVK;
  1374. let oddNames = 'HD' in win &&
  1375. !Object.getOwnPropertyNames(win).every(n => !n.startsWith('_0x'));
  1376. if (!oddNames)
  1377. break UberVK;
  1378. log('UberVK');
  1379. XMLHttpRequest.prototype.open = () => {
  1380. throw 404;
  1381. };
  1382. }
  1383. }, false
  1384. );
  1385.  
  1386. // Applies wrapper function on the current page and all newly created same-origin iframes
  1387. // This is used to prevent trick which allows to get fresh page API through newly created same-origin iframes
  1388. function deepWrapAPI(wrapper) {
  1389. let wrapped = new WeakSet(),
  1390. _get_contentWindow = () => null,
  1391. log = (...args) => false && _console.log(...args);
  1392. let wrapAPI = root => {
  1393. if (!root || wrapped.has(root))
  1394. return;
  1395. wrapped.add(root);
  1396. try {
  1397. wrapper(root instanceof HTMLIFrameElement ? _get_contentWindow(root) : root);
  1398. log('Wrapped API in', (root === win) ? "main window." : root);
  1399. } catch(e) {
  1400. log('Failed to wrap API in', (root === win) ? "main window." : root, '\n', e);
  1401. }
  1402. };
  1403.  
  1404. // wrap API on contentWindow access
  1405. let _apply = Function.prototype.apply;
  1406. let _contentWindow = Object.getOwnPropertyDescriptor(HTMLIFrameElement.prototype, 'contentWindow');
  1407. _get_contentWindow = _apply.bind(_contentWindow.get);
  1408. _contentWindow.get = function() {
  1409. wrapAPI(this);
  1410. return _get_contentWindow(this);;
  1411. };
  1412. Object.defineProperty(HTMLIFrameElement.prototype, 'contentWindow', _contentWindow);
  1413.  
  1414. // wrap API on contentDocument access
  1415. let _contentDocument = Object.getOwnPropertyDescriptor(HTMLIFrameElement.prototype, 'contentDocument');
  1416. let _get_contentDocument = _apply.bind(_contentDocument.get);
  1417. _contentDocument.get = function() {
  1418. wrapAPI(this);
  1419. return _get_contentDocument(this);
  1420. };
  1421. Object.defineProperty(HTMLIFrameElement.prototype, 'contentDocument', _contentDocument);
  1422.  
  1423. // manual children objects traverser to avoid issues
  1424. // with calling querySelectorAll on wrong types of objects
  1425. let _nodeType = _apply.bind(Object.getOwnPropertyDescriptor(_Node, 'nodeType').get);
  1426. let _childNodes = _apply.bind(Object.getOwnPropertyDescriptor(_Node, 'childNodes').get);
  1427. let _ELEMENT_NODE = _Node.ELEMENT_NODE;
  1428. let _DOCUMENT_FRAGMENT_NODE = _Node.DOCUMENT_FRAGMENT_NODE
  1429. let wrapFrames = root => {
  1430. if (_nodeType(root) !== _ELEMENT_NODE && _nodeType(root) !== _DOCUMENT_FRAGMENT_NODE)
  1431. return; // only process nodes which may contain an IFRAME or be one
  1432. if (root instanceof HTMLIFrameElement) {
  1433. wrapAPI(root);
  1434. return;
  1435. }
  1436. for (let child of _childNodes(root))
  1437. wrapFrames(child);
  1438. };
  1439.  
  1440. // wrap API in a newly appended iframe objects
  1441. let _appendChild = _apply.bind(Node.prototype.appendChild);
  1442. Node.prototype.appendChild = function appendChild() {
  1443. '[native code]';
  1444. let res = _appendChild(this, arguments);
  1445. wrapFrames(arguments[0]);
  1446. return res;
  1447. };
  1448.  
  1449. // wrap API in iframe objects created with innerHTML of element on page
  1450. let _innerHTML = Object.getOwnPropertyDescriptor(_Element, 'innerHTML');
  1451. let _set_innerHTML = _apply.bind(_innerHTML.set);
  1452. _innerHTML.set = function() {
  1453. _set_innerHTML(this, arguments);
  1454. if (_document.contains(this))
  1455. wrapFrames(this);
  1456. };
  1457. Object.defineProperty(_Element, 'innerHTML', _innerHTML);
  1458.  
  1459. wrapAPI(win);
  1460. }
  1461.  
  1462. // piguiqproxy.com / zmctrack.net circumvention and onerror callback prevention
  1463. scriptLander(
  1464. () => {
  1465. // onerror callback blacklist
  1466. let masks = [],
  1467. //blockAll = /(^|\.)(rutracker-org\.appspot\.com)$/,
  1468. isBlocked = url => masks.some(mask => mask.test(url));// || blockAll.test(location.hostname);
  1469. for (let filter of [// blacklist
  1470. // global
  1471. '/fuckadblock/', '/fuckadblock.', '/adv/www/',
  1472. // adservers
  1473. '||185.87.50.147^',
  1474. '||10root25.website^', '||24video.xxx^',
  1475. '||adlabs.ru^', '||adspayformymortgage.win^', '||amgload.net^', '||aviabay.ru^',
  1476. '||bgrndi.com^', '||brokeloy.com^',
  1477. '||cdnjs-aws.ru^','||cnamerutor.ru^',
  1478. '||directadvert.ru^', '||dsn-fishki.ru^', '||docfilms.info^', '||dreadfula.ru^',
  1479. '||et-cod.com^', '||et-code.ru^', '||etcodes.com^',
  1480. '||franecki.net^', '||film-doma.ru^',
  1481. '||free-torrent.org^', '||free-torrent.pw^',
  1482. '||free-torrents.org^', '||free-torrents.pw^',
  1483. '||game-torrent.info^', '||gocdn.ru^',
  1484. '||hdkinoshka.com^', '||hghit.com^', '||hindcine.net^',
  1485. '||kinotochka.net^', '||kinott.com^', '||kinott.ru^',
  1486. '||klcheck.com^', '||kuveres.com^',
  1487. '||lepubs.com^', '||luxadv.com^', '||luxup.ru^', '||luxupcdna.com^',
  1488. '||marketgid.com^', '||mebablo.com^', '||mixadvert.com^', '||mxtads.com^',
  1489. '||nickhel.com^',
  1490. '||oconner.biz^', '||oconner.link^', '||octoclick.net^', '||octozoon.org^',
  1491. '||piguiqproxy.com^', '||pkpojhc.com^',
  1492. '||psma01.com^', '||psma02.com^', '||psma03.com^',
  1493. '||rcdn.pro^', '||recreativ.ru^', '||redtram.com^', '||regpole.com^',
  1494. '||rootmedia.ws^', '||ruttwind.com^', '||rutvind.com^',
  1495. '||skidl.ru^', '||smi2.net^', '||smcheck.org^',
  1496. '||torvind.com^', '||traffic-media.co^', '||trafmag.com^', '||trustjs.net^', '||ttarget.ru^',
  1497. '||u-dot-id-adtool.appspot.com^', '||utarget.ru^',
  1498. '||webadvert-gid.ru^', '||webadvertgid.ru^',
  1499. '||xxuhter.ru^',
  1500. '||yuiout.online^',
  1501. '||zmctrack.net^', '||zoom-film.ru^'])
  1502. masks.push(new RegExp(
  1503. filter.replace(/([\\/[\].+?(){}$])/g, '\\$1')
  1504. .replace(/\*/g, '.*?')
  1505. .replace(/\^(?!$)/g,'\\.?[^\\w%._-]')
  1506. .replace(/\^$/,'\\.?([^\\w%._-]|$)')
  1507. .replace(/^\|\|/,'^(ws|http)s?:\\/+([^/.]+\\.)*?'),
  1508. 'i'));
  1509. // main script
  1510. deepWrapAPI(root => {
  1511. let _call = root.Function.prototype.call,
  1512. _defineProperty = root.Object.defineProperty,
  1513. _getOwnPropertyDescriptor = root.Object.getOwnPropertyDescriptor;
  1514. onerror: {
  1515. // 'onerror' handler for scripts from blacklisted sources
  1516. let scriptMap = new WeakMap();
  1517. let _Reflect_apply = root.Reflect.apply,
  1518. _HTMLScriptElement = root.HTMLScriptElement,
  1519. _HTMLImageElement = root.HTMLImageElement;
  1520. let _get_tagName = _call.bind(_getOwnPropertyDescriptor(root.Element.prototype, 'tagName').get),
  1521. _get_scr_src = _call.bind(_getOwnPropertyDescriptor(_HTMLScriptElement.prototype, 'src').get),
  1522. _get_img_src = _call.bind(_getOwnPropertyDescriptor(_HTMLImageElement.prototype, 'src').get);
  1523. let _get_src = node => {
  1524. if (node instanceof _HTMLScriptElement)
  1525. return _get_scr_src(node);
  1526. if (node instanceof _HTMLImageElement)
  1527. return _get_img_src(node);
  1528. return void 0
  1529. };
  1530. let _onerror = _getOwnPropertyDescriptor(root.HTMLElement.prototype, 'onerror'),
  1531. _set_onerror = _call.bind(_onerror.set);
  1532. _onerror.get = function() {
  1533. return scriptMap.get(this) || null;
  1534. };
  1535. _onerror.set = function(callback) {
  1536. if (typeof callback !== 'function') {
  1537. scriptMap.delete(this);
  1538. _set_onerror(this, callback);
  1539. return;
  1540. }
  1541. scriptMap.set(this, callback);
  1542. _set_onerror(this, function() {
  1543. let src = _get_src(this);
  1544. if (isBlocked(src)) {
  1545. _console.warn(`Blocked "onerror" callback from ${_get_tagName(this)}: ${src}`);
  1546. return;
  1547. }
  1548. _Reflect_apply(scriptMap.get(this), this, arguments);
  1549. });
  1550. };
  1551. _defineProperty(root.HTMLElement.prototype, 'onerror', _onerror);
  1552. }
  1553. // Simplistic WebSocket wrapper for Maxthon and Firefox before v58
  1554. WSWrap: { // once again seems required in Google Chrome and similar browsers due to zmctrack.net -_-
  1555. if (true /*/Maxthon/.test(navigator.appVersion) ||
  1556. 'InstallTrigger' in win && 'StopIteration' in win*/) {
  1557. let _ws = _getOwnPropertyDescriptor(root, 'WebSocket');
  1558. if (!_ws)
  1559. break WSWrap;
  1560. _ws.value = new Proxy(_ws.value, {
  1561. construct: (ws, args) => {
  1562. if (isBlocked(args[0])) {
  1563. _console.log('Blocked WS connection:', args[0]);
  1564. return {};
  1565. }
  1566. return new ws(...args);
  1567. }
  1568. });
  1569. _defineProperty(root, 'WebSocket', _ws);
  1570. }
  1571. }
  1572. untrustedClick: {
  1573. // Block popular method to open a new window in Google Chrome by dispatching a custom click
  1574. // event on a newly created anchor with _blank target. Untrusted events must not open new windows.
  1575. let _dispatchEvent = _call.bind(root.EventTarget.prototype.dispatchEvent);
  1576. root.EventTarget.prototype.dispatchEvent = function dispatchEvent(e) {
  1577. if (!e.isTrusted && e.type === 'click' && e.constructor.name === 'MouseEvent' &&
  1578. !this.parentNode && this.tagName === 'A' && this.target[0] === '_') {
  1579. _console.log('Blocked dispatching a click event on a parentless anchor:', this);
  1580. return;
  1581. }
  1582. return _dispatchEvent(this, ...arguments);
  1583. };
  1584. }
  1585. // XHR Wrapper
  1586. let _proto = void 0;
  1587. try {
  1588. _proto = root.XMLHttpRequest.prototype;
  1589. } catch(ignore) {
  1590. return;
  1591. };
  1592. // blacklist of domains where all third-party requests are ignored
  1593. let ondomains = /(^|[/.@])oane\.ws($|[:/])/i;
  1594. // highly suspicious URLs
  1595. let suspicious = /^(https?:)?\/\/(csp-)?([a-z0-9]{6}){1,2}\.ru\//i;
  1596. let on_get_ban = /^(https?:)?\/\/(csp-)?([a-z0-9]{6}){1,2}\.ru\/([a-z0-9/]{40,}|[a-z0-9]{8,}|ad\/banner\/.+)$/i;
  1597. let on_post_ban = /^(https?:)?\/\/(csp-)?([a-z0-9]{6}){1,2}\.ru\/([a-z0-9]{6,})$/i;
  1598. 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;
  1599. let more_y_direct = /^(https?:)?\/\/([^.]+\.)??(echo\.msk|kakprosto|liveinternet|razlozhi)\.ru\/(.{290,}|[a-z0-9/_-]{100,})$/i;
  1600. let whitelist = /^(https?:)?\/\/yandex\.ru\/yobject$/;
  1601.  
  1602. let blockedUrls = new Set();
  1603. function checkRequest(fname, method, url) {
  1604. if ((isBlocked(url) ||
  1605. ondomains.test(location.hostname) && !ondomains.test(url) ||
  1606. method === 'GET' && on_get_ban.test(url) ||
  1607. method === 'POST' && on_post_ban.test(url) ||
  1608. yandex_direct.test(url) || more_y_direct.test(url)) && !whitelist.test(url)) {
  1609. if (!blockedUrls.has(url)) // don't repeat log if the same URL were blocked more than once
  1610. _console.warn(`Blocked ${fname} ${method} request:`, url);
  1611. blockedUrls.add(url);
  1612. return true;
  1613. }
  1614. if (suspicious.test(url))
  1615. _console.warn(`Suspicious ${fname} ${method} request:`, url);
  1616. return false;
  1617. }
  1618.  
  1619. // workaround for a broken weather mini-map on Yandex
  1620. let skip_xhr_check = false;
  1621. if (root.location.hostname.startsWith('yandex.') &&
  1622. root.location.pathname.startsWith('/pogoda/') ||
  1623. root.location.hostname.endsWith('.kakprosto.ru'))
  1624. skip_xhr_check = true;
  1625.  
  1626. let xhrStopList = new WeakSet();
  1627. let _open = root.Function.prototype.apply.bind(_proto.open);
  1628. _proto.open = function open() {
  1629. '[native code]';
  1630. return !skip_xhr_check && checkRequest('xhr', ...arguments) ?
  1631. (xhrStopList.add(this), void 0) : _open(this, arguments);
  1632. };
  1633. ['send', 'setRequestHeader', 'getAllResponseHeaders'].forEach(
  1634. name => {
  1635. let func = _proto[name];
  1636. _proto[name] = function(...args) {
  1637. return xhrStopList.has(this) ? null : func.apply(this, args);
  1638. };
  1639. }
  1640. );
  1641. // simulate readyState === 1 for blocked requests
  1642. let _readyState = Object.getOwnPropertyDescriptor(_proto, 'readyState');
  1643. let _get_readyState = root.Function.prototype.apply.bind(_readyState.get);
  1644. _readyState.get = function() {
  1645. return xhrStopList.has(this) ? 1 : _get_readyState(this, arguments);
  1646. }
  1647. Object.defineProperty(_proto, 'readyState', _readyState);
  1648.  
  1649. let _fetch = root.Function.prototype.apply.bind(root.fetch);
  1650. root.fetch = function fetch() {
  1651. '[native code]';
  1652. let url = arguments[0];
  1653. let method = arguments[1] ? arguments[1].method : void 0;
  1654. if (arguments[0] instanceof Request) {
  1655. method = url.method;
  1656. url = url.url;
  1657. }
  1658. if (checkRequest('fetch', method, url))
  1659. return new Promise(() => null);
  1660. return _fetch(root, arguments);
  1661. };
  1662.  
  1663. let _script_src = Object.getOwnPropertyDescriptor(root.HTMLScriptElement.prototype, 'src');
  1664. let _script_src_set = root.Function.prototype.apply.bind(_script_src.set);
  1665. _script_src.set = function(src) {
  1666. return checkRequest('set', 'script.src', src) || _script_src_set(this, arguments);
  1667. };
  1668. Object.defineProperty(root.HTMLScriptElement.prototype, 'src', _script_src);
  1669. });
  1670.  
  1671. win.stop = () => {
  1672. _console.warn('window.stop() ...y tho?');
  1673. for (let sheet of _document.styleSheets)
  1674. if (sheet.disabled) {
  1675. sheet.disabled = false;
  1676. _console.log('Re-enabled:', sheet);
  1677. }
  1678. }
  1679. }, deepWrapAPI
  1680. );
  1681.  
  1682. // === Helper functions ===
  1683.  
  1684. // function to search and remove nodes by content
  1685. // selector - standard CSS selector to define set of nodes to check
  1686. // words - regular expression to check content of the suspicious nodes
  1687. // params - object with multiple extra parameters:
  1688. // .log - display log in the console
  1689. // .hide - set display to none instead of removing from the page
  1690. // .parent - parent node to remove if content is found in the child node
  1691. // .siblings - number of simling nodes to remove (excluding text nodes)
  1692. let scRemove = (node) => node.parentNode.removeChild(node);
  1693. let scHide = function(node) {
  1694. let style = _getAttribute(node, 'style') || '',
  1695. hide = ';display:none!important;';
  1696. if (style.indexOf(hide) < 0)
  1697. _setAttribute(node, 'style', style + hide);
  1698. };
  1699.  
  1700. function scissors (selector, words, scope, params) {
  1701. let logger = (...args) => { if (params.log) _console.log(...args) };
  1702. if (!scope.contains(_document.body))
  1703. logger('[s] scope', scope);
  1704. let remFunc = (params.hide ? scHide : scRemove),
  1705. iterFunc = (params.siblings > 0 ? 'nextElementSibling' : 'previousElementSibling'),
  1706. toRemove = [],
  1707. siblings;
  1708. for (let node of scope.querySelectorAll(selector)) {
  1709. // drill up to a parent node if specified, break if not found
  1710. if (params.parent) {
  1711. let old = node;
  1712. node = node.closest(params.parent);
  1713. if (node === null || node.contains(scope)) {
  1714. logger('[s] went out of scope with', old);
  1715. continue;
  1716. }
  1717. }
  1718. logger('[s] processing', node);
  1719. if (toRemove.includes(node))
  1720. continue;
  1721. if (words.test(node.innerHTML)) {
  1722. // skip node if already marked for removal
  1723. logger('[s] marked for removal');
  1724. toRemove.push(node);
  1725. // add multiple nodes if defined more than one sibling
  1726. siblings = Math.abs(params.siblings) || 0;
  1727. while (siblings) {
  1728. node = node[iterFunc];
  1729. if (!node) break; // can't go any further - exit
  1730. logger('[s] adding sibling node', node);
  1731. toRemove.push(node);
  1732. siblings -= 1;
  1733. }
  1734. }
  1735. }
  1736. let toSkip = [];
  1737. for (let node of toRemove)
  1738. if (!toRemove.every(other => other === node || !node.contains(other)))
  1739. toSkip.push(node);
  1740. if (toRemove.length)
  1741. logger(`[s] proceeding with ${params.hide?'hide':'removal'} of`, toRemove, `skip`, toSkip);
  1742. for (let node of toRemove) if (!toSkip.includes(node))
  1743. remFunc(node);
  1744. }
  1745.  
  1746. // function to perform multiple checks if ads inserted with a delay
  1747. // by default does 30 checks withing a 3 seconds unless nonstop mode specified
  1748. // also does 1 extra check when a page completely loads
  1749. // selector and words - passed dow to scissors
  1750. // params - object with multiple extra parameters:
  1751. // .log - display log in the console
  1752. // .root - selector to narrow down scope to scan;
  1753. // .observe - if true then check will be performed continuously;
  1754. // Other parameters passed down to scissors.
  1755. function gardener(selector, words, params) {
  1756. let logger = (...args) => { if (params.log) _console.log(...args) };
  1757. params = params || {};
  1758. logger(`[gardener] selector: '${selector}' detector: ${words} options: ${JSON.stringify(params)}`);
  1759. let scope;
  1760. let globalScope = [_de];
  1761. let domLoaded = false;
  1762. let getScope = root => root ? _de.querySelectorAll(root) : globalScope;
  1763. let onevent = e => {
  1764. logger(`[gardener] cleanup on ${Object.getPrototypeOf(e)} "${e.type}"`);
  1765. for (let node of scope)
  1766. scissors(selector, words, node, params);
  1767. };
  1768. let repeater = n => {
  1769. if (!domLoaded && n) {
  1770. setTimeout(repeater, 500, n - 1);
  1771. scope = getScope(params.root);
  1772. if (!scope) // exit if the root element is not present on the page
  1773. return 0;
  1774. onevent({type: 'Repeater'});
  1775. }
  1776. };
  1777. repeater(20);
  1778. _document.addEventListener(
  1779. 'DOMContentLoaded', (e) => {
  1780. domLoaded = true;
  1781. // narrow down scope to a specific element
  1782. scope = getScope(params.root);
  1783. if (!scope) // exit if the root element is not present on the page
  1784. return 0;
  1785. logger('[g] scope', scope);
  1786. // add observe mode if required
  1787. if (params.observe) {
  1788. let params = { childList:true, subtree: true };
  1789. let observer = new MutationObserver(
  1790. function(ms) {
  1791. for (let m of ms)
  1792. if (m.addedNodes.length)
  1793. onevent(m);
  1794. }
  1795. );
  1796. for (let node of scope)
  1797. observer.observe(node, params);
  1798. logger('[g] observer enabled');
  1799. }
  1800. onevent(e);
  1801. }, false);
  1802. // wait for a full page load to do one extra cut
  1803. win.addEventListener('load', onevent, false);
  1804. }
  1805.  
  1806. // wrap popular methods to open a new tab to catch specific behaviours
  1807. function createWindowOpenWrapper(openFunc) {
  1808. let _createElement = _Document.createElement,
  1809. _appendChild = _Element.appendChild,
  1810. fakeNative = (f) => (f.toString = () => `function ${f.name}() { [native code] }`);
  1811.  
  1812. let nt = new nullTools();
  1813. fakeNative(openFunc);
  1814.  
  1815. let parser = _createElement.call(_document, 'a');
  1816. let openWhitelist = (url, parent) => {
  1817. parser.href = url;
  1818. return parser.hostname === 'www.imdb.com' || parser.hostname === 'www.kinopoisk.ru' ||
  1819. parent.hostname === 'radikal.ru' && url === void 0;
  1820. };
  1821.  
  1822. let redefineOpen = (root) => {
  1823. if ('open' in root) {
  1824. let _open = root.open.bind(root);
  1825. nt.define(root, 'open', (...args) => {
  1826. if (openWhitelist(args[0], location)) {
  1827. _console.log('Whitelisted popup:', ...args);
  1828. return _open(...args);
  1829. }
  1830. return openFunc(...args);
  1831. });
  1832. }
  1833. };
  1834. redefineOpen(win);
  1835.  
  1836. function createElement() {
  1837. '[native code]';
  1838. let el = _createElement.apply(this, arguments);
  1839. // redefine window.open in first-party frames
  1840. if (el instanceof HTMLIFrameElement || el instanceof HTMLObjectElement)
  1841. el.addEventListener('load', (e) => {
  1842. try {
  1843. redefineOpen(e.target.contentWindow);
  1844. } catch(ignore) {}
  1845. }, false);
  1846. return el;
  1847. }
  1848. fakeNative(createElement);
  1849.  
  1850. let redefineCreateElement = (obj) => {
  1851. for (let root of [obj.document, _Document]) if ('createElement' in root)
  1852. nt.define(root, 'createElement', createElement);
  1853. };
  1854. redefineCreateElement(win);
  1855.  
  1856. // wrap window.open in newly added first-party frames
  1857. _Element.appendChild = function appendChild() {
  1858. '[native code]';
  1859. let el = _appendChild.apply(this, arguments);
  1860. if (el instanceof HTMLIFrameElement)
  1861. try {
  1862. redefineOpen(el.contentWindow);
  1863. redefineCreateElement(el.contentWindow);
  1864. } catch(ignore) {}
  1865. return el;
  1866. };
  1867. fakeNative(_Element.appendChild);
  1868. }
  1869.  
  1870. // Function to catch and block various methods to open a new window with 3rd-party content.
  1871. // Some advertisement networks went way past simple window.open call to circumvent default popup protection.
  1872. // This funciton blocks window.open, ability to restore original window.open from an IFRAME object,
  1873. // ability to perform an untrusted (not initiated by user) click on a link, click on a link without a parent
  1874. // node or simply a link with piece of javascript code in the HREF attribute.
  1875. function preventPopups() {
  1876. // call sandbox-me if in iframe and not whitelisted
  1877. if (inIFrame) {
  1878. win.top.postMessage({ name: 'sandbox-me', href: win.location.href }, '*');
  1879. return;
  1880. }
  1881.  
  1882. scriptLander(() => {
  1883. let nt = new nullTools({log:true});
  1884. let open = (...args) => {
  1885. '[native code]';
  1886. _console.warn('Site attempted to open a new window', ...args);
  1887. return {
  1888. document: nt.proxy({
  1889. write: nt.func({}, 'write'),
  1890. writeln: nt.func({}, 'writeln')
  1891. }),
  1892. location: nt.proxy({})
  1893. };
  1894. };
  1895.  
  1896. createWindowOpenWrapper(open);
  1897.  
  1898. _console.log('Popup prevention enabled.');
  1899. }, nullTools, createWindowOpenWrapper);
  1900. }
  1901.  
  1902. // Helper function to close background tab if site opens itself in a new tab and then
  1903. // loads a 3rd-party page in the background one (thus performing background redirect).
  1904. function preventPopunders() {
  1905. // create "close_me" event to call high-level window.close()
  1906. let eventName = `close_me_${Math.random().toString(36).substr(2)}`;
  1907. let callClose = () => {
  1908. _console.log('close call');
  1909. window.close();
  1910. };
  1911. window.addEventListener(eventName, callClose, true);
  1912.  
  1913. scriptLander(() => {
  1914. // get host of a provided URL with help of an anchor object
  1915. // unfortunately new URL(url, window.location) generates wrong URL in some cases
  1916. let parseURL = _document.createElement('A');
  1917. let getHost = url => {
  1918. parseURL.href = url;
  1919. return parseURL.hostname
  1920. };
  1921. // site went to a new tab and attempts to unload
  1922. // call for high-level close through event
  1923. let closeWindow = () => window.dispatchEvent(new CustomEvent(eventName, {}));
  1924. // check is URL local or goes to different site
  1925. let isLocal = (url) => {
  1926. if (url === location.pathname || url === location.href)
  1927. return true; // URL points to current pathname or full address
  1928. let host = getHost(url);
  1929. let site = location.hostname;
  1930. return host !== '' && // URLs with unusual protocol may have empty 'host'
  1931. (site === host || site.endsWith(`.${host}`) || host.endsWith(`.${site}`));
  1932. };
  1933.  
  1934. let _open = window.open.bind(window);
  1935. let open = (...args) => {
  1936. '[native code]';
  1937. let url = args[0];
  1938. if (url && isLocal(url))
  1939. window.addEventListener('beforeunload', closeWindow, true);
  1940. return _open(...args);
  1941. };
  1942.  
  1943. createWindowOpenWrapper(open);
  1944.  
  1945. _console.log("Background redirect prevention enabled.");
  1946. }, `let eventName="${eventName}"`, nullTools, createWindowOpenWrapper);
  1947. }
  1948.  
  1949. // Mix between check for popups and popunders
  1950. // Significantly more agressive than both and can't be used as universal solution
  1951. function preventPopMix() {
  1952. if (inIFrame) {
  1953. win.top.postMessage({ name: 'sandbox-me', href: win.location.href }, '*');
  1954. return;
  1955. }
  1956.  
  1957. // create "close_me" event to call high-level window.close()
  1958. let eventName = `close_me_${Math.random().toString(36).substr(2)}`;
  1959. let callClose = () => {
  1960. _console.log('close call');
  1961. window.close();
  1962. };
  1963. window.addEventListener(eventName, callClose, true);
  1964.  
  1965. scriptLander(() => {
  1966. let _open = window.open,
  1967. parseURL = _document.createElement('A');
  1968. // get host of a provided URL with help of an anchor object
  1969. // unfortunately new URL(url, window.location) generates wrong URL in some cases
  1970. let getHost = (url) => {
  1971. parseURL.href = url;
  1972. return parseURL.host;
  1973. };
  1974. // site went to a new tab and attempts to unload
  1975. // call for high-level close through event
  1976. let closeWindow = () => {
  1977. _open(window.location,'_self');
  1978. window.dispatchEvent(new CustomEvent(eventName, {}));
  1979. };
  1980. // check is URL local or goes to different site
  1981. function isLocal(url) {
  1982. let loc = window.location;
  1983. if (url === loc.pathname || url === loc.href)
  1984. return true; // URL points to current pathname or full address
  1985. let host = getHost(url),
  1986. site = loc.host;
  1987. if (host === '')
  1988. return false; // URLs with unusual protocol may have empty 'host'
  1989. if (host.length > site.length)
  1990. [site, host] = [host, site];
  1991. return site.includes(host, site.length - host.length);
  1992. }
  1993.  
  1994. // add check for redirect for 5 seconds, then disable it
  1995. function checkRedirect() {
  1996. window.addEventListener('beforeunload', closeWindow, true);
  1997. setTimeout(closeWindow=>window.removeEventListener('beforeunload', closeWindow, true), 5000, closeWindow);
  1998. }
  1999.  
  2000. function open(url, name) {
  2001. '[native code]';
  2002. if (url && isLocal(url) && (!name || name === '_blank')) {
  2003. _console.warn('Suspicious local new window', arguments);
  2004. checkRedirect();
  2005. return _open.apply(this, arguments);
  2006. }
  2007. _console.warn('Blocked attempt to open a new window', arguments);
  2008. return {
  2009. document: {
  2010. write: () => {},
  2011. writeln: () => {}
  2012. }
  2013. };
  2014. }
  2015.  
  2016. function clickHandler(e) {
  2017. let link = e.target,
  2018. url = link.href||'';
  2019. if (e.targetParentNode && e.isTrusted || link.target !== '_blank') {
  2020. _console.log('Link', link, 'were created dinamically, but looks fine.');
  2021. return true;
  2022. }
  2023. if (isLocal(url) && link.target === '_blank') {
  2024. _console.log('Suspicious local link', link);
  2025. checkRedirect();
  2026. return;
  2027. }
  2028. _console.log('Blocked suspicious click on a link', link);
  2029. e.stopPropagation();
  2030. e.preventDefault();
  2031. }
  2032.  
  2033. createWindowOpenWrapper(open, clickHandler);
  2034.  
  2035. _console.log("Mixed popups prevention enabled.");
  2036. }, `let eventName="${eventName}"`, createWindowOpenWrapper);
  2037. }
  2038. // External listener for case when site known to open popups were loaded in iframe
  2039. // It will sandbox any iframe which will send message 'forbid.popups' (preventPopups sends it)
  2040. // Some sites replace frame's window.location with data-url to run in clean context
  2041. if (!inIFrame) window.addEventListener(
  2042. 'message', function(e) {
  2043. if (!e.data || e.data.name !== 'sandbox-me' || !e.data.href)
  2044. return;
  2045. let src = e.data.href;
  2046. for (let frame of _document.querySelectorAll('iframe'))
  2047. if (frame.contentWindow === e.source) {
  2048. if (frame.hasAttribute('sandbox')) {
  2049. if (!frame.sandbox.contains('allow-popups'))
  2050. return; // exit frame since it's already sandboxed and popups are blocked
  2051. // remove allow-popups if frame already sandboxed
  2052. frame.sandbox.remove('allow-popups');
  2053. } else
  2054. // set sandbox mode for troublesome frame and allow scripts, forms and a few other actions
  2055. // technically allowing both scripts and same-origin allows removal of the sandbox attribute,
  2056. // but to apply content must be reloaded and this script will re-apply it in the result
  2057. frame.setAttribute('sandbox','allow-forms allow-scripts allow-presentation allow-top-navigation allow-same-origin');
  2058. _console.log('Disallowed popups from iframe', frame);
  2059.  
  2060. // reload frame content to apply restrictions
  2061. if (!src) {
  2062. src = frame.src;
  2063. _console.log('Unable to get current iframe location, reloading from src', src);
  2064. } else
  2065. _console.log('Reloading iframe with URL', src);
  2066. frame.src = 'about:blank';
  2067. frame.src = src;
  2068. }
  2069. }, false
  2070. );
  2071.  
  2072. let evalPatternYandex = /{exports:{},id:r,loaded:!1}|containerId:(.|\r|\n)+params:/;
  2073. let evalPatternGeneric = /_0x|location\s*?=|location.href\s*?=|location.assign\(|open\(/i;
  2074. function selectiveEval(...patterns) {
  2075. if (patterns.length === 0)
  2076. patterns.push(evalPatternGeneric);
  2077. scriptLander(() => {
  2078. let _eval_def = Object.getOwnPropertyDescriptor(win, 'eval');
  2079. if (!_eval_def || !_eval_def.value) {
  2080. _console.warn('Unable to wrap window.eval.', _eval_def);
  2081. return;
  2082. }
  2083. let _eval_val = _eval_def.value;
  2084. _eval_def.value = function(...args) {
  2085. if (patterns.some(pattern => pattern.test(args[0]))) {
  2086. _console.warn(`Skipped eval of ${args[0].slice(0, 512)}\u2026`);
  2087. return null;
  2088. }
  2089. try {
  2090. return _eval_val.apply(this, args);
  2091. } catch(e) {
  2092. _console.log('Crash source:', args[0]);
  2093. throw e;
  2094. }
  2095. };
  2096. Object.defineProperty(win, 'eval', _eval_def);
  2097. }, `let patterns = [${patterns}];`);
  2098. }
  2099.  
  2100. // hides cookies by pattern and attempts to remove them if they already set
  2101. // also prevents setting new versions of such cookies
  2102. function selectiveCookies(scPattern, scPaths = []) {
  2103. scriptLander(() => {
  2104. let ga = '|_g(at?|id)|__utm[a-z]'; // Google Analytics Cookies
  2105. if (scPattern.startsWith('~default|')) {
  2106. scPattern = scPattern.replace('~default|', '');
  2107. ga = '';
  2108. }
  2109. scPattern = new RegExp(`(^|;\\s?)(${scPattern}${ga})($|=)`);
  2110. if (isFirefox && scPaths.length)
  2111. scPaths = scPaths.map(path => `${path}/`);
  2112. scPaths.push('/');
  2113. let _doc_proto = ('cookie' in _Document) ? _Document : Object.getPrototypeOf(_document);
  2114. let _cookie = Object.getOwnPropertyDescriptor(_doc_proto, 'cookie');
  2115. if (_cookie) {
  2116. let _set_cookie = Function.prototype.call.bind(_cookie.set);
  2117. let _get_cookie = Function.prototype.call.bind(_cookie.get);
  2118. let expireDate = 'Thu, 01 Jan 1970 00:00:01 UTC';
  2119. let expireAge = '-99999999';
  2120. let expireBase = `=;expires=${expireDate};Max-Age=${expireAge}`;
  2121. let expireAttempted = {};
  2122. // expire is called from cookie getter and doesn't know exact parameters used to set cookies present there
  2123. // so, it will use path=/ by default if scPaths wasn't set and attempt to set cookies on all parent domains
  2124. let expire = (cookie, that) => {
  2125. let domain = that.location.hostname.split('.'),
  2126. name = cookie.replace(/=.*/,'');
  2127. scPaths.forEach(path =>_set_cookie(that, `${name}${expireBase};path=${path}`));
  2128. while (domain.length > 1) {
  2129. try {
  2130. scPaths.forEach(
  2131. path => _set_cookie(that, `${name}${expireBase};domain=${domain.join('.')};path=${path}`)
  2132. );
  2133. } catch(e) { _console.warn(e); }
  2134. domain.shift();
  2135. }
  2136. expireAttempted[name] = true;
  2137. _console.log('Removing existing cookie:', cookie);
  2138. };
  2139. // skip setting unwanted cookies
  2140. _cookie.set = function(value) {
  2141. if (scPattern.test(value)) {
  2142. _console.warn('Ignored cookie:', value);
  2143. // try to remove same cookie if it already exists using exact values from the set string
  2144. if (scPattern.test(_get_cookie(this))) {
  2145. let parts = value.split(/;\s?/),
  2146. name = parts[0].replace(/=.*/,''),
  2147. newParts = [`${name}=`, `expires=${expireDate}`, `Max-Age=${expireAge}`],
  2148. skip = [name, 'expires', 'Max-Age'];
  2149. for (let part of parts)
  2150. if (!skip.includes(part.replace(/=.*/,'')))
  2151. newParts.push(part);
  2152. try {
  2153. _set_cookie(this, newParts.join(';'));
  2154. } catch(e) { _console.warn(e); }
  2155. _console.log('Removing existing cookie:', name);
  2156. }
  2157. return;
  2158. }
  2159. return _set_cookie(this, value);
  2160. };
  2161. // hide unwanted cookies from site
  2162. _cookie.get = function() {
  2163. let res = _get_cookie(this);
  2164. if (scPattern.test(res)) {
  2165. let stack = [];
  2166. for (let cookie of res.split(/;\s?/))
  2167. if (!scPattern.test(cookie))
  2168. stack.push(cookie);
  2169. else {
  2170. let name = cookie.replace(/=.*/,'');
  2171. if (expireAttempted[name]) {
  2172. _console.log('Unable to expire:', cookie);
  2173. expireAttempted[name] = false;
  2174. }
  2175. if (!(name in expireAttempted))
  2176. expire(cookie, this);
  2177. }
  2178. res = stack.join('; ');
  2179. }
  2180. return res;
  2181. };
  2182. Object.defineProperty(_doc_proto, 'cookie', _cookie);
  2183. }
  2184. _console.log('Active cookies:', document.cookie);
  2185. }, `let scPattern = "${scPattern}", scPaths = ${JSON.stringify(scPaths)}, isFirefox = ${isFirefox};`);
  2186. }
  2187.  
  2188. /*{ // simple toString wrapper, might be useful to prevent detection
  2189. '[native code]';
  2190. let _toString = Function.prototype.apply.bind(Function.prototype.toString);
  2191. let baseText = Function.prototype.toString.toString();
  2192. let protect = new WeakSet();
  2193. protect.add(_Document.createElement);
  2194. protect.add(_Node.appendChild);
  2195. protect.add(_Node.removeChild);
  2196. win.Function.prototype.toString = function() {
  2197. if (protect.has(this))
  2198. return baseText.replace('toString', this.name);
  2199. return _toString(this);
  2200. };
  2201. protect.add(Function.prototype.toString);
  2202. }*/
  2203.  
  2204. // Locates a node with specific text in Russian
  2205. // Uses table of substitutions for similar letters
  2206. let selectNodeByTextContent = (()=> {
  2207. let subs = {
  2208. // english & greek
  2209. 'А': 'AΑ', 'В': 'BΒ', 'Г':'Γ',
  2210. 'Е': 'EΕ', 'З': '3', 'К':'KΚ',
  2211. 'М': 'MΜ', 'Н': 'HΗ', 'О':'OΟ',
  2212. 'П': 'Π', 'Р': 'PΡ', 'С':'C',
  2213. 'Т': 'T', 'Ф': 'Φ', 'Х':'XΧ'
  2214. }
  2215. let regExpBuilder = text => new RegExp(
  2216. text.toUpperCase()
  2217. .split('')
  2218. .map(function(e){
  2219. return `${e in subs ? `[${e}${subs[e]}]` : (e === ' ' ? '\\s+' : e)}[\u200b\u200c\u200d]*`;
  2220. })
  2221. .join(''),
  2222. 'i');
  2223. let reMap = {};
  2224. return (re, opts = { root: _document.body }) => {
  2225. if (!re.test) {
  2226. if (!reMap[re])
  2227. reMap[re] = regExpBuilder(re);
  2228. re = reMap[re];
  2229. }
  2230.  
  2231. for (let child of opts.root.children)
  2232. if (re.test(child.textContent)) {
  2233. if (opts.shallow)
  2234. return child;
  2235. opts.root = child;
  2236. return selectNodeByTextContent(re, opts) || child;
  2237. }
  2238. }
  2239. })();
  2240.  
  2241. // === Scripts for specific domains ===
  2242.  
  2243. let scripts = {};
  2244. // prevent popups and redirects block
  2245. // Popups
  2246. scripts.preventPopups = {
  2247. other: [
  2248. 'biqle.ru',
  2249. 'chaturbate.com',
  2250. 'dfiles.ru',
  2251. 'eporner.eu',
  2252. 'hentaiz.org',
  2253. 'mirrorcreator.com',
  2254. 'online-multy.ru',
  2255. 'radikal.ru', 'rumedia.ws',
  2256. 'tapehub.tech', 'thepiratebay.org',
  2257. 'unionpeer.com',
  2258. 'zippyshare.com'
  2259. ],
  2260. now: preventPopups
  2261. };
  2262. // Popunders (background redirect)
  2263. scripts.preventPopunders = {
  2264. other: [
  2265. 'lostfilm-online.ru',
  2266. 'mediafire.com', 'megapeer.org', 'megapeer.ru',
  2267. 'perfectgirls.net'
  2268. ],
  2269. now: preventPopunders
  2270. };
  2271. // PopMix (both types of popups encountered on site)
  2272. scripts['openload.co'] = {
  2273. other: ['oload.tv', 'oload.info'],
  2274. now: () => {
  2275. let nt = new nullTools();
  2276. nt.define(win, 'CNight', win.CoinHive);
  2277. if (location.pathname.startsWith('/embed/')) {
  2278. nt.define(win, 'BetterJsPop', {
  2279. add: ((a, b) => _console.warn('BetterJsPop.add', a, b)),
  2280. config: ((o) => _console.warn('BetterJsPop.config', o)),
  2281. Browser: { isChrome: true }
  2282. });
  2283. nt.define(win, 'isSandboxed', nt.func(null));
  2284. nt.define(win, 'adblock', false);
  2285. nt.define(win, 'adblock2', false);
  2286. } else preventPopMix();
  2287. }
  2288. };
  2289. scripts['turbobit.net'] = preventPopMix;
  2290.  
  2291. scripts['tapochek.net'] = () => {
  2292. // workaround for moradu.com/apu.php load error handler script, not sure which ad network is this
  2293. let _appendChild = Object.getOwnPropertyDescriptor(_Node, 'appendChild');
  2294. let _appendChild_value = _appendChild.value;
  2295. _appendChild.value = function appendChild(node) {
  2296. if (this === _document.body)
  2297. if ((node instanceof HTMLScriptElement || node instanceof HTMLStyleElement) &&
  2298. /^https?:\/\/[0-9a-f]{15}\.com\/\d+(\/|\.css)$/.test(node.src) ||
  2299. node instanceof HTMLDivElement && node.style.zIndex > 900000 &&
  2300. node.style.backgroundImage.includes('R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7'))
  2301. throw '...eenope!';
  2302. return _appendChild_value.apply(this, arguments);
  2303. };
  2304. Object.defineProperty(_Node, 'appendChild', _appendChild);
  2305.  
  2306. // disable window focus tricks and changing location
  2307. let focusHandlerName = /\WfocusAchieved\(/
  2308. let _toString = Function.prototype.call.bind(Function.prototype.toString);
  2309. let _setInterval = win.setInterval;
  2310. win.setInterval = (...args) => {
  2311. if (args.length && focusHandlerName.test(_toString(args[0]))) {
  2312. _console.log('skip setInterval for', ...args);
  2313. return -1;
  2314. }
  2315. return _setInterval(...args);
  2316. };
  2317. let _addEventListener = win.addEventListener;
  2318. win.addEventListener = function(...args) {
  2319. if (args.length && args[0] === 'focus' && focusHandlerName.test(_toString(args[1]))) {
  2320. _console.log('skip addEventListener for', ...args);
  2321. return void 0;
  2322. }
  2323. return _addEventListener.apply(this, args);
  2324. };
  2325.  
  2326. // generic popup prevention
  2327. preventPopups();
  2328. };
  2329.  
  2330. scripts['rustorka.com'] = {
  2331. other: ['rustorka.club', 'rustorka.lib', 'rustorka.net'],
  2332. now: () => {
  2333. selectiveEval(evalPatternGeneric, /antiadblock/);
  2334. selectiveCookies('adblock|u_count|gophp|st2|st3', ['/forum']);
  2335. scriptLander(() => {
  2336. // wrap window.open to catch a popup if it triggers
  2337. win.open = (...args) => {
  2338. _console.warn(`Site attempted to open "${args[0]}" in a new window.`);
  2339. location.replace(location.href);
  2340. return null;
  2341. };
  2342. window.addEventListener('DOMContentLoaded', () => {
  2343. let link = void 0;
  2344. _document.body.addEventListener('mousedown', e => {
  2345. link = e.target.closest('a, select, #fancybox-title-wrap');
  2346. }, false);
  2347. let _open = window.open.bind(window);
  2348. let _getAttribute = Function.prototype.call.bind(_Element.getAttribute);
  2349. win.open = (...args) => {
  2350. let url = args[0];
  2351. if (link instanceof HTMLAnchorElement) {
  2352. // third-party post links
  2353. let href = _getAttribute(link, 'href');
  2354. if (link.classList.contains('postLink') &&
  2355. !link.matches(`a[href*="${location.hostname}"]`) &&
  2356. (href === url || link.href === url))
  2357. return _open(...args);
  2358. // onclick # links
  2359. if (href === '#' && /window\.open/.test(_getAttribute(link, 'onclick')))
  2360. return _open(...args);
  2361. // force local links to load in the current window
  2362. if (href[0] === '/' || href.startsWith('./') || href.includes(`//${location.hostname}/`))
  2363. location.assign(href);
  2364. }
  2365. // list of image hostings under upload picture button (new comment)
  2366. if (link instanceof HTMLSelectElement &&
  2367. !url.includes(location.hostname) &&
  2368. link.value === url)
  2369. return _open(...args);
  2370. // open screenshot in a new window
  2371. if (link instanceof HTMLSpanElement &&
  2372. link.id === 'fancybox-title-wrap')
  2373. return _open(...args);
  2374. // looks like tabunder
  2375. if (link === null && url === location.href)
  2376. location.replace(url); // reload current page
  2377. // other cases
  2378. _console.warn(`Site attempted to open "${url}" in a new window. Source: `, link);
  2379. return {};
  2380. };
  2381. }, true);
  2382. }, nullTools)
  2383. }
  2384. };
  2385.  
  2386. // = other ======================================================================================
  2387. scripts['1tv.ru'] = {
  2388. other: ['mediavitrina.ru'],
  2389. now: () => scriptLander(() => {
  2390. let nt = new nullTools();
  2391. nt.define(win, 'EUMPAntiblockConfig', nt.proxy({url: '//www.1tv.ru/favicon.ico'}));
  2392. let disablePlugins = {
  2393. 'antiblock': false,
  2394. 'stat1tv': false
  2395. };
  2396. let _EUMPConfig = void 0;
  2397. let _EUMPConfig_set = x => {
  2398. if (x.plugins) {
  2399. x.plugins = x.plugins.filter(plugin => (plugin in disablePlugins) ? !(disablePlugins[plugin] = true) : true);
  2400. _console.warn(`Player plugins: active [${x.plugins}], disabled [${Object.keys(disablePlugins).filter(x => disablePlugins[x])}]`);
  2401. }
  2402. _EUMPConfig = x;
  2403. };
  2404. if ('EUMPConfig' in win)
  2405. _EUMPConfig_set(win.EUMPConfig);
  2406. Object.defineProperty(win, 'EUMPConfig', {
  2407. enumerable: true,
  2408. get: () => _EUMPConfig,
  2409. set: _EUMPConfig_set
  2410. });
  2411. }, nullTools)
  2412. };
  2413.  
  2414. scripts['2picsun.ru'] = {
  2415. other: [
  2416. 'pics2sun.ru', '3pics-img.ru'
  2417. ],
  2418. now: () => {
  2419. Object.defineProperty(navigator, 'userAgent', {value: 'googlebot'});
  2420. }
  2421. };
  2422.  
  2423. scripts['4pda.ru'] = {
  2424. now: () => {
  2425. // https://greasyfork.org/en/scripts/14470-4pda-unbrender
  2426. let isForum = location.pathname.startsWith('/forum/'),
  2427. remove = node => (node && node.parentNode.removeChild(node)),
  2428. hide = node => (node && (node.style.display = 'none'));
  2429.  
  2430. // clean a page
  2431. window.addEventListener(
  2432. 'DOMContentLoaded', function() {
  2433. let width = () => window.innerWidth || _de.clientWidth || _document.body.clientWidth || 0;
  2434. let height = () => window.innerHeight || _de.clientHeight || _document.body.clientHeight || 0;
  2435.  
  2436. HeaderAds: {
  2437. // hide ads above HEADER
  2438. let header = _document.querySelector('.drop-search');
  2439. if (!header) {
  2440. _console.warn('Unable to locate header element');
  2441. break HeaderAds;
  2442. }
  2443. header = header.parentNode.parentNode;
  2444. for (let itm of header.parentNode.children)
  2445. if (itm !== header)
  2446. hide(itm);
  2447. else break;
  2448. }
  2449.  
  2450. if (isForum) {
  2451. let itm = _document.querySelector('#logostrip');
  2452. if (itm)
  2453. remove(itm.parentNode.nextSibling);
  2454. // clear background in the download frame
  2455. if (location.pathname.startsWith('/forum/dl/')) {
  2456. let setBackground = node => _setAttribute(
  2457. node,
  2458. 'style', (_getAttribute(node, 'style') || '') +
  2459. ';background-color:#4ebaf6!important'
  2460. );
  2461. setBackground(_document.body);
  2462. for (let itm of _document.querySelectorAll('body > div'))
  2463. if (!itm.querySelector('.dw-fdwlink, .content') && !itm.classList.contains('footer'))
  2464. remove(itm);
  2465. else
  2466. setBackground(itm);
  2467. }
  2468. // exist from DOMContentLoaded since the rest is not for forum
  2469. return;
  2470. }
  2471.  
  2472. FixNavMenu: {
  2473. // restore DevDB link in the navigation
  2474. let itm = _document.querySelector('#nav li a[href$="/devdb/"]')
  2475. if (!itm) {
  2476. _console.warn('Unable to locate navigation menu');
  2477. break FixNavMenu;
  2478. }
  2479. itm.closest('li').style.display = 'block';
  2480. // hide ad link from the navigation
  2481. hide(_document.querySelector('#nav li a[data-dotrack]'));
  2482. }
  2483. SidebarAds: {
  2484. // remove ads from sidebar
  2485. let aside = _document.querySelectorAll('[class]:not([id]) > [id]:not([class]) > :first-child + :last-child');
  2486. if (!aside.length) {
  2487. _console.warn('Unable to locate sidebar');
  2488. break SidebarAds;
  2489. }
  2490. let post;
  2491. for (let side of aside) {
  2492. _console.log('Processing potential sidebar:', side);
  2493. for (let itm of Array.from(side.children)) {
  2494. post = itm.classList.contains('post');
  2495. if (itm.querySelector('iframe') && !post)
  2496. remove(itm);
  2497. if (itm.querySelector('script, a[target="_blank"] > img') && !post || !itm.children.length)
  2498. hide(itm);
  2499. }
  2500. }
  2501. }
  2502.  
  2503. _document.body.setAttribute('style', (_document.body.getAttribute('style')||'')+';background-color:#E6E7E9!important');
  2504.  
  2505. let extra = 'background-image:none!important;background-color:transparent!important',
  2506. fakeStyles = new WeakMap(),
  2507. styleProxy = {
  2508. get: (target, prop) => fakeStyles.get(target)[prop] || target[prop],
  2509. set: function(target, prop, value) {
  2510. let fakeStyle = fakeStyles.get(target);
  2511. ((prop in fakeStyle) ? fakeStyle : target)[prop] = value;
  2512. return true;
  2513. }
  2514. };
  2515. for (let itm of _document.querySelectorAll('[id]:not(A), A')) {
  2516. if (!(itm.offsetWidth > 0.95 * width() &&
  2517. itm.offsetHeight > 0.85 * height()))
  2518. continue;
  2519. if (itm.tagName !== 'A') {
  2520. fakeStyles.set(itm.style, {
  2521. 'backgroundImage': itm.style.backgroundImage,
  2522. 'backgroundColor': itm.style.backgroundColor
  2523. });
  2524.  
  2525. try {
  2526. Object.defineProperty(itm, 'style', {
  2527. value: new Proxy(itm.style, styleProxy),
  2528. enumerable: true
  2529. });
  2530. } catch (e) {
  2531. _console.log('Unable to protect style property.', e);
  2532. }
  2533.  
  2534. _setAttribute(itm, 'style', `${(_getAttribute(itm, 'style') || '')};${extra}`);
  2535. }
  2536. if (itm.tagName === 'A')
  2537. _setAttribute(itm, 'style', 'display:none!important');
  2538. }
  2539. }
  2540. );
  2541. }
  2542. };
  2543.  
  2544. scripts['adhands.ru'] = () => scriptLander(() => {
  2545. let nt = new nullTools();
  2546. try {
  2547. let _adv;
  2548. Object.defineProperty(win, 'adv', {
  2549. get: () => _adv,
  2550. set: (v) => {
  2551. _console.log('Blocked advert on adhands.ru.');
  2552. nt.define(v, 'advert', '');
  2553. _adv = v;
  2554. }
  2555. });
  2556. } catch (ignore) {
  2557. if (!win.adv)
  2558. _console.log('Unable to locate advert on adhands.ru.');
  2559. else {
  2560. _console.log('Blocked advert on adhands.ru.');
  2561. nt.define(win.adv, 'advert', '');
  2562. }
  2563. }
  2564. }, nullTools);
  2565.  
  2566. scripts['all-episodes.tv'] = () => {
  2567. let nt = new nullTools();
  2568. nt.define(win, 'perX1', 2);
  2569. createStyle('#advtss, #ad3, a[href*="/ad.admitad.com/"] { display:none!important }');
  2570. };
  2571.  
  2572. scripts['allhentai.ru'] = () => {
  2573. selectiveEval();
  2574. preventPopups();
  2575. scriptLander(() => {
  2576. let _onerror = Object.getOwnPropertyDescriptor(HTMLElement.prototype, 'onerror');
  2577. if (!_onerror)
  2578. return;
  2579. _onerror.set = (...args) => _console.log(args[0].toString());
  2580. Object.defineProperty(HTMLElement.prototype, 'onerror', _onerror);
  2581. });
  2582. };
  2583.  
  2584. scripts['allmovie.pro'] = {
  2585. other: ['rufilmtv.org'],
  2586. dom: function() {
  2587. // pretend to be Android to make site use different played for ads
  2588. if (isSafari)
  2589. return;
  2590. Object.defineProperty(navigator, 'userAgent', {
  2591. get: function(){
  2592. 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';
  2593. },
  2594. enumerable: true
  2595. });
  2596. }
  2597. };
  2598.  
  2599. scripts['anidub-online.ru'] = {
  2600. other: ['anime.anidub.com', 'online.anidub.com'],
  2601. dom: function() {
  2602. if (win.ogonekstart1)
  2603. win.ogonekstart1 = () => _console.log("Fire in the hole!");
  2604. },
  2605. now: () => createStyle([
  2606. '.background {background: none!important;}',
  2607. '.background > script + div,'+
  2608. '.background > script ~ div:not([id]):not([class]) + div[id][class]'+
  2609. '{display:none!important}'
  2610. ])
  2611. };
  2612.  
  2613. scripts['audioportal.su'] = {
  2614. now: () => createStyle('#blink2 { display: none !important }'),
  2615. dom: () => {
  2616. let links = _document.querySelectorAll('a[onclick*="clickme("]');
  2617. if (!links) return;
  2618. for (let link of links)
  2619. clickme(link);
  2620. }
  2621. };
  2622.  
  2623. scripts['avito.ru'] = () => selectiveCookies('abp|bltsr|cmtchd|crookie|is_adblock');
  2624.  
  2625. scripts['di.fm'] = () => scriptLander(() => {
  2626. let log = false;
  2627. // wrap global app object to catch registration of specific modules
  2628. let _di = void 0;
  2629. Object.defineProperty(win, 'di', {
  2630. get: () => _di,
  2631. set: vl => {
  2632. if (vl === _di)
  2633. return;
  2634. log && _console.log('di =', vl);
  2635. _di = new Proxy(vl, {
  2636. set: (di, name, vl) => {
  2637. if (vl === di[name])
  2638. return true;
  2639. if (name === 'app') {
  2640. log && _console.log('di.app =', vl);
  2641. if ('module' in vl)
  2642. vl.module = new Proxy(vl.module, {
  2643. apply: (module, that, args) => {
  2644. if (/Wall|Banner|Detect|WebplayerApp\.Ads/.test(args[0])) {
  2645. let name = args[0];
  2646. log && _console.warn('wrap', name, 'module');
  2647. if (typeof args[1] === 'function')
  2648. args[1] = new Proxy(args[1], {
  2649. apply: (fun, that, args) => {
  2650. if (args[0]) // module object
  2651. args[0].start = () => _console.log('Skipped start of', name);
  2652. return Reflect.apply(fun, that, args);
  2653. }
  2654. });
  2655. }// else log && _console.log('loading module', args[0]);
  2656. if (args[0] === 'Modals') {
  2657. log && _console.warn('wrap', name, 'module');
  2658. if (typeof args[1] === 'function')
  2659. args[1] = new Proxy(args[1], {
  2660. apply: (fun, that, args) => {
  2661. if ('commands' in args[1] && 'setHandlers' in args[1].commands &&
  2662. !Object.hasOwnProperty.call(args[1].commands, 'setHandlers')) {
  2663. let _commands = args[1].commands;
  2664. _commands.setHandlers = new Proxy(_commands.setHandlers, {
  2665. apply: (fun, that, args) => {
  2666. for (let name in args[0])
  2667. if (name === 'modal:streaminterrupt' ||
  2668. name === 'modal:midroll')
  2669. args[0][name] = () => _console.log('Skipped', name, 'window');
  2670. delete _commands.setHandlers;
  2671. return Reflect.apply(fun, that, args);
  2672. }
  2673. });
  2674. }
  2675. return Reflect.apply(fun, that, args);
  2676. }
  2677. });
  2678. }
  2679. return Reflect.apply(module, that, args);
  2680. }
  2681. });
  2682. }
  2683. di[name] = vl;
  2684. return true;
  2685. }
  2686. });
  2687. }
  2688. });
  2689. // don't send errorception logs
  2690. Object.defineProperty(win, 'onerror', {
  2691. set: vl => log && _console.warn('Skipped global onerror callback', vl)
  2692. });
  2693. });
  2694.  
  2695. scripts['drive2.ru'] = () => {
  2696. gardener('.c-block:not([data-metrika="recomm"]),.o-grid__item', />Реклама<\//i);
  2697. scriptLander(() => {
  2698. let _d2 = void 0;
  2699. Object.defineProperty(win, 'd2', {
  2700. get: () => _d2,
  2701. set: o => {
  2702. if (o === _d2)
  2703. return true;
  2704. _d2 = new Proxy(o, {
  2705. set: (tgt, prop, val) => {
  2706. if (['brandingRender', 'dvReveal', '__dv'].includes(prop))
  2707. val = () => null;
  2708. tgt[prop] = val;
  2709. return true;
  2710. }
  2711. });
  2712. }
  2713. });
  2714. });
  2715. };
  2716.  
  2717. scripts['echo.msk.ru'] = () => selectiveEval(evalPatternYandex, /^document\.write/, /callAdblock/);
  2718.  
  2719. scripts['fastpic.ru'] = () => {
  2720. let nt = new nullTools();
  2721. // Had to obfuscate property name to avoid triggering anti-obfuscation on greasyfork.org -_- (Exception 403012)
  2722. nt.define(win, `_0x${'4955'}`, []);
  2723. };
  2724.  
  2725. scripts['fishki.net'] = () => {
  2726. scriptLander(() => {
  2727. let nt = new nullTools();
  2728. let fishki = {};
  2729. nt.define(fishki, 'adv', nt.proxy({
  2730. afterAdblockCheck: nt.func(null),
  2731. refreshFloat: nt.func(null)
  2732. }));
  2733. nt.define(fishki, 'is_adblock', false);
  2734. nt.define(win, 'fishki', fishki);
  2735. }, nullTools);
  2736. gardener('.drag_list > .drag_element, .list-view > .paddingtop15, .post-wrap', /543769|Новости\sпартнеров|Полезная\sреклама/);
  2737. };
  2738.  
  2739. scripts['friends.in.ua'] = () => scriptLander(() => {
  2740. Object.defineProperty(win, 'need_warning', {
  2741. get: () => 0, set: () => null
  2742. });
  2743. });
  2744.  
  2745. scripts['gidonline.club'] = () => createStyle('.tray > div[style] {display: none!important}');
  2746.  
  2747. scripts['hdgo.cc'] = {
  2748. other: ['46.30.43.38', 'couber.be'],
  2749. now: () => (new MutationObserver(
  2750. (ms) => {
  2751. let m, node;
  2752. for (m of ms) for (node of m.addedNodes)
  2753. if (node.tagName instanceof HTMLScriptElement && _getAttribute(node, 'onerror') !== null)
  2754. node.removeAttribute('onerror');
  2755. }
  2756. )).observe(_document.documentElement, { childList:true, subtree: true })
  2757. };
  2758.  
  2759. scripts['gismeteo.ru'] = {
  2760. other: ['gismeteo.by', 'gismeteo.kz', 'gismeteo.ua'],
  2761. now: () => {
  2762. selectiveCookies('ab_[^=]*|bltsr|redirect|_gab');
  2763. gardener('div > script', /AdvManager/i, { observe: true, parent: 'div' })
  2764. }
  2765. };
  2766.  
  2767. scripts['hdrezka.ag'] = () => {
  2768. Object.defineProperty(win, 'ab', { value: false, enumerable: true });
  2769. gardener('div[id][onclick][onmouseup][onmousedown]', /onmouseout/i);
  2770. };
  2771.  
  2772. scripts['hqq.tv'] = () => scriptLander(() => {
  2773. // disable anti-debugging in hqq.tv player
  2774. 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);
  2775. deepWrapAPI(root => {
  2776. // skip obfuscated stuff and a few other calls
  2777. let _setInterval = root.setInterval,
  2778. _setTimeout = root.setTimeout,
  2779. _toString = root.Function.prototype.call.bind(root.Function.prototype.toString);
  2780. root.setInterval = (...args) => {
  2781. let fun = args[0];
  2782. if (fun instanceof Function) {
  2783. let text = _toString(fun),
  2784. skip = text.includes('check();') || isObfuscated(text);
  2785. _console.warn('setInterval', text, 'skip', skip);
  2786. if (skip) return -1;
  2787. }
  2788. return _setInterval.apply(this, args);
  2789. };
  2790. let wrappedST = new WeakSet();
  2791. root.setTimeout = (...args) => {
  2792. let fun = args[0];
  2793. if (fun instanceof Function) {
  2794. let text = _toString(fun),
  2795. skip = fun.name === 'check' || isObfuscated(text);
  2796. if (!wrappedST.has(fun)) {
  2797. _console.warn('setTimeout', text, 'skip', skip);
  2798. wrappedST.add(fun);
  2799. }
  2800. if (skip) return;
  2801. }
  2802. return _setTimeout.apply(this, args);
  2803. };
  2804. // skip 'debugger' call
  2805. let _eval = root.eval;
  2806. root.eval = text => {
  2807. if (typeof text === 'string' && text.includes('debugger;')) {
  2808. _console.warn('skip eval', text);
  2809. return;
  2810. }
  2811. _eval(text);
  2812. };
  2813. // Prevent RegExpt + toString trick
  2814. let _proto = void 0;
  2815. try {
  2816. _proto = root.RegExp.prototype;
  2817. } catch(ignore) {
  2818. return;
  2819. }
  2820. let _RE_tS = Object.getOwnPropertyDescriptor(_proto, 'toString');
  2821. let _RE_tSV = _RE_tS.value || _RE_tS.get();
  2822. Object.defineProperty(_proto, 'toString', {
  2823. enumerable: _RE_tS.enumerable,
  2824. configurable: _RE_tS.configurable,
  2825. get: () => _RE_tSV,
  2826. set: val => _console.warn('Attempt to change toString for', this, 'with', _toString(val))
  2827. });
  2828. });
  2829. }, deepWrapAPI);
  2830.  
  2831. scripts['hideip.me'] = {
  2832. now: () => scriptLander(() => {
  2833. let _innerHTML = Object.getOwnPropertyDescriptor(_Element, 'innerHTML');
  2834. let _set_innerHTML = _innerHTML.set;
  2835. let _innerText = Object.getOwnPropertyDescriptor(HTMLElement.prototype, 'innerText');
  2836. let _get_innerText = _innerText.get;
  2837. let div = _document.createElement('div');
  2838. _innerHTML.set = function(...args) {
  2839. _set_innerHTML.call(div, args[0].replace('i','a'));
  2840. if (args[0] && /[рp][еe]кл/.test(_get_innerText.call(div))||
  2841. /(\d\d\d?\.){3}\d\d\d?:\d/.test(_get_innerText.call(this)) ) {
  2842. _console.log('Anti-Adblock killed.');
  2843. return true;
  2844. }
  2845. _set_innerHTML.apply(this, args);
  2846. };
  2847. Object.defineProperty(_Element, 'innerHTML', _innerHTML);
  2848. Object.defineProperty(win, 'adblock', {
  2849. get: () => false,
  2850. set: () => null,
  2851. enumerable: true
  2852. });
  2853. let _$ = {};
  2854. let _$_map = new WeakMap();
  2855. let _gOPD = Object.getOwnPropertyDescriptor(Object, 'getOwnPropertyDescriptor');
  2856. let _val_gOPD = _gOPD.value;
  2857. _gOPD.value = function(...args) {
  2858. let _res = _val_gOPD.apply(this, args);
  2859. if (args[0] instanceof Window && (args[1] === '$' || args[1] === 'jQuery')) {
  2860. delete _res.get;
  2861. delete _res.set;
  2862. _res.value = win[args[1]];
  2863. }
  2864. return _res;
  2865. };
  2866. Object.defineProperty(Object, 'getOwnPropertyDescriptor', _gOPD);
  2867. let getJQWrap = (n) => {
  2868. let name = n;
  2869. return {
  2870. enumerable: true,
  2871. get: () => _$[name],
  2872. set: x => {
  2873. if (_$_map.has(x)) {
  2874. _$[name] = _$_map.get(x);
  2875. return true;
  2876. }
  2877. if (x === _$.$ || x === _$.jQuery) {
  2878. _$[name] = x;
  2879. return true;
  2880. }
  2881. _$[name] = new Proxy(x, {
  2882. apply: (t, o, args) => {
  2883. let _res = t.apply(o, args);
  2884. if (_$_map.has(_res.is))
  2885. _res.is = _$_map.get(_res.is);
  2886. else {
  2887. let _is = _res.is;
  2888. _res.is = function(...args) {
  2889. if (args[0] === ':hidden')
  2890. return false;
  2891. return _is.apply(this, args);
  2892. };
  2893. _$_map.set(_is, _res.is);
  2894. }
  2895. return _res;
  2896. }
  2897. });
  2898. _$_map.set(x, _$[name]);
  2899. return true;
  2900. }
  2901. };
  2902. };
  2903. Object.defineProperty(win, '$', getJQWrap('$'));
  2904. Object.defineProperty(win, 'jQuery', getJQWrap('jQuery'));
  2905. let _dP = Object.defineProperty;
  2906. Object.defineProperty = function(...args) {
  2907. if (args[0] instanceof Window && (args[1] === '$' || args[1] === 'jQuery'))
  2908. return void 0;
  2909. return _dP.apply(this, args);
  2910. };
  2911. })
  2912. };
  2913.  
  2914. scripts['igra-prestoloff.cx'] = () => scriptLander(() => {
  2915. let nt = new nullTools();
  2916. /*jslint evil: true */ // yes, evil, I know
  2917. let _write = _document.write.bind(_document);
  2918. /*jslint evil: false */
  2919. nt.define(_document, 'write', t => {
  2920. let id = t.match(/jwplayer\("(\w+)"\)/i);
  2921. if (id && id[1])
  2922. return _write(`<div id="${id[1]}"></div>${t}`);
  2923. return _write('');
  2924. });
  2925. });
  2926.  
  2927. scripts['imageban.ru'] = () => { Object.defineProperty(win, 'V7x1J', { get: () => null }); };
  2928.  
  2929. scripts['inoreader.com'] = () => scriptLander(() => {
  2930. let i = setInterval(() => {
  2931. if ('adb_detected' in win) {
  2932. win.adb_detected = () => adb_not_detected();
  2933. clearInterval(i);
  2934. }
  2935. }, 10);
  2936. _document.addEventListener('DOMContentLoaded', () => clearInterval(i), false);
  2937. });
  2938.  
  2939. scripts['ivi.ru'] = () => {
  2940. let _xhr_open = win.XMLHttpRequest.prototype.open;
  2941. win.XMLHttpRequest.prototype.open = function(method, url, ...args) {
  2942. if (typeof url === 'string')
  2943. if (url.endsWith('/track'))
  2944. return;
  2945. return _xhr_open.call(this, method, url, ...args);
  2946. };
  2947. let _responseText = Object.getOwnPropertyDescriptor(XMLHttpRequest.prototype, 'responseText');
  2948. let _responseText_get = _responseText.get;
  2949. _responseText.get = function() {
  2950. if (this.__responseText__)
  2951. return this.__responseText__;
  2952. let res = _responseText_get.apply(this, arguments);
  2953. let o;
  2954. try {
  2955. if (res)
  2956. o = JSON.parse(res);
  2957. } catch(ignore) {};
  2958. let changed = false;
  2959. if (o && o.result) {
  2960. if (o.result instanceof Array &&
  2961. 'adv_network_logo_url' in o.result[0]) {
  2962. o.result = [];
  2963. changed = true;
  2964. }
  2965. if (o.result.show_adv) {
  2966. o.result.show_adv = false;
  2967. changed = true;
  2968. }
  2969. }
  2970. if (changed) {
  2971. _console.log('changed response >>', o);
  2972. res = JSON.stringify(o);
  2973. }
  2974. this.__responseText__ = res;
  2975. return res;
  2976. };
  2977. Object.defineProperty(XMLHttpRequest.prototype, 'responseText', _responseText);
  2978. };
  2979.  
  2980. scripts['kinopoisk.ru'] = () => {
  2981. selectiveCookies('bltsr|cmtchd|crookie|kpunk');
  2982. // set no-branding body style and adjust other blocks on the page
  2983. let style = [
  2984. '.app__header.app__header_margin-bottom_brand, #top { margin-bottom: 20px !important }',
  2985. '.app__branding { display: none !important}'
  2986. ];
  2987. if (location.hostname === 'www.kinopoisk.ru' && !location.pathname.startsWith('/games/'))
  2988. style.push('html:not(#id), body:not(#id), .app-container { background: #d5d5d5 url(/images/noBrandBg.jpg) 50% 0 no-repeat !important }');
  2989. createStyle(style);
  2990. // catch branding and other things
  2991. let _KP = void 0;
  2992. Object.defineProperty(win, 'KP', {
  2993. get: () => _KP,
  2994. set: val => {
  2995. if (_KP === val)
  2996. return true;
  2997. _KP = new Proxy(val, {
  2998. set: (kp, name, val) => {
  2999. if (name === 'branding') {
  3000. kp[name] = new Proxy({ weborama: {} }, {
  3001. get: (kp, name) => name in kp ? kp[name] : '',
  3002. set: () => true
  3003. });
  3004. return true;
  3005. }
  3006. if (name === 'config')
  3007. val = new Proxy(val, {
  3008. set: (cfg, name, val) => {
  3009. if (name === 'anContextUrl')
  3010. return true;
  3011. if (name === 'adfoxEnabled' || name === 'hasBranding')
  3012. val = false;
  3013. if (name === 'adfoxVideoAdUrls')
  3014. val = {flash:{}, html:{}};
  3015. cfg[name] = val;
  3016. return true;
  3017. }
  3018. });
  3019. kp[name] = val;
  3020. return true;
  3021. }
  3022. });
  3023. _console.log('KP =', val);
  3024. }
  3025. });
  3026. // skip branding and some other junk
  3027. Object.defineProperty(win, 'advBlock', {
  3028. get: () => () => null,
  3029. set: () => true
  3030. });
  3031. // skip timeout check for blocked requests
  3032. let _setTimeout = Function.prototype.apply.bind(win.setTimeout);
  3033. let _toString = Function.prototype.apply.bind(Function.prototype.toString);
  3034. win.setTimeout = function(...args) {
  3035. if (args[1] === 100) {
  3036. let str = _toString(args[0]);
  3037. if (str.endsWith('{a()}') || str.endsWith('{n()}'))
  3038. return;
  3039. }
  3040. return _setTimeout(this, args);
  3041. };
  3042. };
  3043.  
  3044. scripts['kinozal-tv.appspot.com'] = {
  3045. other: ['a-dot-kinozal-tv.appspot.com', 'kinozal-me.appspot.com'],
  3046. now: () => {
  3047. document.cookie = 'MarketGidStorage=42';
  3048. document.cookie = '_ga=42';
  3049. selectiveCookies('~default|~ab');
  3050. }
  3051. };
  3052.  
  3053. scripts['korrespondent.net'] = {
  3054. now: () => scriptLander(() => {
  3055. let nt = new nullTools();
  3056. nt.define(win, 'holder', function(id) {
  3057. let div = _document.getElementById(id);
  3058. if (!div)
  3059. return;
  3060. if (div.parentNode.classList.contains('col__sidebar')) {
  3061. div.parentNode.appendChild(div);
  3062. div.style.height = '300px';
  3063. }
  3064. });
  3065. }, nullTools),
  3066. dom: () => {
  3067. for (let frame of _document.querySelectorAll('.unit-side-informer > iframe'))
  3068. frame.parentNode.style.width = '1px';
  3069. }
  3070. };
  3071.  
  3072. scripts['liveinternet.ru'] = () => selectiveEval(evalPatternYandex);
  3073.  
  3074. scripts['mail.ru'] = {
  3075. other: ['ok.ru'],
  3076. now: () => {
  3077. selectiveCookies('act|testcookie');
  3078. scriptLander(() => {
  3079. let nt = new nullTools();
  3080. // Trick to prevent mail.ru from removing 3rd-party styles
  3081. nt.define(Object.prototype, 'restoreVisibility', nt.func(null), false);
  3082. // Disable some of their counters
  3083. nt.define(win, 'rb_counter', nt.func(null, 'rb_counter'));
  3084. if (location.hostname === 'e.mail.ru')
  3085. nt.define(win, 'aRadar', nt.func(null, 'aRadar'));
  3086. else
  3087. nt.define(win, 'createRadar', nt.func(nt.func(null, 'aRadar'), 'createRadar'));
  3088.  
  3089. // Disable page scrambler on mail.ru to let extensions easily block ads there
  3090. let logger = {
  3091. apply: (target, thisArg, args) => {
  3092. let res = target.apply(thisArg, args);
  3093. _console.log(`${target._name}(`, ...args, `) >>`, res);
  3094. return res;
  3095. }
  3096. };
  3097.  
  3098. function wrapLocator(locator) {
  3099. if ('setup' in locator) {
  3100. let _setup = locator.setup;
  3101. locator.setup = function(o) {
  3102. if ('enable' in o) {
  3103. o.enable = false;
  3104. _console.log('Disable mimic mode.');
  3105. }
  3106. if ('links' in o) {
  3107. o.links = [];
  3108. _console.log('Call with empty list of sheets.');
  3109. }
  3110. return _setup.call(this, o);
  3111. };
  3112. locator.insertSheet = () => false;
  3113. locator.wrap = () => false;
  3114. }
  3115. try {
  3116. let names = [];
  3117. for (let name in locator)
  3118. if (locator[name] instanceof Function && name !== 'transform') {
  3119. locator[name]._name = "locator." + name;
  3120. locator[name] = new Proxy(locator[name], logger);
  3121. names.push(name);
  3122. }
  3123. _console.log(`[locator] wrapped properties: ${names.length ? names.join(', ') : '[empty]'}`);
  3124. } catch(e) {
  3125. _console.log(e);
  3126. }
  3127. return locator;
  3128. }
  3129.  
  3130. function defineLocator(root) {
  3131. let _locator = root.locator;
  3132. let wrapLocatorSetter = vl => _locator = wrapLocator(vl);
  3133. let loc_desc = Object.getOwnPropertyDescriptor(root, 'locator');
  3134. if (!loc_desc || loc_desc.set !== wrapLocatorSetter)
  3135. try {
  3136. Object.defineProperty(root, 'locator', {
  3137. set: wrapLocatorSetter,
  3138. get: () => _locator
  3139. });
  3140. } catch (err) {
  3141. _console.log('Unable to redefine "locator" object!!!', err);
  3142. }
  3143. if (loc_desc.value)
  3144. _locator = wrapLocator(loc_desc.value);
  3145. }
  3146.  
  3147. {
  3148. let missingCheck = {
  3149. get: (obj, name) => {
  3150. if (!(name in obj))
  3151. _console.warn(obj, 'missing:', name);
  3152. return obj[name];
  3153. }
  3154. };
  3155. let skipLog = (name, ret) => (...args) => (_console.log(`Skip ${name}(`, ...args, ')'), ret);
  3156. let createSkipLogObject = (baseName, list) => list.reduce(
  3157. (acc, cur) => (acc[cur] = skipLog(`${baseName}.${cur}`), acc),
  3158. {}
  3159. );
  3160. let redefiner = {
  3161. apply: (target, thisArg, args) => {
  3162. let res = void 0;
  3163. if (target._name === 'mrg-smokescreen/Welter')
  3164. res = {
  3165. isWelter: () => true,
  3166. wrap: skipLog(`${target._name}.wrap`)
  3167. };
  3168. if (target._name === 'mrg-smokescreen/StyleSheets')
  3169. res = createSkipLogObject(target._name, ['update', 'remove', 'insert', 'setup']);
  3170. if (target._name === 'mrg-honeypot/main')
  3171. res = { check: skipLog(`${target._name}.check`, false) };
  3172. if (target._name.startsWith('advert/rb/slot')) {
  3173. res = createSkipLogObject(target._name, ['get', 'getHTML', 'createBlock', 'onRedirect']);
  3174. res.slot = '0';
  3175. }
  3176. if (target._name.startsWith('OK/banners/'))
  3177. res = createSkipLogObject(target._name, ['activate', 'deactivate']);
  3178. if (target._name === 'advert/adman/adman')
  3179. res = createSkipLogObject(target._name, ['refresh', 'getBlock', 'init']);
  3180. if (res)
  3181. res = new Proxy(res, missingCheck);
  3182. else
  3183. res = target.apply(thisArg, args);
  3184. if (target._name === 'mimic')
  3185. res = new Proxy(res, {
  3186. construct: (...args) => {
  3187. function wrap(o) {
  3188. if ('locator' in o)
  3189. defineLocator(o);
  3190. for (let name in o)
  3191. if (typeof o[name] === 'object' && name !== 'locator')
  3192. wrap(o[name]);
  3193. return o;
  3194. }
  3195. let res = wrap(Reflect.construct(...args));
  3196. _console.warn('new mimic', res);
  3197. return res;
  3198. }
  3199. });
  3200. if (target._name === 'mrg-smokescreen/Utils')
  3201. res.extend = function(...args) {
  3202. let res = {
  3203. enable: false,
  3204. match: [],
  3205. links: []
  3206. };
  3207. _console.log(`${target._name}.extend(`, ...args, ') >>', res );
  3208. return res;
  3209. };
  3210. if (target._name === 'advert/RB') {
  3211. res.getSlots = () => [];
  3212. res.load._name = target._name + '.load';
  3213. res.load = new Proxy(res.load, redefiner);
  3214. }
  3215. _console.log(target._name, '(',...args,') >>', res);
  3216. return res;
  3217. }
  3218. };
  3219.  
  3220. let wrapAdFuncs = {
  3221. apply: (target, thisArg, args) => {
  3222. let module = args[0];
  3223. if (typeof module === 'string')
  3224. if (module.startsWith('mrg-smoke') ||
  3225. module.startsWith('mrg-context') ||
  3226. module.startsWith('mrg-honeypot') ||
  3227. module.startsWith('advert') ||
  3228. module.startsWith('mimic') ||
  3229. module.startsWith('OK/banner') ||
  3230. module === 'OK/Smokescreen') {
  3231. let fun = args[args.length-1];
  3232. fun._name = module;
  3233. args[args.length-1] = new Proxy(fun, redefiner);
  3234. }// else
  3235. // _console.log('Define:', args[0]);
  3236. return target.apply(thisArg, args);
  3237. }
  3238. };
  3239. let wrapDefine = def => {
  3240. if (!def)
  3241. return;
  3242. _console.log('define =', def);
  3243. def = new Proxy(def, wrapAdFuncs);
  3244. def._name = 'define';
  3245. return def;
  3246. };
  3247. let _define = wrapDefine(win.define);
  3248. Object.defineProperty(win, 'define', {
  3249. get: () => _define,
  3250. set: x => {
  3251. if (_define === x)
  3252. return true;
  3253. _define = wrapDefine(x);
  3254. return true;
  3255. }
  3256. });
  3257. }
  3258.  
  3259. let _honeyPot;
  3260. function defineDetector(mr) {
  3261. let __ = mr._ || {};
  3262. let setHoneyPot = o => {
  3263. if (!o || o === _honeyPot) return;
  3264. _console.log('[honeyPot]', o);
  3265. _honeyPot = function() {
  3266. this.check = new Proxy(() => {
  3267. __.STUCK_IN_POT = false;
  3268. return false;
  3269. }, logger);
  3270. this.check._name = 'honeyPot.check';
  3271. this.destroy = () => null;
  3272. };
  3273. };
  3274. if ('honeyPot' in mr)
  3275. setHoneyPot(mr.honeyPot);
  3276. else
  3277. Object.defineProperty(mr, 'honeyPot', {
  3278. get: () => _honeyPot,
  3279. set: setHoneyPot
  3280. });
  3281.  
  3282. __ = new Proxy(__, {
  3283. get: (t, p) => t[p],
  3284. set: (t, p, v) => {
  3285. _console.log(`mr._.${p} =`, v);
  3286. t[p] = v;
  3287. return true;
  3288. }
  3289. });
  3290. mr._ = __;
  3291. }
  3292.  
  3293. function defineAdd(mr) {
  3294. let _add;
  3295. let addWrapper = {
  3296. apply: (tgt, that, args) => {
  3297. let module = args[0];
  3298. if (typeof module === 'string' && module.startsWith('ad')) {
  3299. _console.log('Skip module:', module);
  3300. return;
  3301. }
  3302. if (typeof module === 'object' && module.name.startsWith('ad'))
  3303. _console.log('Loaded module:', module);
  3304. return logger.apply(tgt, that, args);
  3305. }
  3306. };
  3307. let setMrAdd = v => {
  3308. if (!v) return;
  3309. v._name = 'mr.add';
  3310. v = new Proxy(v, addWrapper);
  3311. _add = v;
  3312. };
  3313. if ('add' in mr)
  3314. setMrAdd(mr.add);
  3315. Object.defineProperty(mr, 'add', {
  3316. get: () => _add,
  3317. set: setMrAdd
  3318. });
  3319.  
  3320. }
  3321.  
  3322. let _mr_wrapper = vl => {
  3323. defineLocator(vl.mimic ? vl.mimic : vl);
  3324. defineDetector(vl);
  3325. defineAdd(vl);
  3326. return vl;
  3327. };
  3328. if ('mr' in win) {
  3329. _console.log('Found existing "mr" object.');
  3330. win.mr = _mr_wrapper(win.mr);
  3331. } else {
  3332. let _mr = void 0;
  3333. Object.defineProperty(win, 'mr', {
  3334. get: () => _mr,
  3335. set: vl => { _mr = _mr_wrapper(vl) },
  3336. configurable: true
  3337. });
  3338. let _defineProperty = Function.prototype.apply.bind(Object.defineProperty);
  3339. Object.defineProperty = function defineProperty(o, name, conf) {
  3340. if (name === 'mr' && o instanceof Window) {
  3341. _console.warn('Object.defineProperty(', ...arguments, ')');
  3342. conf.set(_mr_wrapper(conf.get()));
  3343. }
  3344. if ((name === 'honeyPot' || name === 'add') && _mr === o && conf.set)
  3345. return;
  3346. return _defineProperty(this, arguments);
  3347. };
  3348. }
  3349.  
  3350. // smokyTools wrapper for news.mail.ru
  3351. nt.define(win, 'smokyTools', nt.proxy({
  3352. getDict: nt.func(nt.proxy({}, 'smokyTools.getDict', null), 'smokyTools.getDict'),
  3353. CSS: nt.func(nt.proxy({}, 'smokyTools.CSS', null), 'smokyTools.CSS')
  3354. }, 'smokyTools', null));
  3355. nt.define(win, 'smoky', nt.func(null, 'smoky'));
  3356. nt.define(win, 'smokySingleElement', nt.func(null, 'smokySingleElement'));
  3357. nt.define(win, 'smokyByClass', nt.func(null, 'smokyByClass'));
  3358. }, nullTools);
  3359. }
  3360. };
  3361.  
  3362. scripts['oms.matchat.online'] = () => scriptLander(() => {
  3363. let _rmpGlobals = void 0;
  3364. Object.defineProperty(win, 'rmpGlobals', {
  3365. get: () => _rmpGlobals,
  3366. set: x => {
  3367. if (x === _rmpGlobals)
  3368. return true;
  3369. _rmpGlobals = new Proxy(x, {
  3370. get: (obj, name) => {
  3371. if (name === 'adBlockerDetected')
  3372. return false;
  3373. return obj[name];
  3374. },
  3375. set: (obj, name, val) => {
  3376. if (name === 'adBlockerDetected')
  3377. _console.warn('rmpGlobals.adBlockerDetected =', val)
  3378. else
  3379. obj[name] = val;
  3380. return true;
  3381. }
  3382. });
  3383. }
  3384. });
  3385. });
  3386.  
  3387. scripts['megogo.net'] = {
  3388. now: () => {
  3389. let nt = new nullTools();
  3390. nt.define(win, 'adBlock', false);
  3391. nt.define(win, 'showAdBlockMessage', nt.func(null));
  3392. }
  3393. };
  3394.  
  3395. scripts['naruto-base.su'] = () => gardener('div[id^="entryID"],.block', /href="http.*?target="_blank"/i);
  3396.  
  3397. scripts['newdeaf-online.net'] = {
  3398. dom: () => {
  3399. let adNodes = _document.querySelectorAll('.ads');
  3400. if (!adNodes)
  3401. return;
  3402. let getter = x => {
  3403. let val = x;
  3404. return () => (_console.warn('read .ads', name, val), val);
  3405. };
  3406. let setter = x => _console.warn('skip write .ads', name, x);
  3407. for (let adNode of adNodes)
  3408. for (let name of ['innerHTML'])
  3409. Object.defineProperty(adNode, name, {
  3410. get: getter(ads[name]),
  3411. set: setter
  3412. });
  3413. }
  3414. };
  3415.  
  3416. scripts['overclockers.ru'] = {
  3417. dom: () => scriptLander(() => {
  3418. let killed = () => _console.warn('Anti-Adblock killed.');
  3419. if ('$' in win)
  3420. win.$ = new Proxy($, {
  3421. apply: (tgt, that, args) => {
  3422. let res = tgt.apply(that, args);
  3423. if (res[0] && res[0] === _document.body) {
  3424. res.html = killed;
  3425. res.empty = killed;
  3426. }
  3427. return res;
  3428. }
  3429. });
  3430. })
  3431. };
  3432. scripts['forums.overclockers.ru'] = {
  3433. now: () => {
  3434. createStyle('.needblock {position: fixed; left: -10000px}');
  3435. Object.defineProperty(win, 'adblck', {
  3436. get: () => 'no',
  3437. set: () => undefined,
  3438. enumerable: true
  3439. });
  3440. }
  3441. };
  3442.  
  3443. scripts['pb.wtf'] = {
  3444. other: ['piratbit.org', 'piratbit.ru'],
  3445. dom: () => {
  3446. // line above topic content and images in the slider in the header
  3447. let remove = node => (_console.log('removed', node), node.parentNode.removeChild(node));
  3448. for (let el of _document.querySelectorAll('.release-block-img a, #page_content a')) {
  3449. if (location.hostname === el.hostname &&
  3450. /^\/(\w{3}|exit)\/[\w=/]{20,}$/.test(el.pathname)) {
  3451. remove(el.closest('div, tr'));
  3452. continue;
  3453. }
  3454. // ads in the topic header in case filter above wasn't enough
  3455. let parent = el.closest('tr');
  3456. if (parent) {
  3457. let span = (parent.querySelector('span') || {}).textContent;
  3458. span && span.startsWith('YO!') && remove(parent);
  3459. }
  3460. }
  3461. // casino ad button in random places
  3462. for (let el of _document.querySelectorAll('.btn-group')) {
  3463. el = el.parentNode;
  3464. if (el.tagName === 'CENTER')
  3465. remove(el.parentNode);
  3466. }
  3467. // ads in comments
  3468. let el = _document.querySelector('thead + tbody[id^="post_"] + tbody[class*=" "]');
  3469. if (el && el.parentNode.children[2] == el)
  3470. remove(el);
  3471. }
  3472. };
  3473.  
  3474. scripts['pikabu.ru'] = () => gardener('.story', /story__author[^>]+>ads</i, {root: '.inner_wrap', observe: true});
  3475.  
  3476. scripts['peka2.tv'] = () => {
  3477. let bodyClass = 'body--branding';
  3478. let checkNode = node => {
  3479. for (let className of node.classList)
  3480. if (className.includes('banner') || className === bodyClass) {
  3481. _removeAttribute(node, 'style');
  3482. node.classList.remove(className);
  3483. for (let attr of Array.from(node.attributes))
  3484. if (attr.name.startsWith('advert'))
  3485. _removeAttribute(node, attr.name);
  3486. }
  3487. };
  3488. (new MutationObserver(ms => {
  3489. let m, node;
  3490. for (m of ms) for (node of m.addedNodes)
  3491. if (node instanceof HTMLElement)
  3492. checkNode(node);
  3493. })).observe(_de, {childList: true, subtree: true});
  3494. (new MutationObserver(ms => {
  3495. for (let m of ms)
  3496. checkNode(m.target);
  3497. })).observe(_de, {attributes: true, subtree: true, attributeFilter: ['class']});
  3498. };
  3499.  
  3500. scripts['qrz.ru'] = {
  3501. now: () => {
  3502. let nt = new nullTools();
  3503. nt.define(win, 'ab', false);
  3504. nt.define(win, 'tryMessage', nt.func(null));
  3505. }
  3506. };
  3507.  
  3508. scripts['razlozhi.ru'] = {
  3509. now: () => {
  3510. let nt = new nullTools();
  3511. nt.define(win, 'cadb', false);
  3512. for (let func of ['createShadowRoot', 'attachShadow'])
  3513. if (func in _Element)
  3514. _Element[func] = function(){
  3515. return this.cloneNode();
  3516. };
  3517. }
  3518. };
  3519.  
  3520. scripts['rbc.ru'] = {
  3521. other: ['autonews.ru', 'rbcplus.ru', 'sportrbc.ru'],
  3522. now: () => {
  3523. selectiveCookies('adb_on');
  3524. let _RA = void 0;
  3525. let setArgs = {
  3526. 'showBanners': true,
  3527. 'showAds': true,
  3528. 'banners.staticPath': '',
  3529. 'paywall.staticPath': '',
  3530. 'banners.dfp.config': [],
  3531. 'banners.dfp.pageTargeting': () => null,
  3532. };
  3533. Object.defineProperty(win, 'RA', {
  3534. get: () => _RA,
  3535. set: vl => {
  3536. _console.log('RA =', vl);
  3537. if ('repo' in vl) {
  3538. _console.log('RA.repo =', vl.repo);
  3539. vl.repo = new Proxy(vl.repo, {
  3540. set: (o, name, val) => {
  3541. if (name === 'banner') {
  3542. _console.log(`RA.repo.${name} =`, val);
  3543. val = new Proxy(val, {
  3544. get: (o, name) => {
  3545. let res = o[name];
  3546. if (typeof o[name] === 'function') {
  3547. res = () => null;
  3548. res.toString = o[name].toString.bind(o[name]);
  3549. }
  3550. if (name === 'isInited')
  3551. res = true;
  3552. _console.warn(`get RA.repo.banner.${name}`, res);
  3553. return res;
  3554. }
  3555. });
  3556. }
  3557. o[name] = val;
  3558. return true;
  3559. }
  3560. });
  3561. } else
  3562. _console.log('Unable to locate RA.repo');
  3563. _RA = new Proxy(vl, {
  3564. set: (o, name, val) => {
  3565. if (name === 'config') {
  3566. _console.log('RA.config =', val);
  3567. if ('set' in val) {
  3568. val.set = new Proxy(val.set, {
  3569. apply: (set, that, args) => {
  3570. let name = args[0];
  3571. if (name in setArgs)
  3572. args[1] = setArgs[name];
  3573. if (name in setArgs || name === 'checkad')
  3574. _console.log('RA.config.set(', ...args, ')');
  3575. return Reflect.apply(set, that, args);
  3576. }
  3577. });
  3578. val.set('showAds', true); // pretend ads already were shown
  3579. }
  3580. }
  3581. o[name] = val;
  3582. return true;
  3583. }
  3584. });
  3585. }
  3586. });
  3587. Object.defineProperty(win, 'bannersConfig', {
  3588. get: () => [], set: () => null
  3589. });
  3590. // pretend there is a paywall landing on screen already
  3591. let pwl = _document.createElement('div');
  3592. pwl.style.display = 'none';
  3593. pwl.className = 'js-paywall-landing';
  3594. _document.documentElement.appendChild(pwl);
  3595. // detect and skip execution of one of the ABP detectors
  3596. let _setTimeout = Function.prototype.apply.bind(win.setTimeout);
  3597. let _toString = Function.prototype.call.bind(Function.prototype.toString);
  3598. win.setTimeout = function setTimeout() {
  3599. if (typeof arguments[0] === 'function') {
  3600. let fts = _toString(arguments[0]);
  3601. if (/\.length\s*>\s*0\s*&&/.test(fts) && /:hidden/.test(fts)) {
  3602. _console.log('Skipped setTimout(', fts, arguments[1], ')');
  3603. return;
  3604. }
  3605. }
  3606. return _setTimeout(this, arguments);
  3607. };
  3608. // hide banner placeholders
  3609. createStyle('[data-banner-id], .banner__container, .banners__yandex__article { display: none !important }');
  3610. },
  3611. dom: () => {
  3612. // hide sticky banner place at the top of the page
  3613. for (let itm of _document.querySelectorAll('.l-sticky'))
  3614. if (itm.querySelector('.banner__container__link'))
  3615. itm.style.display = 'none';
  3616. }
  3617. };
  3618.  
  3619. scripts['rp5.ru'] = {
  3620. other: ['rp5.by', 'rp5.kz', 'rp5.ua'],
  3621. now: () => {
  3622. Object.defineProperty(win, 'sContentBottom', {
  3623. get: () => '',
  3624. set: () => true
  3625. });
  3626. },
  3627. dom: () => {
  3628. let node = selectNodeByTextContent('Разместить текстовое объявление', { root: _de.querySelector('#content-wrapper'), shallow: true });
  3629. if (node)
  3630. node.style.display = 'none';
  3631. }
  3632. };
  3633.  
  3634. scripts['rutube.ru'] = () => scriptLander(() => {
  3635. let _parse = JSON.parse;
  3636. let _skip_enabled = false;
  3637. JSON.parse = (...args) => {
  3638. let res = _parse(...args),
  3639. log = false;
  3640. if (!res)
  3641. return res;
  3642. // parse player configuration
  3643. if ('appearance' in res || 'video_balancer' in res) {
  3644. log = true;
  3645. if (res.appearance) {
  3646. if ('forbid_seek' in res.appearance && res.appearance.forbid_seek)
  3647. res.appearance.forbid_seek = false;
  3648. if ('forbid_timeline_preview' in res.appearance && res.appearance.forbid_timeline_preview)
  3649. res.appearance.forbid_timeline_preview = false;
  3650. }
  3651. _skip_enabled = !!res.remove_unseekable_blocks;
  3652. //res.advert = [];
  3653. delete res.advert;
  3654. //for (let limit of res.limits)
  3655. // limit.limit = 0;
  3656. delete res.limits;
  3657. //res.yast = null;
  3658. //res.yast_live_online = null;
  3659. delete res.yast;
  3660. delete res.yast_live_online;
  3661. Object.defineProperty(res, 'stat', {
  3662. get: () => [],
  3663. set: () => true,
  3664. enumerable: true
  3665. });
  3666. }
  3667.  
  3668. // parse video configuration
  3669. if ('video_url' in res) {
  3670. log = true;
  3671. if (res.cuepoints && !_skip_enabled)
  3672. for (let point of res.cuepoints) {
  3673. point.is_pause = false;
  3674. point.show_navigation = true;
  3675. point.forbid_seek = false;
  3676. }
  3677. }
  3678.  
  3679. if (log)
  3680. _console.log('[rutube]', res);
  3681. return res;
  3682. };
  3683. });
  3684.  
  3685. scripts['simpsonsua.com.ua'] = {
  3686. other: ['simpsonsua.tv'],
  3687. now: () => scriptLander(() => {
  3688. let _addEventListener = _Document.addEventListener;
  3689. _document.addEventListener = function(event, callback) {
  3690. if (event === 'DOMContentLoaded' && callback.toString().includes('show_warning'))
  3691. return;
  3692. return _addEventListener.apply(this, arguments);
  3693. };
  3694. let nt = new nullTools();
  3695. nt.define(win, 'need_warning', 0);
  3696. }, nullTools)
  3697. };
  3698.  
  3699. scripts['smotretanime.ru'] = () => scriptLander(() => {
  3700. deepWrapAPI(root => {
  3701. let _pause = root.Function.prototype.call.bind(root.Audio.prototype.pause);
  3702. let _addEventListener = root.Function.prototype.call.bind(root.Element.prototype.addEventListener);
  3703. let stopper = e => _pause(e.target);
  3704. root.Audio = new Proxy(root.Audio, {
  3705. construct: (audio, args) => {
  3706. let res = new audio(...args);
  3707. _addEventListener(res, 'play', stopper, true);
  3708. return res;
  3709. }
  3710. });
  3711. _createElement = root.Document.prototype.createElement;
  3712. root.Document.prototype.createElement = function createElement() {
  3713. let res = _createElement.apply(this, arguments);
  3714. if (res instanceof HTMLAudioElement)
  3715. _addEventListener(res, 'play', stopper, true);
  3716. return res;
  3717. };
  3718. });
  3719. }, deepWrapAPI);
  3720.  
  3721. scripts['spaces.ru'] = () => {
  3722. gardener('div:not(.f-c_fll) > a[href*="spaces.ru/?Cl="]', /./, { parent: 'div' });
  3723. gardener('.js-banner_rotator', /./, { parent: '.widgets-group' });
  3724. };
  3725.  
  3726. scripts['spam-club.blogspot.co.uk'] = () => {
  3727. let _clientHeight = Object.getOwnPropertyDescriptor(_Element, 'clientHeight'),
  3728. _clientWidth = Object.getOwnPropertyDescriptor(_Element, 'clientWidth');
  3729. let wrapGetter = (getter) => {
  3730. let _getter = getter;
  3731. return function() {
  3732. let _size = _getter.apply(this, arguments);
  3733. return _size ? _size : 1;
  3734. };
  3735. };
  3736. _clientHeight.get = wrapGetter(_clientHeight.get);
  3737. _clientWidth.get = wrapGetter(_clientWidth.get);
  3738. Object.defineProperty(_Element, 'clientHeight', _clientHeight);
  3739. Object.defineProperty(_Element, 'clientWidth', _clientWidth);
  3740. let _onload = Object.getOwnPropertyDescriptor(HTMLElement.prototype, 'onload'),
  3741. _set_onload = _onload.set;
  3742. _onload.set = function() {
  3743. if (this instanceof HTMLImageElement)
  3744. return true;
  3745. _set_onload.apply(this, arguments);
  3746. };
  3747. Object.defineProperty(HTMLElement.prototype, 'onload', _onload);
  3748. };
  3749.  
  3750. scripts['sport-express.ru'] = () => gardener('.js-relap__item',/>Реклама\s+<\//, {root:'.container', observe: true});
  3751.  
  3752. scripts['sports.ru'] = {
  3753. now: () => {
  3754. gardener('.aside-news-list__item', /aside-news-list__advert/i, {root:'.columns-layout__left', observe: true});
  3755. gardener('.material-list__item', /Реклама/i, {root:'.columns-layout', observe: true});
  3756. // extra functionality: shows/hides panel at the top depending on scroll direction
  3757. createStyle([
  3758. '.user-panel__fixed { transition: top 0.2s ease-in-out!important; }',
  3759. '.user-panel-up { top: -40px!important }'
  3760. ], {id: 'userPanelSlide'}, false);
  3761. },
  3762. dom: () => {
  3763. (function lookForPanel() {
  3764. let panel = _document.querySelector('.user-panel__fixed');
  3765. if (!panel)
  3766. setTimeout(lookForPanel, 100);
  3767. else
  3768. window.addEventListener(
  3769. 'wheel', function(e) {
  3770. if (e.deltaY > 0 && !panel.classList.contains('user-panel-up'))
  3771. panel.classList.add('user-panel-up');
  3772. else if (e.deltaY < 0 && panel.classList.contains('user-panel-up'))
  3773. panel.classList.remove('user-panel-up');
  3774. }, false
  3775. );
  3776. })();
  3777. }
  3778. };
  3779.  
  3780. scripts['stealthz.ru'] = {
  3781. dom: () => {
  3782. // skip timeout
  3783. let $ = _document.querySelector.bind(_document);
  3784. let [timer_1, timer_2] = [$('#timer_1'), $('#timer_2')];
  3785. if (!timer_1 || !timer_2)
  3786. return;
  3787. timer_1.style.display = 'none';
  3788. timer_2.style.display = 'block';
  3789. }
  3790. };
  3791.  
  3792. scripts['xittv.net'] = () => scriptLander(() => {
  3793. let logNames = ['setup', 'trigger', 'on', 'off', 'onReady', 'onError', 'getConfig', 'addPlugin', 'getAdBlock'];
  3794. let skipEvents = ['adComplete', 'adSkipped', 'adBlock', 'adRequest', 'adMeta', 'adImpression', 'adError', 'adTime', 'adStarted', 'adClick'];
  3795. let _jwplayer = void 0;
  3796. Object.defineProperty(win, 'jwplayer', {
  3797. get: () => _jwplayer,
  3798. set: x => {
  3799. _jwplayer = new Proxy(x, {
  3800. apply: (fun, that, args) => {
  3801. let res = fun.apply(that, args);
  3802. res = new Proxy(res, {
  3803. get: (obj, name) => {
  3804. if (logNames.includes(name) && obj[name] instanceof Function)
  3805. return new Proxy(obj[name], {
  3806. apply: (fun, that, args) => {
  3807. if (name === 'setup') {
  3808. let o = args[0];
  3809. if (o)
  3810. delete o.advertising;
  3811. }
  3812. if (name === 'on' || name === 'trigger') {
  3813. let events = typeof args[0] === 'string' ? args[0].split(" ") : null;
  3814. if (events.length === 1 && skipEvents.includes(events[0]))
  3815. return res;
  3816. if (events.length > 1) {
  3817. let names = [];
  3818. for (let event of events)
  3819. if (!skipEvents.includes(event))
  3820. names.push(event);
  3821. if (names.length > 0)
  3822. args[0] = names.join(" ");
  3823. else
  3824. return res;
  3825. }
  3826. }
  3827. let subres = fun.apply(that, args);
  3828. _console.warn(`jwplayer().${name}(`, ...args, `) >>`, res);
  3829. return subres;
  3830. }
  3831. });
  3832. return obj[name];
  3833. }
  3834. });
  3835. return res;
  3836. }
  3837. });
  3838. _console.log('jwplayer =', x);
  3839. }
  3840. });
  3841. });
  3842.  
  3843. scripts['yap.ru'] = {
  3844. other: ['yaplakal.com'],
  3845. now: () => {
  3846. gardener('form > table[id^="p_row_"]:nth-of-type(2)', /member1438|Administration/);
  3847. gardener('.icon-comments', /member1438|Administration|\/go\/\?http/, {parent:'tr', siblings:-2});
  3848. }
  3849. };
  3850.  
  3851. scripts['rambler.ru'] = {
  3852. other: ['championat.com', 'gazeta.ru', 'lenta.ru', 'media.eagleplatform.com', 'quto.ru', 'rns.online'],
  3853. now: () => {
  3854. selectiveCookies('detect_count');
  3855. scriptLander(() => {
  3856. // Prevent autoplay
  3857. if (!('EaglePlayer' in win)) {
  3858. let _EaglePlayer = void 0;
  3859. Object.defineProperty(win, 'EaglePlayer', {
  3860. enumerable: true,
  3861. get: () => _EaglePlayer,
  3862. set: x => {
  3863. if (x === _EaglePlayer)
  3864. return true;
  3865. _EaglePlayer = new Proxy(x, {
  3866. construct: (targ, args) => {
  3867. let player = new targ(...args);
  3868. if (!player.options) {
  3869. _console.log('EaglePlayer: no options', EaglePlayer);
  3870. return player;
  3871. }
  3872. Object.defineProperty(player.options, 'autoplay', {
  3873. get: () => false,
  3874. set: () => true
  3875. });
  3876. Object.defineProperty(player.options, 'scroll', {
  3877. get: () => false,
  3878. set: () => true
  3879. });
  3880. return player;
  3881. }
  3882. });
  3883. }
  3884. });
  3885. let _setAttribute = Function.prototype.apply.bind(_Element.setAttribute);
  3886. let isAutoplay = /^autoplay$/i;
  3887. _Element.setAttribute = function setAttribute(name) {
  3888. if (!this._stopped && isAutoplay.test(name)) {
  3889. _console.log('Prevented assigning autoplay attribute.');
  3890. return null;
  3891. }
  3892. return _setAttribute(this, arguments);
  3893. };
  3894. } else {
  3895. _console.log('EaglePlayer function already exists.');
  3896. if (inIFrame) {
  3897. let _setAttribute = Function.prototype.apply.bind(_Element.setAttribute);
  3898. let isAutoplay = /^autoplay$/i;
  3899. _Element.setAttribute = function setAttribute(name) {
  3900. if (!this._stopped && isAutoplay.test(name)) {
  3901. _console.log('Prevented assigning autoplay attribute.');
  3902. this._stopped = true;
  3903. this.play = () => {
  3904. _console.log('Prevented attempt to force-start playback.');
  3905. delete this.play;
  3906. };
  3907. return null;
  3908. }
  3909. return _setAttribute(this, arguments);
  3910. };
  3911. }
  3912. }
  3913. if (location.hostname.endsWith('.media.eagleplatform.com'))
  3914. return;
  3915. let nt = new nullTools();
  3916. // Adblock Detector
  3917. let _hidden = void 0;
  3918. Object.defineProperty(win, 'QW50aS1BZEJsb2Nr', {
  3919. set: vl => {
  3920. for (let name in vl) delete vl[name];
  3921. nt.define(vl, 'Detector', nt.proxy({
  3922. getBlockingStatus: () => new Promise(),
  3923. blockingDetectors: [],
  3924. baitURLPrefix: '',
  3925. commonRules: []
  3926. }));
  3927. nt.define(vl, 'isAdBlockFlag', '');
  3928. nt.define(vl, 'ruid', '');
  3929. nt.define(vl, 'user', nt.proxy({
  3930. getOrSetUid: () => null
  3931. }));
  3932. _console.log('Found Adblock Detector.');
  3933. _hidden = vl;
  3934. },
  3935. get: () => _hidden
  3936. });
  3937. // prevent ads from loading
  3938. let blockObfuscated = false;
  3939. let obfuscation = /\[[a-z]{4}\("0x\d+"\)\]/i;
  3940. let _toString = Function.prototype.call.bind(Function.prototype.toString);
  3941. let CSSRuleProto = 'cssText' in CSSRule.prototype ? CSSRule.prototype : CSSStyleRule.prototype;
  3942. let _cssText = Object.getOwnPropertyDescriptor(CSSRuleProto, 'cssText');
  3943. let _cssText_get = _cssText.get;
  3944. _cssText.configurable = false;
  3945. _cssText.get = function() {
  3946. let cssText = _cssText_get.call(this);
  3947. if (cssText.includes('content:')) {
  3948. _console.warn('Blocked access to suspicious cssText:', cssText.slice(0,60), '\u2026', cssText.length);
  3949. blockObfuscated = true;
  3950. return null;
  3951. }
  3952. return cssText;
  3953. };
  3954. Object.defineProperty(CSSRuleProto, 'cssText', _cssText);
  3955. let _setTimeout = win.setTimeout;
  3956. win.setTimeout = function(f) {
  3957. if (blockObfuscated && obfuscation.test(_toString(f))) {
  3958. _console.warn('Stopped setTimeout for:', _toString(f).slice(0,100), '\u2026');
  3959. return null;
  3960. };
  3961. return _setTimeout.apply(this, arguments);
  3962. };
  3963. // fake global Adf object
  3964. let Adf_banner = {};
  3965. [
  3966. 'reloadssp', 'sspScroll',
  3967. 'sspRich', 'ssp'
  3968. ].forEach(name => void(Adf_banner[name] = nt.proxy(() => new Promise(r => r({status: true})))));
  3969. nt.define(win, 'Adf', nt.proxy({
  3970. banner: nt.proxy(Adf_banner)
  3971. }));
  3972. // extra script to remove partner news on gazeta.ru
  3973. if (!location.hostname.includes('gazeta.ru'))
  3974. return;
  3975. (new MutationObserver(
  3976. (ms) => {
  3977. let m, node, header;
  3978. for (m of ms) for (node of m.addedNodes)
  3979. if (node instanceof HTMLDivElement && node.matches('.sausage')) {
  3980. header = node.querySelector('.sausage-header');
  3981. if (header && /новости\s+партн[её]ров/i.test(header.textContent))
  3982. node.style.display = 'none';
  3983. }
  3984. }
  3985. )).observe(_document.documentElement, { childList:true, subtree: true });
  3986. }, `let inIFrame = ${inIFrame}`, nullTools)
  3987. }
  3988. };
  3989.  
  3990. scripts['reactor.cc'] = {
  3991. other: ['joyreactor.cc', 'pornreactor.cc'],
  3992. now: () => {
  3993. selectiveEval();
  3994. scriptLander(() => {
  3995. let nt = new nullTools();
  3996. win.open = function(){
  3997. throw new Error('Redirect prevention.');
  3998. };
  3999. nt.define(win, 'Worker', function(){});
  4000. nt.define(win, 'JRCH', win.CoinHive);
  4001. }, nullTools);
  4002. },
  4003. click: function(e) {
  4004. let node = e.target;
  4005. if (node.nodeType === _Node.ELEMENT_NODE &&
  4006. node.style.position === 'absolute' &&
  4007. node.style.zIndex > 0)
  4008. node.parentNode.removeChild(node);
  4009. },
  4010. dom: function() {
  4011. let tid = void 0;
  4012. function probe() {
  4013. let node = selectNodeByTextContent('блокировщик рекламы');
  4014. if (!node) return;
  4015. while (node.parentNode.offsetHeight < 750 && node !== _document.body)
  4016. node = node.parentNode;
  4017. _setAttribute(node, 'style', 'background:none!important');
  4018. // stop observer
  4019. if (!tid) tid = setTimeout(() => this.disconnect(), 1000);
  4020. }
  4021. (new MutationObserver(probe))
  4022. .observe(_document, { childList:true, subtree:true });
  4023. }
  4024. };
  4025.  
  4026. scripts['auto.ru'] = () => {
  4027. let words = /Реклама|Яндекс.Директ|yandex_ad_/;
  4028. let userAdsListAds = (
  4029. '.listing-list > .listing-item,'+
  4030. '.listing-item_type_fixed.listing-item'
  4031. );
  4032. let catalogAds = (
  4033. 'div[class*="layout_catalog-inline"],'+
  4034. 'div[class$="layout_horizontal"]'
  4035. );
  4036. let otherAds = (
  4037. '.advt_auto,'+
  4038. '.sidebar-block,'+
  4039. '.pager-listing + div[class],'+
  4040. '.card > div[class][style],'+
  4041. '.sidebar > div[class],'+
  4042. '.main-page__section + div[class],'+
  4043. '.listing > tbody'
  4044. );
  4045. gardener(userAdsListAds, words, {root:'.listing-wrap', observe:true});
  4046. gardener(catalogAds, words, {root:'.catalog__page,.content__wrapper', observe:true});
  4047. gardener(otherAds, words);
  4048. };
  4049.  
  4050. scripts['rsload.net'] = {
  4051. load: () => {
  4052. let dis = _document.querySelector('label[class*="cb-disable"]');
  4053. if (dis)
  4054. dis.click();
  4055. },
  4056. click: e => {
  4057. let t = e.target;
  4058. if (t && t.href && (/:\/\/\d+\.\d+\.\d+\.\d+\//.test(t.href)))
  4059. t.href = t.href.replace('://','://rsload.net:rsload.net@');
  4060. }
  4061. };
  4062.  
  4063. let domain;
  4064. // add alternative domain names if present and wrap functions into objects
  4065. for (let name in scripts) {
  4066. if (scripts[name] instanceof Function)
  4067. scripts[name] = { now: scripts[name] };
  4068. for (domain of (scripts[name].other||[])) {
  4069. if (domain in scripts)
  4070. _console.log('Error in scripts list. Script for', name, 'replaced script for', domain);
  4071. scripts[domain] = scripts[name];
  4072. }
  4073. delete scripts[name].other;
  4074. }
  4075. // look for current domain in the list and run appropriate code
  4076. domain = _document.domain;
  4077. while (domain.includes('.')) {
  4078. if (domain in scripts) for (let when in scripts[domain])
  4079. switch(when) {
  4080. case 'now':
  4081. scripts[domain][when]();
  4082. break;
  4083. case 'dom':
  4084. _document.addEventListener('DOMContentLoaded', scripts[domain][when], false);
  4085. break;
  4086. default:
  4087. _document.addEventListener (when, scripts[domain][when], false);
  4088. }
  4089. domain = domain.slice(domain.indexOf('.') + 1);
  4090. }
  4091.  
  4092. // Batch script lander
  4093. if (!skipLander)
  4094. landScript(batchLand, batchPrepend);
  4095.  
  4096. { // JS Fixes Tools Menu
  4097. let openOptions = function() {
  4098. let ovl = _createElement('div'),
  4099. inner = _createElement('div');
  4100. ovl.style = (
  4101. 'position: fixed;'+
  4102. 'top:0; left:0;'+
  4103. 'bottom: 0; right: 0;'+
  4104. 'background: rgba(0,0,0,0.85);'+
  4105. 'z-index: 2147483647;'+
  4106. 'padding: 5em'
  4107. );
  4108. inner.style = (
  4109. 'background: whitesmoke;'+
  4110. 'font-size: 10pt;'+
  4111. 'color: black;'+
  4112. 'padding: 1em'
  4113. );
  4114. inner.textContent = 'JS Fixes Tools';
  4115. inner.appendChild(_createElement('br'));
  4116. inner.appendChild(_createElement('br'));
  4117. ovl.addEventListener(
  4118. 'click', function(e) {
  4119. if (e.target === ovl) {
  4120. ovl.parentNode.removeChild(ovl);
  4121. e.preventDefault();
  4122. }
  4123. e.stopPropagation();
  4124. }, false
  4125. );
  4126.  
  4127. let sObjBtn = _createElement('button');
  4128. sObjBtn.onclick = getStrangeObjectsList;
  4129. sObjBtn.textContent = 'Print (in console) list of unusual window properties';
  4130. inner.appendChild(_createElement('br'));
  4131. inner.appendChild(sObjBtn);
  4132.  
  4133. _document.body.appendChild(ovl);
  4134. ovl.appendChild(inner);
  4135. };
  4136.  
  4137. // monitor keys pressed for Ctrl+Alt+Shift+J > s > f code
  4138. let opPos = 0, opKey = ['KeyJ','KeyS','KeyF'];
  4139. _document.addEventListener(
  4140. 'keydown', function(e) {
  4141. if ((e.code === opKey[opPos] || e.location) &&
  4142. (!!opPos || e.altKey && e.ctrlKey && e.shiftKey)) {
  4143. opPos += e.location ? 0 : 1;
  4144. e.stopPropagation();
  4145. e.preventDefault();
  4146. } else
  4147. opPos = 0;
  4148. if (opPos === opKey.length) {
  4149. opPos = 0;
  4150. openOptions();
  4151. }
  4152. }, false
  4153. );
  4154. }
  4155. })();