RU AdList JS Fixes

try to take over the world!

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

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

QingJ © 2025

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