RU AdList JS Fixes

try to take over the world!

当前为 2018-10-19 提交的版本,查看 最新版本

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

QingJ © 2025

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