RU AdList JS Fixes

try to take over the world!

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

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

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址