RU AdList JS Fixes

try to take over the world!

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

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

QingJ © 2025

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