RU AdList JS Fixes

try to take over the world!

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

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

QingJ © 2025

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