RU AdList JS Fixes

try to take over the world!

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

  1. // ==UserScript==
  2. // @name RU AdList JS Fixes
  3. // @namespace ruadlist_js_fixes
  4. // @version 20181004.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 = _Element.prototype.getAttribute,
  42. _setAttribute = _Element.prototype.setAttribute,
  43. _removeAttribute = _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.call(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.call(node, 'style',
  845. style.replace(imptt, ret_b));
  846. log = true;
  847. };
  848.  
  849. (new MutationObserver(
  850. function(mutations) {
  851. setTimeout(
  852. function(ms) {
  853. let m, node;
  854. for (m of ms) for (node of m.addedNodes)
  855. unimportanter(node);
  856. logger();
  857. }, 0, mutations
  858. );
  859. }
  860. )).observe(_document, {
  861. childList : true,
  862. subtree : true
  863. });
  864.  
  865. _Element.prototype.setAttribute = function setAttribute(name, value) {
  866. "[native code]";
  867. let replaced = value;
  868. if (name && _toLowerCase.call(name) === 'style' && protectedNodes.has(this))
  869. replaced = value.replace(imptt, ret_b);
  870. log = (replaced !== value);
  871. logger();
  872. return _setAttribute.apply(this, arguments);
  873. };
  874.  
  875. win.addEventListener (
  876. 'load', () => {
  877. for (let imp of _document.querySelectorAll('[style*="!"]'))
  878. unimportanter(imp);
  879. logger();
  880. }, false
  881. );
  882. }
  883.  
  884. // Naive ABP Style protector
  885. {
  886. let _querySelector = _Document.prototype.querySelector.bind(_document);
  887. let _removeChild = _Node.prototype.removeChild;
  888. let _appendChild = _Node.prototype.appendChild;
  889. let createShadow = () => _createElement('shadow');
  890. // Prevent adding fake content entry point
  891. _Node.prototype.appendChild = function(child) {
  892. if (this instanceof ShadowRoot &&
  893. child instanceof HTMLContentElement)
  894. return _appendChild.call(this, createShadow());
  895. return _appendChild.apply(this, arguments);
  896. };
  897. {
  898. let _shadowSelector = ShadowRoot.prototype.querySelector;
  899. let _innerHTML = Object.getOwnPropertyDescriptor(ShadowRoot.prototype, 'innerHTML');
  900. let _parentNode = Object.getOwnPropertyDescriptor(_Node.prototype, 'parentNode');
  901. if (_innerHTML && _parentNode) {
  902. let _set = _innerHTML.set;
  903. let _getParent = _parentNode.get;
  904. _innerHTML.configurable = false;
  905. _innerHTML.set = function() {
  906. _set.apply(this, arguments);
  907. let content = _shadowSelector.call(this, 'content');
  908. if (content) {
  909. let parent = _getParent.call(content);
  910. _removeChild.call(parent, content);
  911. _appendChild.call(parent, createShadow());
  912. }
  913. };
  914. }
  915. Object.defineProperty(ShadowRoot.prototype, 'innerHTML', _innerHTML);
  916. }
  917. // Locate and apply extra protection to a style on top of what ABP does
  918. let style;
  919. (new Promise(
  920. function(resolve, reject) {
  921. let getStyle = () => _querySelector('::shadow style');
  922. style = getStyle();
  923. if (style)
  924. return resolve(style);
  925. let intv = setInterval(
  926. function() {
  927. style = getStyle();
  928. if (!style)
  929. return;
  930. intv = clearInterval(intv);
  931. return resolve(style);
  932. }, 0
  933. );
  934. _document.addEventListener(
  935. 'DOMContentLoaded', () => {
  936. if (intv)
  937. clearInterval(intv);
  938. style = getStyle();
  939. return style ? resolve(style) : reject();
  940. }, false
  941. );
  942. }
  943. )).then(
  944. function(style) {
  945. let emptyArr = [],
  946. nullStr = {
  947. get: () => '',
  948. set: () => undefined
  949. };
  950. let shadow = style.parentNode;
  951. Object.defineProperties(shadow, {
  952. childElementCount: { value: 0 },
  953. styleSheets: { value: emptyArr },
  954. firstChild: { value: null },
  955. firstElementChild: { value: null },
  956. lastChild: { value: null },
  957. lastElementChild: { value: null },
  958. childNodes: { value: emptyArr },
  959. children: { value: emptyArr },
  960. innerHTML: { value: nullStr },
  961. });
  962. Object.defineProperties(style, {
  963. innerHTML: { value: nullStr },
  964. textContent: { value: nullStr },
  965. ownerDocument: { value: null },
  966. parentNode: {value: null },
  967. previousElementSibling: { value: null },
  968. previousSibling: { value: null },
  969. disabled: { get: () => true, set: () => null }
  970. });
  971. Object.defineProperties(style.sheet, {
  972. deleteRule: { value: () => null },
  973. disabled: { get: () => true, set: () => null },
  974. cssRules: { value: emptyArr },
  975. rules: { value: emptyArr }
  976. });
  977. }
  978. ).catch(()=>null);
  979. _Node.prototype.removeChild = function(child) {
  980. if (child === style)
  981. return;
  982. return _removeChild.apply(this, arguments);
  983. };
  984. }
  985. }
  986.  
  987. if (/^https?:\/\/(mail\.yandex\.|music\.yandex\.|news\.yandex\.|(www\.)?yandex\.[^/]+\/(yand)?search[/?])/i.test(win.location.href) ||
  988. /^https?:\/\/tv\.yandex\./i.test(win.location.href)) {
  989. // https://gf.qytechs.cn/en/scripts/809-no-yandex-ads
  990. let yadWord = /Яндекс.Директ/i,
  991. adWords = /Реклама|Ad/i;
  992. let _querySelector = _document.querySelector.bind(_document),
  993. _querySelectorAll = _document.querySelectorAll.bind(_document),
  994. _getAttribute = _Element.prototype.getAttribute,
  995. _setAttribute = _Element.prototype.setAttribute;
  996. // Function to attach an observer to monitor dynamic changes on the page
  997. let pageUpdateObserver = (func, obj, params) => {
  998. if (obj)
  999. (new MutationObserver(func))
  1000. .observe(obj, (params || { childList:true, subtree:true }));
  1001. };
  1002. // Short name for parentNode.removeChild and setAttribute style to display:none
  1003. let remove = (node) => {
  1004. if (!node || !node.parentNode)
  1005. return false;
  1006. console.log('Removed node.');
  1007. node.parentNode.removeChild(node);
  1008. };
  1009. let hide = (node) => {
  1010. if (!node)
  1011. return false;
  1012. console.log('Hid node.');
  1013. _setAttribute.call(node, 'style', 'display:none!important');
  1014. };
  1015. // Yandex search ads in Google Chrome
  1016. if ('attachShadow' in _Element.prototype) {
  1017. let _attachShadow = _Element.prototype.attachShadow;
  1018. _Element.prototype.attachShadow = function() {
  1019. let node = this,
  1020. root = _attachShadow.apply(node, arguments);
  1021. pageUpdateObserver(
  1022. (ms) => {
  1023. for (let m of ms) if (m.addedNodes.length)
  1024. if (adWords.test(root.textContent))
  1025. remove(node.closest('.serp-item'));
  1026. }, root
  1027. );
  1028. return root;
  1029. };
  1030. }
  1031. // prevent/defuse adblock detector
  1032. setInterval(()=>{
  1033. localStorage.ic = '';
  1034. localStorage._mt__data = '';
  1035. },100);
  1036. let _doc_proto = ('cookie' in _Document.prototype) ? _Document.prototype : Object.getPrototypeOf(_document);
  1037. let _cookie = Object.getOwnPropertyDescriptor(_doc_proto, 'cookie');
  1038. if (_cookie) {
  1039. let _set_cookie = Function.prototype.call.bind(_cookie.set);
  1040. _cookie.set = function(value) {
  1041. if (/^(mda=|yp=|ys=|yabs-|__)/.test(value))
  1042. // remove value, set expired
  1043. if (!value.startsWith('yp=')) {
  1044. value = value.replace(/^([^=]+=)[^;]+/,'$1').replace(/(expires=)[\w\s\d,]+/,'$1Thu, 01 Jan 1970 00');
  1045. console.log('expire cookie', value.match(/^[^=]+/)[0]);
  1046. } else {
  1047. let parts = value.split(';');
  1048. let values = parts[0].split('#').filter(part => /\.sp\./.test(part));
  1049. if (values.length)
  1050. values[0] = values[0].replace(/^yp=/, '');
  1051. parts[0] = `yp=${values.join('#')}`;
  1052. value = parts.join(';');
  1053. console.log(`set cookie ${parts[0]}`);
  1054. }
  1055. return _set_cookie(this, value);
  1056. };
  1057. Object.defineProperty(_doc_proto, 'cookie', _cookie);
  1058. }
  1059. // other ads
  1060. _document.addEventListener(
  1061. 'DOMContentLoaded', () => {
  1062. {
  1063. // Generic ads removal and fixes
  1064. let node = _querySelector('.serp-header');
  1065. if (node)
  1066. node.style.marginTop = '0';
  1067. for (node of _querySelectorAll(
  1068. '.serp-adv__head + .serp-item,'+
  1069. '#adbanner,'+
  1070. '.serp-adv,'+
  1071. '.b-spec-adv,'+
  1072. 'div[class*="serp-adv__"]:not(.serp-adv__found):not(.serp-adv__displayed)'
  1073. )) remove(node);
  1074. }
  1075. // Search ads
  1076. function removeSearchAds() {
  1077. for (let node of _querySelectorAll('.serp-item'))
  1078. if (_getAttribute.call(node, 'role') === 'complementary' ||
  1079. adWords.test((node.querySelector('.label')||{}).textContent))
  1080. hide(node);
  1081. }
  1082. // News ads
  1083. function removeNewsAds() {
  1084. let node, block, items, mask, classes,
  1085. masks = [
  1086. { class: '.ads__wrapper', regex: /[^,]*?,[^,]*?\.ads__wrapper/ },
  1087. { class: '.ads__pool', regex: /[^,]*?,[^,]*?\.ads__pool/ }
  1088. ];
  1089. for (node of _querySelectorAll('style[nonce]')) {
  1090. classes = node.innerText.replace(/\{[^}]+\}+/ig, '|').split('|');
  1091. for (block of classes) for (mask of masks)
  1092. if (block.includes(mask.class)) {
  1093. block = block.match(mask.regex)[0];
  1094. items = _querySelectorAll(block);
  1095. for (item of items)
  1096. remove(items[0]);
  1097. }
  1098. }
  1099. }
  1100. // Music ads
  1101. function removeMusicAds() {
  1102. for (let node of _querySelectorAll('.ads-block'))
  1103. remove(node);
  1104. }
  1105. // Mail ads
  1106. function removeMailAds() {
  1107. let slice = Array.prototype.slice,
  1108. nodes = slice.call(_querySelectorAll('.ns-view-folders')),
  1109. node, len, cls;
  1110.  
  1111. for (node of nodes)
  1112. if (!len || len > node.classList.length)
  1113. len = node.classList.length;
  1114.  
  1115. node = nodes.pop();
  1116. while (node) {
  1117. if (node.classList.length > len)
  1118. for (cls of slice.call(node.classList))
  1119. if (cls.indexOf('-') === -1) {
  1120. remove(node);
  1121. break;
  1122. }
  1123. node = nodes.pop();
  1124. }
  1125. }
  1126. // News fixes
  1127. function removePageAdsClass() {
  1128. if (_document.body.classList.contains("b-page_ads_yes")) {
  1129. _document.body.classList.remove("b-page_ads_yes");
  1130. console.log('Page ads class removed.');
  1131. }
  1132. }
  1133. // TV fixes
  1134. function removeTVAds() {
  1135. for (let node of _querySelectorAll('div[class^="_"][data-reactid] > div'))
  1136. if (yadWord.test(node.textContent) || node.querySelector('iframe:not([src])')) {
  1137. if (node.offsetWidth) {
  1138. let pad = _document.createElement('div');
  1139. _setAttribute.call(pad, 'style', `width:${node.offsetWidth}px`);
  1140. node.parentNode.appendChild(pad);
  1141. }
  1142. remove(node);
  1143. }
  1144. }
  1145.  
  1146. if (location.hostname.startsWith('mail.')) {
  1147. pageUpdateObserver(
  1148. function(ms, o) {
  1149. let aside = _querySelector('.mail-Layout-Aside');
  1150. if (aside) {
  1151. o.disconnect();
  1152. pageUpdateObserver(removeMailAds, aside);
  1153. }
  1154. }, _document.body
  1155. );
  1156. removeMailAds();
  1157. } else if (location.hostname.startsWith('music.')) {
  1158. pageUpdateObserver(removeMusicAds, _querySelector('.sidebar'));
  1159. removeMusicAds();
  1160. } else if (location.hostname.startsWith('news.')) {
  1161. pageUpdateObserver(removeNewsAds, _document.body);
  1162. pageUpdateObserver(removePageAdsClass, _document.body, { attributes:true, attributesFilter:['class'] });
  1163. removeNewsAds();
  1164. removePageAdsClass();
  1165. } else if (location.hostname.startsWith('tv.')) {
  1166. pageUpdateObserver(removeTVAds, _document.body);
  1167. removeTVAds();
  1168. } else {
  1169. pageUpdateObserver(removeSearchAds, _querySelector('.main__content'));
  1170. removeSearchAds();
  1171. }
  1172. }
  1173. );
  1174. }
  1175.  
  1176. // Yandex Link Tracking
  1177. if (/^https?:\/\/([^.]+\.)*yandex\.[^/]+/i.test(win.location.href)) {
  1178. // remove banner on the start page
  1179. scriptLander(() => {
  1180. let nt = new nullTools({log: false, trace: true});
  1181. let AwapsJsonAPI_Json = function(...args) {
  1182. console.log('>> new AwapsJsonAPI.Json(', ...args, ')');
  1183. };
  1184. [
  1185. 'setID', 'addImageContent',
  1186. 'sendCounts', 'expand', 'refreshAd'
  1187. ].forEach(name => void(AwapsJsonAPI_Json.prototype[name] = nt.func(null, `AwapsJsonAPI.Json.${name}`)));
  1188. AwapsJsonAPI_Json.prototype.checkBannerVisibility = nt.func(true, 'AwapsJsonAPI.Json.checkBannerVisibility');
  1189. AwapsJsonAPI_Json.prototype.addIframeContent = nt.proxy(function(...args) {
  1190. try {
  1191. let frame = args[1][0].parentNode;
  1192. frame.parentNode.removeChild(frame);
  1193. console.log(`Removed banner placeholder.`);
  1194. } catch(ignore) {
  1195. console.log(`Can't locate frame object to remove.`);
  1196. }
  1197. });
  1198. AwapsJsonAPI_Json.prototype.getHTML = nt.func('', 'AwapsJsonAPI.Json.getHTML');
  1199. AwapsJsonAPI_Json.prototype = nt.proxy(AwapsJsonAPI_Json.prototype);
  1200. AwapsJsonAPI_Json = nt.proxy(AwapsJsonAPI_Json);
  1201. if ('AwapsJsonAPI' in win) {
  1202. console.log('Oops! AwapsJsonAPI already defined.');
  1203. let f = win.AwapsJsonAPI.Json;
  1204. win.AwapsJsonAPI.Json = AwapsJsonAPI_Json;
  1205. if (f && f.prototype)
  1206. f.prototype = AwapsJsonAPI_Json.prototype;
  1207. } else
  1208. nt.define(win, 'AwapsJsonAPI', nt.proxy({
  1209. Json: AwapsJsonAPI_Json
  1210. }));
  1211.  
  1212. let home = win.home || {};
  1213. let parseExport = x => {
  1214. if (!x)
  1215. return x;
  1216. // remove banner placeholder
  1217. if (x.banner && x.banner.cls) {
  1218. let _parent = `.${x.banner.cls.banner__parent}`;
  1219. _document.addEventListener('DOMContentLoaded', () => {
  1220. for (let banner of _document.querySelectorAll(_parent)) {
  1221. _setAttribute.call(banner, 'style', 'display:none!important');
  1222. console.log('Hid banner placeholder.');
  1223. }
  1224. }, false);
  1225. }
  1226.  
  1227. // remove banner data and some other stuff
  1228. delete x.banner;
  1229. delete x.consistency;
  1230. delete x['i-bannerid'];
  1231. delete x['i-counter'];
  1232. delete x['ga-counter'];
  1233. delete x['promo-curtain'];
  1234.  
  1235. return x;
  1236. };
  1237. let home_export = parseExport(home.export);
  1238. Object.defineProperty(home, 'export', {
  1239. get: () => home_export,
  1240. set: x => {
  1241. home_export = parseExport(x);
  1242. }
  1243. });
  1244. nt.define(win, 'home', home);
  1245. }, nullTools, '_setAttribute = _Element.prototype.setAttribute');
  1246.  
  1247. if ('attachShadow' in _Element.prototype) {
  1248. let fakeRoot = () => ({
  1249. firstChild: null,
  1250. appendChild: ()=>null,
  1251. querySelector: ()=>null,
  1252. querySelectorAll: ()=>null
  1253. });
  1254. _Element.prototype.createShadowRoot = fakeRoot;
  1255. let shadows = new WeakMap();
  1256. let _attachShadow = Object.getOwnPropertyDescriptor(_Element.prototype, 'attachShadow');
  1257. _attachShadow.value = function() {
  1258. return shadows.set(this, fakeRoot()).get(this);
  1259. };
  1260. Object.defineProperty(_Element.prototype, 'attachShadow', _attachShadow);
  1261. let _shadowRoot = Object.getOwnPropertyDescriptor(_Element.prototype, 'shadowRoot');
  1262. _shadowRoot.set = () => null;
  1263. _shadowRoot.get = function() {
  1264. return shadows.has(this) ? shadows.get(this) : void 0;
  1265. };
  1266. Object.defineProperty(_Element.prototype, 'shadowRoot', _shadowRoot);
  1267. }
  1268. // Partially based on https://gf.qytechs.cn/en/scripts/22737-remove-yandex-redirect
  1269. let selectors = (
  1270. 'A[onmousedown*="/jsredir"],'+
  1271. 'A[data-vdir-href],'+
  1272. 'A[data-counter]'
  1273. );
  1274. let removeTrackingAttributes = function(link) {
  1275. link.removeAttribute('onmousedown');
  1276. if (link.hasAttribute('data-vdir-href')) {
  1277. link.removeAttribute('data-vdir-href');
  1278. link.removeAttribute('data-orig-href');
  1279. }
  1280. if (link.hasAttribute('data-counter')) {
  1281. link.removeAttribute('data-counter');
  1282. link.removeAttribute('data-bem');
  1283. }
  1284. };
  1285. let removeTracking = function(scope) {
  1286. if (scope instanceof Element)
  1287. for (let link of scope.querySelectorAll(selectors))
  1288. removeTrackingAttributes(link);
  1289. };
  1290. _document.addEventListener('DOMContentLoaded', (e) => removeTracking(e.target));
  1291. (new MutationObserver(
  1292. function(ms) {
  1293. let m, node;
  1294. for (m of ms) for (node of m.addedNodes)
  1295. if (node instanceof HTMLAnchorElement && node.matches(selectors))
  1296. removeTrackingAttributes(node);
  1297. else
  1298. removeTracking(node);
  1299. }
  1300. )).observe(_de, { childList: true, subtree: true });
  1301. }
  1302.  
  1303. // https://gf.qytechs.cn/en/scripts/21937-moonwalk-hdgo-kodik-fix v0.8 (adapted)
  1304. _document.addEventListener(
  1305. 'DOMContentLoaded', function() {
  1306. function log (name) {
  1307. console.log(`Player FIX: Detected ${name} player in ${location.href}`);
  1308. }
  1309. function removeVast (data) {
  1310. if (data && (data.vast || data.reserve_vast || data.vast_button)) {
  1311. console.log('Removed:\ndata.vast', data.vast, '\ndata.reserve_vast', data.reserve_vast, '\ndata.vast_button', data.vast_button);
  1312. delete data.vast;
  1313. delete data.reserve_vast;
  1314. delete data.vast_button;
  1315. if (data.chain) {
  1316. let need = [],
  1317. drop = [],
  1318. links = data.chain.split('.');
  1319. for (let link of links)
  1320. if (!/^vast_|_vast_|_vast$/.test(link))
  1321. need.push(link);
  1322. else
  1323. drop.push(link);
  1324. console.log('Dropped from the chain:', ...drop);
  1325. data.chain = need.join('.');
  1326. }
  1327. }
  1328. return data;
  1329. }
  1330. if (win.video_balancer !== void 0 && win.event_callback !== void 0) {
  1331. log('Moonwalk');
  1332. if (video_balancer.adv_loader)
  1333. removeVast(video_balancer.adv_loader.options);
  1334. if ('_mw_adb' in win)
  1335. Object.defineProperty(win, '_mw_adb', {
  1336. get: () => false,
  1337. set: () => true
  1338. });
  1339. } else if (win.stat_url !== undefined && win.is_html5 !== undefined && win.is_wp8 !== undefined) {
  1340. log('HDGo');
  1341. _document.body.onclick = null;
  1342. let tmp = _document.querySelector('#swtf');
  1343. if (tmp)
  1344. tmp.style.display = 'none';
  1345. if (win.banner_second !== void 0)
  1346. win.banner_second = 0;
  1347. if (win.$banner_ads !== void 0)
  1348. win.$banner_ads = false;
  1349. if (win.$new_ads !== void 0)
  1350. win.$new_ads = false;
  1351. if (win.createCookie !== void 0)
  1352. win.createCookie('popup', 'true', '999');
  1353. if (win.canRunAds !== void 0 && win.canRunAds !== true)
  1354. win.canRunAds = true;
  1355. } else if (win.startKodikPlayer !== void 0) {
  1356. log('Kodik');
  1357. // skip attempt to block access to HD resolutions
  1358. let chainCall = new Proxy({}, { get: () => () => chainCall });
  1359. if ($ && $.prototype && $.prototype.addClass) {
  1360. let $addClass = $.prototype.addClass;
  1361. $.prototype.addClass = function (className) {
  1362. if (className === 'blocked')
  1363. return chainCall;
  1364. return $addClass.apply(this, arguments);
  1365. };
  1366. }
  1367. // remove ad links from the metadata
  1368. let _ajax = win.$.ajax;
  1369. win.$.ajax = (params, ...args) => {
  1370. if (params.success) {
  1371. let _s = params.success;
  1372. params.success = (data, ...args) => _s(removeVast(data), ...args);
  1373. }
  1374. return _ajax(params, ...args);
  1375. }
  1376. } else if (win.getnextepisode && win.uppodEvent) {
  1377. log('Share-Serials.net');
  1378. scriptLander(
  1379. function() {
  1380. let _setInterval = win.setInterval,
  1381. _setTimeout = win.setTimeout,
  1382. _toString = Function.prototype.call.bind(Function.prototype.toString);
  1383. win.setInterval = function(func) {
  1384. if (func instanceof Function && _toString(func).includes('_delay')) {
  1385. let intv = _setInterval.call(
  1386. this, function() {
  1387. _setTimeout.call(
  1388. this, function(intv) {
  1389. clearInterval(intv);
  1390. let timer = _document.querySelector('#timer');
  1391. if (timer)
  1392. timer.click();
  1393. }, 100, intv);
  1394. func.call(this);
  1395. }, 5
  1396. );
  1397.  
  1398. return intv;
  1399. }
  1400. return _setInterval.apply(this, arguments);
  1401. };
  1402. win.setTimeout = function(func) {
  1403. if (func instanceof Function && _toString(func).includes('adv_showed'))
  1404. return _setTimeout.call(this, func, 0);
  1405. return _setTimeout.apply(this, arguments);
  1406. };
  1407. }
  1408. );
  1409. } else if ('ADC' in win) {
  1410. log('vjs-creatives plugin in');
  1411. let replacer = (obj) => {
  1412. for (let name in obj)
  1413. if (obj[name] instanceof Function)
  1414. obj[name] = () => null;
  1415. };
  1416. replacer(win.ADC);
  1417. replacer(win.currentAdSlot);
  1418. }
  1419. UberVK: {
  1420. if (!inIFrame)
  1421. break UberVK;
  1422. let oddNames = 'HD' in win &&
  1423. !Object.getOwnPropertyNames(win).every(n => !n.startsWith('_0x'));
  1424. if (!oddNames)
  1425. break UberVK;
  1426. log('UberVK');
  1427. XMLHttpRequest.prototype.open = () => {
  1428. throw 404;
  1429. };
  1430. }
  1431. }, false
  1432. );
  1433.  
  1434. // Applies wrapper function on the current page and all newly created same-origin iframes
  1435. // This is used to prevent trick which allows to get fresh page API through newly created same-origin iframes
  1436. function deepWrapAPI(wrapper) {
  1437. let wrapped = new WeakSet();
  1438. let wrapAPI = root => {
  1439. wrapper(root);
  1440. wrapped.add(root);
  1441. };
  1442. wrapAPI(win);
  1443.  
  1444. let _contentWindow = Object.getOwnPropertyDescriptor(HTMLIFrameElement.prototype, 'contentWindow');
  1445. let _get_contentWindow = Function.prototype.apply.bind(_contentWindow.get);
  1446. _contentWindow.get = function() {
  1447. let _cw = _get_contentWindow(this, arguments);
  1448. if (_cw && !wrapped.has(_cw))
  1449. try {
  1450. wrapAPI(_cw);
  1451. } catch(ignore) {};
  1452. return _cw;
  1453. };
  1454. Object.defineProperty(HTMLIFrameElement.prototype, 'contentWindow', _contentWindow);
  1455. }
  1456.  
  1457. // piguiqproxy.com / zmctrack.net circumvention prevention
  1458. scriptLander(
  1459. () => {
  1460. // special workaround in case when zmctrack does manage to consistently start before my script
  1461. if (/[/.]sinoptik\.(ua|com\.ru)$/.test(location.hostname))
  1462. for (let prop of ['blur']) {
  1463. let desc = Object.getOwnPropertyDescriptor(win, prop);
  1464. if (!desc || desc.configurable)
  1465. Object.defineProperty(win, prop, {
  1466. configurable: false,
  1467. get: () => (desc && desc.value || void 0),
  1468. set: () => null
  1469. });
  1470. }
  1471. // main script
  1472. deepWrapAPI(root => {
  1473. if (root.location.hostname === 'www.kinopoisk.ru' || root.location.hostname.endsWith('.kinopoisk.ru'))
  1474. return; // temporary fix, for some reason replacing xhr.prototype.open triggers their detector
  1475. let _proto = void 0;
  1476. try {
  1477. _proto = root.XMLHttpRequest.prototype;
  1478. } catch(ignore) {
  1479. return;
  1480. };
  1481. let _open = _proto.open;
  1482. // blacklist of third-party domains requests to which are ignored
  1483. let blacklist = /[/.@](amgload\.net|dsn-fishki\.ru|kingoablc\.com|klcheck\.com|piguiqproxy\.com|rcdn\.pro|smcheck\.org|zmctrack\.net)([:/]|$)/i;
  1484. // blacklist of domains where all third-party requests are ignored
  1485. let ondomains = /(^|[/.@])oane\.ws($|[:/])/i;
  1486. // highly suspicious URLs
  1487. let suspicious = /^https?:\/\/(csp-)?([a-z0-9]{6}){1,2}\.ru\//i;
  1488. let on_get_ban = /^https?:\/\/(csp-)?([a-z0-9]{6}){1,2}\.ru\/([a-z0-9/]{40,}|[a-z0-9]{8,}|ad\/banner\/.+)$/i;
  1489. let on_post_ban = /^https?:\/\/(csp-)?([a-z0-9]{6}){1,2}\.ru\/([a-z0-9]{6,})$/i;
  1490. let yandex_direct = /^https?:\/\/(yandex(\.[a-z]{2,3}){1,2}\/(images\/[a-z0-9/_-]{40,}|j?clck\/.*)|[^.]+\.yandex\.net\/static\/main\.js(\?.*)?)$/i;
  1491.  
  1492. let xhrStopList = new WeakSet();
  1493.  
  1494. function checkRequest(fname, method, url) {
  1495. if (blacklist.test(url) ||
  1496. ondomains.test(location.hostname) && !ondomains.test(url) ||
  1497. method === 'GET' && on_get_ban.test(url) ||
  1498. method === 'POST' && on_post_ban.test(url) ||
  1499. yandex_direct.test(url)) {
  1500. console.log(`Blocked ${fname} ${method} request:`, url);
  1501. return true;
  1502. }
  1503. if (suspicious.test(url))
  1504. console.warn(`Suspicious ${fname} ${method} request:`, url);
  1505. return false;
  1506. }
  1507.  
  1508. _proto.open = function open() {
  1509. if (checkRequest('xhr', ...arguments)) {
  1510. xhrStopList.add(this);
  1511. return;
  1512. }
  1513. return _open.apply(this, arguments);
  1514. };
  1515. ['send', 'setRequestHeader', 'getAllResponseHeaders'].forEach(
  1516. name => {
  1517. let func = _proto[name];
  1518. _proto[name] = function(...args) {
  1519. let _res = null;
  1520. if (!xhrStopList.has(this))
  1521. _res = func.apply(this, args);
  1522. //console.log(_res);debugger;
  1523. return _res;
  1524. }
  1525. }
  1526. );
  1527.  
  1528. let _fetch = root.fetch;
  1529. root.fetch = (...args) => {
  1530. let url = args[0];
  1531. let method = args[1] ? args[1].method : void 0;
  1532. if (args[0] instanceof Request) {
  1533. url = args[0].url;
  1534. method = args[0].method;
  1535. }
  1536. if (checkRequest('fetch', method, url))
  1537. return new Promise(() => null);
  1538. return _fetch.call(root, ...args);
  1539. };
  1540. });
  1541.  
  1542. win.stop = () => {
  1543. console.warn('window.stop() ...y tho?');
  1544. for (let sheet of _document.styleSheets)
  1545. if (sheet.disabled) {
  1546. sheet.disabled = false;
  1547. console.log('Re-enabled:', sheet);
  1548. }
  1549. }
  1550. }, deepWrapAPI
  1551. );
  1552. return;
  1553.  
  1554. // === Helper functions ===
  1555.  
  1556. // function to search and remove nodes by content
  1557. // selector - standard CSS selector to define set of nodes to check
  1558. // words - regular expression to check content of the suspicious nodes
  1559. // params - object with multiple extra parameters:
  1560. // .log - display log in the console
  1561. // .hide - set display to none instead of removing from the page
  1562. // .parent - parent node to remove if content is found in the child node
  1563. // .siblings - number of simling nodes to remove (excluding text nodes)
  1564. let scRemove = (node) => node.parentNode.removeChild(node);
  1565. let scHide = function(node) {
  1566. let style = _getAttribute.call(node, 'style') || '',
  1567. hide = ';display:none!important;';
  1568. if (style.indexOf(hide) < 0)
  1569. _setAttribute.call(node, 'style', style + hide);
  1570. };
  1571.  
  1572. function scissors (selector, words, scope, params) {
  1573. let logger = (...args) => { if (params.log) console.log(...args) };
  1574. if (!scope.contains(_document.body))
  1575. logger('[s] scope', scope);
  1576. let remFunc = (params.hide ? scHide : scRemove),
  1577. iterFunc = (params.siblings > 0 ? 'nextElementSibling' : 'previousElementSibling'),
  1578. toRemove = [],
  1579. siblings;
  1580. for (let node of scope.querySelectorAll(selector)) {
  1581. // drill up to a parent node if specified, break if not found
  1582. if (params.parent) {
  1583. let old = node;
  1584. node = node.closest(params.parent);
  1585. if (node === null || node.contains(scope)) {
  1586. logger('[s] went out of scope with', old);
  1587. continue;
  1588. }
  1589. }
  1590. logger('[s] processing', node);
  1591. if (toRemove.includes(node))
  1592. continue;
  1593. if (words.test(node.innerHTML)) {
  1594. // skip node if already marked for removal
  1595. logger('[s] marked for removal');
  1596. toRemove.push(node);
  1597. // add multiple nodes if defined more than one sibling
  1598. siblings = Math.abs(params.siblings) || 0;
  1599. while (siblings) {
  1600. node = node[iterFunc];
  1601. if (!node) break; // can't go any further - exit
  1602. logger('[s] adding sibling node', node);
  1603. toRemove.push(node);
  1604. siblings -= 1;
  1605. }
  1606. }
  1607. }
  1608. let toSkip = [];
  1609. for (let node of toRemove)
  1610. if (!toRemove.every(other => other === node || !node.contains(other)))
  1611. toSkip.push(node);
  1612. if (toRemove.length)
  1613. logger(`[s] proceeding with ${params.hide?'hide':'removal'} of`, toRemove, `skip`, toSkip);
  1614. for (let node of toRemove) if (!toSkip.includes(node))
  1615. remFunc(node);
  1616. }
  1617.  
  1618. // function to perform multiple checks if ads inserted with a delay
  1619. // by default does 30 checks withing a 3 seconds unless nonstop mode specified
  1620. // also does 1 extra check when a page completely loads
  1621. // selector and words - passed dow to scissors
  1622. // params - object with multiple extra parameters:
  1623. // .log - display log in the console
  1624. // .root - selector to narrow down scope to scan;
  1625. // .observe - if true then check will be performed continuously;
  1626. // Other parameters passed down to scissors.
  1627. function gardener(selector, words, params) {
  1628. let logger = (...args) => { if(params.log) console.log(...args) };
  1629. params = params || {};
  1630. logger(`[gardener] selector: '${selector}' detector: ${words} options: ${JSON.stringify(params)}`);
  1631. let scope;
  1632. let globalScope = [_de];
  1633. let domLoaded = false;
  1634. let getScope = root => root ? _de.querySelectorAll(root) : globalScope;
  1635. let onevent = e => {
  1636. logger(`[gardener] cleanup on ${Object.getPrototypeOf(e)} "${e.type}"`);
  1637. for (let node of scope)
  1638. scissors(selector, words, node, params);
  1639. };
  1640. let repeater = n => {
  1641. if (!domLoaded && n) {
  1642. setTimeout(repeater, 500, n - 1);
  1643. scope = getScope(params.root);
  1644. if (!scope) // exit if the root element is not present on the page
  1645. return 0;
  1646. onevent({type: 'Repeater'});
  1647. }
  1648. };
  1649. repeater(20);
  1650. _document.addEventListener(
  1651. 'DOMContentLoaded', (e) => {
  1652. domLoaded = true;
  1653. // narrow down scope to a specific element
  1654. scope = getScope(params.root);
  1655. if (!scope) // exit if the root element is not present on the page
  1656. return 0;
  1657. logger('[g] scope', scope);
  1658. // add observe mode if required
  1659. if (params.observe) {
  1660. let params = { childList:true, subtree: true };
  1661. let observer = new MutationObserver(
  1662. function(ms) {
  1663. for (let m of ms)
  1664. if (m.addedNodes.length)
  1665. onevent(m);
  1666. }
  1667. );
  1668. for (let node of scope)
  1669. observer.observe(node, params);
  1670. logger('[g] observer enabled');
  1671. }
  1672. onevent(e);
  1673. }, false);
  1674. // wait for a full page load to do one extra cut
  1675. win.addEventListener('load', onevent, false);
  1676. }
  1677.  
  1678. // wrap popular methods to open a new tab to catch specific behaviours
  1679. function createWindowOpenWrapper(openFunc) {
  1680. let _createElement = _Document.prototype.createElement,
  1681. _appendChild = _Element.prototype.appendChild,
  1682. fakeNative = (f) => (f.toString = () => `function ${f.name}() { [native code] }`);
  1683.  
  1684. let nt = new nullTools();
  1685. fakeNative(openFunc);
  1686.  
  1687. let parser = _createElement.call(_document, 'a');
  1688. let openWhitelist = (url, parent) => {
  1689. parser.href = url;
  1690. return parser.hostname === 'www.imdb.com' || parser.hostname === 'www.kinopoisk.ru' ||
  1691. parent.hostname === 'radikal.ru' && url === void 0;
  1692. };
  1693.  
  1694. let redefineOpen = (root) => {
  1695. if ('open' in root) {
  1696. let _open = root.open.bind(root);
  1697. nt.define(root, 'open', (...args) => {
  1698. if (openWhitelist(args[0], location)) {
  1699. console.log('Whitelisted popup:', ...args);
  1700. return _open(...args);
  1701. }
  1702. return openFunc(...args);
  1703. });
  1704. }
  1705. };
  1706. redefineOpen(win);
  1707.  
  1708. function createElement() {
  1709. '[native code]';
  1710. let el = _createElement.apply(this, arguments);
  1711. // redefine window.open in first-party frames
  1712. if (el instanceof HTMLIFrameElement || el instanceof HTMLObjectElement)
  1713. el.addEventListener('load', (e) => {
  1714. try {
  1715. redefineOpen(e.target.contentWindow);
  1716. } catch(ignore) {}
  1717. }, false);
  1718. return el;
  1719. }
  1720. fakeNative(createElement);
  1721.  
  1722. let redefineCreateElement = (obj) => {
  1723. for (let root of [obj.document, _Document.prototype]) if ('createElement' in root)
  1724. nt.define(root, 'createElement', createElement);
  1725. };
  1726. redefineCreateElement(win);
  1727.  
  1728. // wrap window.open in newly added first-party frames
  1729. _Element.prototype.appendChild = function appendChild() {
  1730. '[native code]';
  1731. let el = _appendChild.apply(this, arguments);
  1732. if (el instanceof HTMLIFrameElement)
  1733. try {
  1734. redefineOpen(el.contentWindow);
  1735. redefineCreateElement(el.contentWindow);
  1736. } catch(ignore) {}
  1737. return el;
  1738. };
  1739. fakeNative(_Element.prototype.appendChild);
  1740. }
  1741.  
  1742. // Function to catch and block various methods to open a new window with 3rd-party content.
  1743. // Some advertisement networks went way past simple window.open call to circumvent default popup protection.
  1744. // This funciton blocks window.open, ability to restore original window.open from an IFRAME object,
  1745. // ability to perform an untrusted (not initiated by user) click on a link, click on a link without a parent
  1746. // node or simply a link with piece of javascript code in the HREF attribute.
  1747. function preventPopups() {
  1748. // call sandbox-me if in iframe and not whitelisted
  1749. if (inIFrame) {
  1750. win.top.postMessage({ name: 'sandbox-me', href: win.location.href }, '*');
  1751. return;
  1752. }
  1753.  
  1754. scriptLander(() => {
  1755. let nt = new nullTools({log:true});
  1756. let open = (...args) => {
  1757. '[native code]';
  1758. console.warn('Site attempted to open a new window', ...args);
  1759. return {
  1760. document: nt.proxy({
  1761. write: nt.func({}, 'write'),
  1762. writeln: nt.func({}, 'writeln')
  1763. }),
  1764. location: nt.proxy({})
  1765. };
  1766. };
  1767.  
  1768. createWindowOpenWrapper(open);
  1769.  
  1770. console.log('Popup prevention enabled.');
  1771. }, nullTools, createWindowOpenWrapper);
  1772. }
  1773.  
  1774. // Helper function to close background tab if site opens itself in a new tab and then
  1775. // loads a 3rd-party page in the background one (thus performing background redirect).
  1776. function preventPopunders() {
  1777. // create "close_me" event to call high-level window.close()
  1778. let eventName = `close_me_${Math.random().toString(36).substr(2)}`;
  1779. let callClose = () => {
  1780. console.log('close call');
  1781. window.close();
  1782. };
  1783. window.addEventListener(eventName, callClose, true);
  1784.  
  1785. scriptLander(() => {
  1786. // get host of a provided URL with help of an anchor object
  1787. // unfortunately new URL(url, window.location) generates wrong URL in some cases
  1788. let parseURL = _document.createElement('A');
  1789. let getHost = url => {
  1790. parseURL.href = url;
  1791. return parseURL.hostname
  1792. };
  1793. // site went to a new tab and attempts to unload
  1794. // call for high-level close through event
  1795. let closeWindow = () => window.dispatchEvent(new CustomEvent(eventName, {}));
  1796. // check is URL local or goes to different site
  1797. let isLocal = (url) => {
  1798. if (url === location.pathname || url === location.href)
  1799. return true; // URL points to current pathname or full address
  1800. let host = getHost(url);
  1801. let site = location.hostname;
  1802. return host !== '' && // URLs with unusual protocol may have empty 'host'
  1803. (site === host || site.endsWith(`.${host}`) || host.endsWith(`.${site}`));
  1804. };
  1805.  
  1806. let _open = window.open.bind(window);
  1807. let open = (...args) => {
  1808. '[native code]';
  1809. let url = args[0];
  1810. if (url && isLocal(url))
  1811. window.addEventListener('beforeunload', closeWindow, true);
  1812. return _open(...args);
  1813. };
  1814.  
  1815. createWindowOpenWrapper(open);
  1816.  
  1817. console.log("Background redirect prevention enabled.");
  1818. }, `let eventName="${eventName}"`, nullTools, createWindowOpenWrapper);
  1819. }
  1820.  
  1821. // Mix between check for popups and popunders
  1822. // Significantly more agressive than both and can't be used as universal solution
  1823. function preventPopMix() {
  1824. if (inIFrame) {
  1825. win.top.postMessage({ name: 'sandbox-me', href: win.location.href }, '*');
  1826. return;
  1827. }
  1828.  
  1829. // create "close_me" event to call high-level window.close()
  1830. let eventName = `close_me_${Math.random().toString(36).substr(2)}`;
  1831. let callClose = () => {
  1832. console.log('close call');
  1833. window.close();
  1834. };
  1835. window.addEventListener(eventName, callClose, true);
  1836.  
  1837. scriptLander(() => {
  1838. let _open = window.open,
  1839. parseURL = _document.createElement('A');
  1840. // get host of a provided URL with help of an anchor object
  1841. // unfortunately new URL(url, window.location) generates wrong URL in some cases
  1842. let getHost = (url) => {
  1843. parseURL.href = url;
  1844. return parseURL.host;
  1845. };
  1846. // site went to a new tab and attempts to unload
  1847. // call for high-level close through event
  1848. let closeWindow = () => {
  1849. _open(window.location,'_self');
  1850. window.dispatchEvent(new CustomEvent(eventName, {}));
  1851. };
  1852. // check is URL local or goes to different site
  1853. function isLocal(url) {
  1854. let loc = window.location;
  1855. if (url === loc.pathname || url === loc.href)
  1856. return true; // URL points to current pathname or full address
  1857. let host = getHost(url),
  1858. site = loc.host;
  1859. if (host === '')
  1860. return false; // URLs with unusual protocol may have empty 'host'
  1861. if (host.length > site.length)
  1862. [site, host] = [host, site];
  1863. return site.includes(host, site.length - host.length);
  1864. }
  1865.  
  1866. // add check for redirect for 5 seconds, then disable it
  1867. function checkRedirect() {
  1868. window.addEventListener('beforeunload', closeWindow, true);
  1869. setTimeout(closeWindow=>window.removeEventListener('beforeunload', closeWindow, true), 5000, closeWindow);
  1870. }
  1871.  
  1872. function open(url, name) {
  1873. '[native code]';
  1874. if (url && isLocal(url) && (!name || name === '_blank')) {
  1875. console.warn('Suspicious local new window', arguments);
  1876. checkRedirect();
  1877. return _open.apply(this, arguments);
  1878. }
  1879. console.warn('Blocked attempt to open a new window', arguments);
  1880. return {
  1881. document: {
  1882. write: () => {},
  1883. writeln: () => {}
  1884. }
  1885. };
  1886. }
  1887.  
  1888. function clickHandler(e) {
  1889. let link = e.target,
  1890. url = link.href||'';
  1891. if (e.targetParentNode && e.isTrusted || link.target !== '_blank') {
  1892. console.log('Link', link, 'were created dinamically, but looks fine.');
  1893. return true;
  1894. }
  1895. if (isLocal(url) && link.target === '_blank') {
  1896. console.log('Suspicious local link', link);
  1897. checkRedirect();
  1898. return;
  1899. }
  1900. console.log('Blocked suspicious click on a link', link);
  1901. e.stopPropagation();
  1902. e.preventDefault();
  1903. }
  1904.  
  1905. createWindowOpenWrapper(open, clickHandler);
  1906.  
  1907. console.log("Mixed popups prevention enabled.");
  1908. }, `let eventName="${eventName}"`, createWindowOpenWrapper);
  1909. }
  1910. // External listener for case when site known to open popups were loaded in iframe
  1911. // It will sandbox any iframe which will send message 'forbid.popups' (preventPopups sends it)
  1912. // Some sites replace frame's window.location with data-url to run in clean context
  1913. if (!inIFrame) window.addEventListener(
  1914. 'message', function(e) {
  1915. if (!e.data || e.data.name !== 'sandbox-me' || !e.data.href)
  1916. return;
  1917. let src = e.data.href;
  1918. for (let frame of _document.querySelectorAll('iframe'))
  1919. if (frame.contentWindow === e.source) {
  1920. if (frame.hasAttribute('sandbox')) {
  1921. if (!frame.sandbox.contains('allow-popups'))
  1922. return; // exit frame since it's already sandboxed and popups are blocked
  1923. // remove allow-popups if frame already sandboxed
  1924. frame.sandbox.remove('allow-popups');
  1925. } else
  1926. // set sandbox mode for troublesome frame and allow scripts, forms and a few other actions
  1927. // technically allowing both scripts and same-origin allows removal of the sandbox attribute,
  1928. // but to apply content must be reloaded and this script will re-apply it in the result
  1929. frame.setAttribute('sandbox','allow-forms allow-scripts allow-presentation allow-top-navigation allow-same-origin');
  1930. console.log('Disallowed popups from iframe', frame);
  1931.  
  1932. // reload frame content to apply restrictions
  1933. if (!src) {
  1934. src = frame.src;
  1935. console.log('Unable to get current iframe location, reloading from src', src);
  1936. } else
  1937. console.log('Reloading iframe with URL', src);
  1938. frame.src = 'about:blank';
  1939. frame.src = src;
  1940. }
  1941. }, false
  1942. );
  1943.  
  1944. function selectiveEval() {
  1945. scriptLander(() => {
  1946. let nt = new nullTools();
  1947. let _eval = win.eval.bind(window);
  1948. nt.define(win, 'eval', function(...args) {
  1949. if (/_0x|location\s*?=|location.href\s*?=|location.assign\(|open\(/i.test(args[0])) {
  1950. console.log(`Skipped eval of ${args[0].slice(0, 512)}\u2026`);
  1951. return null;
  1952. }
  1953. return _eval(...args);
  1954. });
  1955. }, nullTools);
  1956. }
  1957.  
  1958. // === Scripts for specific domains ===
  1959.  
  1960. let scripts = {};
  1961. // prevent popups and redirects block
  1962. // Popups
  1963. scripts.preventPopups = {
  1964. other: [
  1965. 'biqle.ru',
  1966. 'chaturbate.com',
  1967. 'dfiles.ru',
  1968. 'eporner.eu',
  1969. 'hentaiz.org',
  1970. 'mirrorcreator.com',
  1971. 'online-multy.ru',
  1972. 'radikal.ru', 'rumedia.ws',
  1973. 'thepiratebay.org',
  1974. 'unionpeer.com',
  1975. 'zippyshare.com'
  1976. ],
  1977. now: preventPopups
  1978. };
  1979. // Popunders (background redirect)
  1980. scripts.preventPopunders = {
  1981. other: [
  1982. 'lostfilm-online.ru',
  1983. 'mediafire.com', 'megapeer.org', 'megapeer.ru',
  1984. 'perfectgirls.net'
  1985. ],
  1986. now: preventPopunders
  1987. };
  1988. // PopMix (both types of popups encountered on site)
  1989. scripts['openload.co'] = {
  1990. other: ['oload.tv', 'oload.info'],
  1991. now: () => {
  1992. let nt = new nullTools();
  1993. nt.define(win, 'CNight', win.CoinHive);
  1994. if (location.pathname.startsWith('/embed/')) {
  1995. nt.define(win, 'BetterJsPop', {
  1996. add: ((a, b) => console.warn('BetterJsPop.add', a, b)),
  1997. config: ((o) => console.warn('BetterJsPop.config', o)),
  1998. Browser: { isChrome: true }
  1999. });
  2000. nt.define(win, 'isSandboxed', nt.func(null));
  2001. nt.define(win, 'adblock', false);
  2002. nt.define(win, 'adblock2', false);
  2003. } else preventPopMix();
  2004. }
  2005. };
  2006. scripts['turbobit.net'] = preventPopMix;
  2007.  
  2008. scripts['tapochek.net'] = () => {
  2009. // workaround for moradu.com/apu.php load error handler script, not sure which ad network is this
  2010. let _appendChild = Object.getOwnPropertyDescriptor(_Node.prototype, 'appendChild');
  2011. let _appendChild_value = _appendChild.value;
  2012. _appendChild.value = function appendChild(node) {
  2013. if (this === _document.body)
  2014. if ((node instanceof HTMLScriptElement || node instanceof HTMLStyleElement) &&
  2015. /^https?:\/\/[0-9a-f]{15}\.com\/\d+(\/|\.css)$/.test(node.src) ||
  2016. node instanceof HTMLDivElement && node.style.zIndex > 900000 &&
  2017. node.style.backgroundImage.includes('R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7'))
  2018. throw '...eenope!';
  2019. return _appendChild_value.apply(this, arguments);
  2020. };
  2021. Object.defineProperty(_Node.prototype, 'appendChild', _appendChild);
  2022.  
  2023. // disable window focus tricks and changing location
  2024. let focusHandlerName = /\WfocusAchieved\(/
  2025. let _toString = Function.prototype.call.bind(Function.prototype.toString);
  2026. let _setInterval = win.setInterval;
  2027. win.setInterval = (...args) => {
  2028. if (args.length && focusHandlerName.test(_toString(args[0]))) {
  2029. console.log('skip setInterval for', ...args);
  2030. return -1;
  2031. }
  2032. return _setInterval(...args);
  2033. };
  2034. let _addEventListener = win.addEventListener;
  2035. win.addEventListener = function(...args) {
  2036. if (args.length && args[0] === 'focus' && focusHandlerName.test(_toString(args[1]))) {
  2037. console.log('skip addEventListener for', ...args);
  2038. return void 0;
  2039. }
  2040. return _addEventListener.apply(this, args);
  2041. };
  2042.  
  2043. // generic popup prevention
  2044. preventPopups();
  2045. };
  2046.  
  2047. scripts['rustorka.com'] = {
  2048. other: ['rustorka.lib', 'rustorka.net'],
  2049. now: () => scriptLander(() => {
  2050. let crumbler = () => {
  2051. // crumble suspicious cookies
  2052. let base = '=; expires=Thu, 01 Jan 1970 00:00:01 UTC; Max-Age=-99999999; path=/';
  2053. console.log('cookies', _document.cookie);
  2054. for (let name of ['adblock', 'gophp', '_692293176245', '_692293176246'])
  2055. _document.cookie = `${name}${base}`;
  2056. for (let name of ['st2', 'st3']) {
  2057. _document.cookie = `${name}${base}forum`;
  2058. _document.cookie = `${name}${base}forum/`;
  2059. }
  2060. console.log('cookies', _document.cookie);
  2061. };
  2062. _document.addEventListener('DOMContentLoaded', crumbler, false);
  2063. crumbler();
  2064.  
  2065. let nt = new nullTools({trace: true});
  2066. nt.define(win, 'syka', false);
  2067. nt.define(win, '_692293176244', location.href);
  2068. [
  2069. 'MTLuxup', 'MTAdSniper', 'MTutarg', 'MTUAatar', 'MTcityAds', 'MTmxMark',
  2070. 'MTmxMark2', 'MTmdnt', 'MTrfDumedia', 'MXsmTDS', 'MTritorno', 'MTadvice',
  2071. 'cyka', 'MTAdTraff', 'MTExebid', 'MXsockFound'
  2072. ].forEach(name => nt.define(win, name, nt.func(null, name)));
  2073. let _eval_def = Object.getOwnPropertyDescriptor(win, 'eval');
  2074. if (!_eval_def)
  2075. return;
  2076. let _eval_val = _eval_def.value;
  2077. _eval_def.value = (...args) => {
  2078. if (args[0] && args[0].includes('antiadblock'))
  2079. return console.log('Anti-AdBlock script may run another day, but not today.');
  2080. return _eval_val.apply(this, args);
  2081. };
  2082. Object.defineProperty(win, 'eval', _eval_def);
  2083. win.open = (...args) => {
  2084. console.warn(`Site attempted to open "${args[0]}" in a new window.`);
  2085. location.replace(location.href);
  2086. return null;
  2087. };
  2088. window.addEventListener('DOMContentLoaded', () => {
  2089. let link = void 0;
  2090. _document.body.addEventListener('mousedown', e => {
  2091. link = e.target.closest('a, select, #fancybox-title-wrap');
  2092. }, false);
  2093. let _open = window.open.bind(window);
  2094. let _getAttribute = _Element.prototype.getAttribute;
  2095. win.open = (...args) => {
  2096. let url = args[0];
  2097. if (link instanceof HTMLAnchorElement) {
  2098. // third-party post links
  2099. let href = _getAttribute.call(link, 'href');
  2100. if (link.classList.contains('postLink') &&
  2101. !link.matches(`a[href*="${location.hostname}"]`) &&
  2102. (href === url || link.href === url))
  2103. return _open(...args);
  2104. // onclick # links
  2105. if (href === '#' && /window\.open/.test(_getAttribute.call(link, 'onclick')))
  2106. return _open(...args);
  2107. // force local links to load in the current window
  2108. if (href[0] === '/' || href.startsWith('./') || href.includes(`//${location.hostname}/`))
  2109. location.assign(href);
  2110. }
  2111. // list of image hostings under upload picture button (new comment)
  2112. if (link instanceof HTMLSelectElement &&
  2113. !url.includes(location.hostname) &&
  2114. link.value === url)
  2115. return _open(...args);
  2116. // open screenshot in a new window
  2117. if (link instanceof HTMLSpanElement &&
  2118. link.id === 'fancybox-title-wrap')
  2119. return _open(...args);
  2120. // looks like tabunder
  2121. if (link === null && url === location.href)
  2122. location.replace(url); // reload current page
  2123. // other cases
  2124. console.warn(`Site attempted to open "${url}" in a new window. Source: `, link);
  2125. return {};
  2126. };
  2127. }, true);
  2128. }, nullTools)
  2129. };
  2130.  
  2131. // other
  2132. scripts['1tv.ru'] = {
  2133. other: ['mediavitrina.ru'],
  2134. now: () => scriptLander(() => {
  2135. let nt = new nullTools();
  2136. nt.define(win, 'EUMPAntiblockConfig', nt.proxy({url: '//www.1tv.ru/favicon.ico'}));
  2137. let disablePlugins = {
  2138. 'antiblock': false,
  2139. 'stat1tv': false
  2140. };
  2141. let _EUMPConfig = void 0;
  2142. let _EUMPConfig_set = x => {
  2143. if (x.plugins) {
  2144. x.plugins = x.plugins.filter(plugin => (plugin in disablePlugins) ? !(disablePlugins[plugin] = true) : true);
  2145. console.warn(`Player plugins: active [${x.plugins}], disabled [${Object.keys(disablePlugins).filter(x => disablePlugins[x])}]`);
  2146. }
  2147. _EUMPConfig = x;
  2148. };
  2149. if ('EUMPConfig' in win)
  2150. _EUMPConfig_set(win.EUMPConfig);
  2151. Object.defineProperty(win, 'EUMPConfig', {
  2152. enumerable: true,
  2153. get: () => _EUMPConfig,
  2154. set: _EUMPConfig_set
  2155. });
  2156. }, nullTools)
  2157. };
  2158.  
  2159. scripts['2picsun.ru'] = {
  2160. other: [
  2161. 'pics2sun.ru', '3pics-img.ru'
  2162. ],
  2163. now: () => {
  2164. Object.defineProperty(navigator, 'userAgent', {value: 'googlebot'});
  2165. }
  2166. };
  2167.  
  2168. scripts['4pda.ru'] = {
  2169. now: () => {
  2170. // https://gf.qytechs.cn/en/scripts/14470-4pda-unbrender
  2171. let isForum = location.pathname.startsWith('/forum/'),
  2172. remove = node => (node && node.parentNode.removeChild(node)),
  2173. hide = node => (node && (node.style.display = 'none'));
  2174.  
  2175. // save links to non-overridden functions to use later
  2176. let protectedElems;
  2177. // protect/hide changed attributes in case site attempt to restore them
  2178. function styleProtector(eventMode) {
  2179. let _toLowerCase = String.prototype.toLowerCase,
  2180. isStyleText = (t) => (_toLowerCase.call(t) === 'style'),
  2181. protectedElems = new WeakMap();
  2182. function protoOverride(element, functionName, isStyleCheck, returnIfProtected) {
  2183. let originalFunction = element.prototype[functionName];
  2184. element.prototype[functionName] = function wrapper() {
  2185. if (protectedElems.has(this) && isStyleCheck(arguments[0]))
  2186. return returnIfProtected(this, arguments);
  2187. return originalFunction.apply(this, arguments);
  2188. };
  2189. }
  2190. protoOverride(Element, 'removeAttribute', isStyleText, () => undefined);
  2191. protoOverride(Element, 'hasAttribute', isStyleText, (_this) => protectedElems.get(_this) !== null);
  2192. protoOverride(Element, 'setAttribute', isStyleText, (_this, args) => protectedElems.set(_this, args[1]));
  2193. protoOverride(Element, 'getAttribute', isStyleText, (_this) => protectedElems.get(_this));
  2194. if (!eventMode)
  2195. return protectedElems;
  2196. let e = _document.createEvent('Event');
  2197. e.initEvent('protoOverride', false, false);
  2198. window.protectedElems = protectedElems;
  2199. window.dispatchEvent(e);
  2200. }
  2201. if (!isFirefox)
  2202. protectedElems = styleProtector(false);
  2203. else {
  2204. let script = _document.createElement('script');
  2205. script.textContent = `(${styleProtector.toString()})(true);`;
  2206. window.addEventListener(
  2207. 'protoOverride', function protoOverrideCallback() {
  2208. if (win.protectedElems) {
  2209. protectedElems = win.protectedElems;
  2210. delete win.protectedElems;
  2211. }
  2212. _document.removeEventListener('protoOverride', protoOverrideCallback, true);
  2213. }, true
  2214. );
  2215. _appendChild(script);
  2216. _removeChild(script);
  2217. }
  2218.  
  2219. // clean a page
  2220. window.addEventListener(
  2221. 'DOMContentLoaded', function() {
  2222. let width = () => window.innerWidth || _de.clientWidth || _document.body.clientWidth || 0;
  2223. let height = () => window.innerHeight || _de.clientHeight || _document.body.clientHeight || 0;
  2224.  
  2225. HeaderAds: {
  2226. // hide ads above HEADER
  2227. let header = _document.querySelector('.drop-search');
  2228. if (!header) {
  2229. console.warn('Unable to locate header element');
  2230. break HeaderAds;
  2231. }
  2232. header = header.parentNode.parentNode;
  2233. for (let itm of header.parentNode.children)
  2234. if (itm !== header)
  2235. hide(itm);
  2236. else break;
  2237. }
  2238.  
  2239. if (isForum) {
  2240. let itm = _document.querySelector('#logostrip');
  2241. if (itm)
  2242. remove(itm.parentNode.nextSibling);
  2243. // clear background in the download frame
  2244. if (location.pathname.startsWith('/forum/dl/')) {
  2245. let setBackground = node => _setAttribute.call(
  2246. node,
  2247. 'style', (_getAttribute.call(node, 'style') || '') +
  2248. ';background-color:#4ebaf6!important'
  2249. );
  2250. setBackground(_document.body);
  2251. for (let itm of _document.querySelectorAll('body > div'))
  2252. if (!itm.querySelector('.dw-fdwlink, .content') && !itm.classList.contains('footer'))
  2253. remove(itm);
  2254. else
  2255. setBackground(itm);
  2256. }
  2257. // exist from DOMContentLoaded since the rest is not for forum
  2258. return;
  2259. }
  2260.  
  2261. FixNavMenu: {
  2262. // restore DevDB link in the navigation
  2263. let itm = _document.querySelector('#nav li a[href$="/devdb/"]')
  2264. if (!itm) {
  2265. console.warn('Unable to locate navigation menu');
  2266. break FixNavMenu;
  2267. }
  2268. itm.closest('li').style.display = 'block';
  2269. // hide ad link from the navigation
  2270. hide(_document.querySelector('#nav li a[data-dotrack]'));
  2271. }
  2272. SidebarAds: {
  2273. // remove ads from sidebar
  2274. let aside = _document.querySelectorAll('[class]:not([id]) > [id]:not([class]) > :first-child + :last-child');
  2275. if (!aside.length) {
  2276. console.warn('Unable to locate sidebar');
  2277. break SidebarAds;
  2278. }
  2279. let post;
  2280. for (let side of aside) {
  2281. console.log('Processing potential sidebar:', side);
  2282. for (let itm of Array.from(side.children)) {
  2283. post = itm.classList.contains('post');
  2284. if (itm.querySelector('iframe') && !post)
  2285. remove(itm);
  2286. if (itm.querySelector('script, a[target="_blank"] > img') && !post || !itm.children.length)
  2287. hide(itm);
  2288. }
  2289. }
  2290. }
  2291.  
  2292. _document.body.setAttribute('style', (_document.body.getAttribute('style')||'')+';background-color:#E6E7E9!important');
  2293.  
  2294. let extra = 'background-image:none!important;background-color:transparent!important',
  2295. fakeStyles = new WeakMap(),
  2296. styleProxy = {
  2297. get: (target, prop) => fakeStyles.get(target)[prop] || target[prop],
  2298. set: function(target, prop, value) {
  2299. let fakeStyle = fakeStyles.get(target);
  2300. ((prop in fakeStyle) ? fakeStyle : target)[prop] = value;
  2301. return true;
  2302. }
  2303. };
  2304. for (let itm of _document.querySelectorAll('[id]:not(A), A')) {
  2305. if (!(itm.offsetWidth > 0.95 * width() &&
  2306. itm.offsetHeight > 0.85 * height()))
  2307. continue;
  2308. if (itm.tagName !== 'A') {
  2309. fakeStyles.set(itm.style, {
  2310. 'backgroundImage': itm.style.backgroundImage,
  2311. 'backgroundColor': itm.style.backgroundColor
  2312. });
  2313.  
  2314. try {
  2315. Object.defineProperty(itm, 'style', {
  2316. value: new Proxy(itm.style, styleProxy),
  2317. enumerable: true
  2318. });
  2319. } catch (e) {
  2320. console.log('Unable to protect style property.', e);
  2321. }
  2322.  
  2323. if (protectedElems)
  2324. protectedElems.set(itm, _getAttribute.call(itm, 'style'));
  2325.  
  2326. _setAttribute.call(itm, 'style', `${(_getAttribute.call(itm, 'style') || '')};${extra}`);
  2327. }
  2328. if (itm.tagName === 'A') {
  2329. if (protectedElems)
  2330. protectedElems.set(itm, _getAttribute.call(itm, 'style'));
  2331. _setAttribute.call(itm, 'style', 'display:none!important');
  2332. }
  2333. }
  2334. }
  2335. );
  2336. }
  2337. };
  2338.  
  2339. scripts['adhands.ru'] = () => scriptLander(() => {
  2340. let nt = new nullTools();
  2341. try {
  2342. let _adv;
  2343. Object.defineProperty(win, 'adv', {
  2344. get: () => _adv,
  2345. set: (v) => {
  2346. console.log('Blocked advert on adhands.ru.');
  2347. nt.define(v, 'advert', '');
  2348. _adv = v;
  2349. }
  2350. });
  2351. } catch (ignore) {
  2352. if (!win.adv)
  2353. console.log('Unable to locate advert on adhands.ru.');
  2354. else {
  2355. console.log('Blocked advert on adhands.ru.');
  2356. nt.define(win.adv, 'advert', '');
  2357. }
  2358. }
  2359. }, nullTools);
  2360.  
  2361. scripts['all-episodes.tv'] = () => {
  2362. let nt = new nullTools();
  2363. nt.define(win, 'perX1', 2);
  2364. createStyle('#advtss, #ad3, a[href*="/ad.admitad.com/"] { display:none!important }');
  2365. };
  2366.  
  2367. scripts['allhentai.ru'] = () => {
  2368. selectiveEval();
  2369. preventPopups();
  2370. scriptLander(() => {
  2371. let _onerror = Object.getOwnPropertyDescriptor(HTMLElement.prototype, 'onerror');
  2372. if (!_onerror)
  2373. return;
  2374. _onerror.set = (...args) => console.log(args[0].toString());
  2375. Object.defineProperty(HTMLElement.prototype, 'onerror', _onerror);
  2376. });
  2377. };
  2378.  
  2379. scripts['allmovie.pro'] = {
  2380. other: ['rufilmtv.org'],
  2381. dom: function() {
  2382. // pretend to be Android to make site use different played for ads
  2383. if (isSafari)
  2384. return;
  2385. Object.defineProperty(navigator, 'userAgent', {
  2386. get: function(){
  2387. 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';
  2388. },
  2389. enumerable: true
  2390. });
  2391. }
  2392. };
  2393.  
  2394. scripts['anidub-online.ru'] = {
  2395. other: ['anime.anidub.com', 'online.anidub.com'],
  2396. dom: function() {
  2397. if (win.ogonekstart1)
  2398. win.ogonekstart1 = () => console.log("Fire in the hole!");
  2399. },
  2400. now: () => createStyle([
  2401. '.background {background: none!important;}',
  2402. '.background > script + div,'+
  2403. '.background > script ~ div:not([id]):not([class]) + div[id][class]'+
  2404. '{display:none!important}'
  2405. ])
  2406. };
  2407.  
  2408. scripts['drive2.ru'] = () => {
  2409. gardener('.c-block:not([data-metrika="recomm"]),.o-grid__item', />Реклама<\//i);
  2410. scriptLander(() => {
  2411. let _d2 = void 0;
  2412. Object.defineProperty(win, 'd2', {
  2413. get: () => _d2,
  2414. set: o => {
  2415. if (o === _d2)
  2416. return true;
  2417. _d2 = new Proxy(o, {
  2418. set: (tgt, prop, val) => {
  2419. if (['brandingRender', 'dvReveal', '__dv'].includes(prop))
  2420. val = () => null;
  2421. tgt[prop] = val;
  2422. return true;
  2423. }
  2424. });
  2425. }
  2426. });
  2427. });
  2428. };
  2429.  
  2430. scripts['fastpic.ru'] = () => {
  2431. let nt = new nullTools();
  2432. // Had to obfuscate property name to avoid triggering anti-obfuscation on gf.qytechs.cn -_- (Exception 403012)
  2433. nt.define(win, `_0x${'4955'}`, []);
  2434. };
  2435.  
  2436. scripts['fishki.net'] = () => {
  2437. scriptLander(() => {
  2438. let nt = new nullTools();
  2439. let fishki = {};
  2440. nt.define(fishki, 'adv', nt.proxy({
  2441. afterAdblockCheck: nt.func(null),
  2442. refreshFloat: nt.func(null)
  2443. }));
  2444. nt.define(fishki, 'is_adblock', false);
  2445. nt.define(win, 'fishki', fishki);
  2446. }, nullTools);
  2447. gardener('.drag_list > .drag_element, .list-view > .paddingtop15, .post-wrap', /543769|Новости\sпартнеров|Полезная\sреклама/);
  2448. };
  2449.  
  2450. scripts['gidonline.club'] = () => createStyle('.tray > div[style] {display: none!important}');
  2451.  
  2452. scripts['hdgo.cc'] = {
  2453. other: ['46.30.43.38', 'couber.be'],
  2454. now: () => (new MutationObserver(
  2455. (ms) => {
  2456. let m, node;
  2457. for (m of ms) for (node of m.addedNodes)
  2458. if (node.tagName instanceof HTMLScriptElement && _getAttribute.call(node, 'onerror') !== null)
  2459. node.removeAttribute('onerror');
  2460. }
  2461. )).observe(_document.documentElement, { childList:true, subtree: true })
  2462. };
  2463.  
  2464. scripts['gismeteo.ru'] = {
  2465. other: ['gismeteo.ua'],
  2466. now: () => gardener('div > script', /AdvManager/i, { observe: true, parent: 'div' })
  2467. };
  2468.  
  2469. scripts['hdrezka.ag'] = () => {
  2470. Object.defineProperty(win, 'ab', { value: false, enumerable: true });
  2471. gardener('div[id][onclick][onmouseup][onmousedown]', /onmouseout/i);
  2472. };
  2473.  
  2474. scripts['hqq.tv'] = () => scriptLander(() => {
  2475. // disable anti-debugging in hqq.tv player
  2476. 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);
  2477. deepWrapAPI(root => {
  2478. // skip obfuscated stuff and a few other calls
  2479. let _setInterval = root.setInterval,
  2480. _setTimeout = root.setTimeout,
  2481. _toString = root.Function.prototype.call.bind(root.Function.prototype.toString);
  2482. root.setInterval = (...args) => {
  2483. let fun = args[0];
  2484. if (fun instanceof Function) {
  2485. let text = _toString(fun),
  2486. skip = text.includes('check();') || isObfuscated(text);
  2487. console.warn('setInterval', text, 'skip', skip);
  2488. if (skip) return -1;
  2489. }
  2490. return _setInterval.apply(this, args);
  2491. };
  2492. let wrappedST = new WeakSet();
  2493. root.setTimeout = (...args) => {
  2494. let fun = args[0];
  2495. if (fun instanceof Function) {
  2496. let text = _toString(fun),
  2497. skip = fun.name === 'check' || isObfuscated(text);
  2498. if (!wrappedST.has(fun)) {
  2499. console.warn('setTimeout', text, 'skip', skip);
  2500. wrappedST.add(fun);
  2501. }
  2502. if (skip) return;
  2503. }
  2504. return _setTimeout.apply(this, args);
  2505. };
  2506. // skip 'debugger' call
  2507. let _eval = root.eval;
  2508. root.eval = text => {
  2509. if (typeof text === 'string' && text.includes('debugger;')) {
  2510. console.warn('skip eval', text);
  2511. return;
  2512. }
  2513. _eval(text);
  2514. };
  2515. // Prevent RegExpt + toString trick
  2516. let _proto = void 0;
  2517. try {
  2518. _proto = root.RegExp.prototype;
  2519. } catch(ignore) {
  2520. return;
  2521. }
  2522. let _RE_tS = Object.getOwnPropertyDescriptor(_proto, 'toString');
  2523. let _RE_tSV = _RE_tS.value || _RE_tS.get();
  2524. Object.defineProperty(_proto, 'toString', {
  2525. enumerable: _RE_tS.enumerable,
  2526. configurable: _RE_tS.configurable,
  2527. get: () => _RE_tSV,
  2528. set: val => console.warn('Attempt to change toString for', this, 'with', _toString(val))
  2529. });
  2530. });
  2531. }, deepWrapAPI);
  2532.  
  2533. scripts['hideip.me'] = {
  2534. now: () => scriptLander(() => {
  2535. let _innerHTML = Object.getOwnPropertyDescriptor(_Element.prototype, 'innerHTML');
  2536. let _set_innerHTML = _innerHTML.set;
  2537. let _innerText = Object.getOwnPropertyDescriptor(HTMLElement.prototype, 'innerText');
  2538. let _get_innerText = _innerText.get;
  2539. let div = _document.createElement('div');
  2540. _innerHTML.set = function(...args) {
  2541. _set_innerHTML.call(div, args[0].replace('i','a'));
  2542. if (args[0] && /[рp][еe]кл/.test(_get_innerText.call(div))||
  2543. /(\d\d\d?\.){3}\d\d\d?:\d/.test(_get_innerText.call(this)) ) {
  2544. console.log('Anti-Adblock killed.');
  2545. return true;
  2546. }
  2547. _set_innerHTML.apply(this, args);
  2548. };
  2549. Object.defineProperty(_Element.prototype, 'innerHTML', _innerHTML);
  2550. Object.defineProperty(win, 'adblock', {
  2551. get: () => false,
  2552. set: () => null,
  2553. enumerable: true
  2554. });
  2555. let _$ = {};
  2556. let _$_map = new WeakMap();
  2557. let _gOPD = Object.getOwnPropertyDescriptor(Object, 'getOwnPropertyDescriptor');
  2558. let _val_gOPD = _gOPD.value;
  2559. _gOPD.value = function(...args) {
  2560. let _res = _val_gOPD.apply(this, args);
  2561. if (args[0] instanceof Window && (args[1] === '$' || args[1] === 'jQuery')) {
  2562. delete _res.get;
  2563. delete _res.set;
  2564. _res.value = win[args[1]];
  2565. }
  2566. return _res;
  2567. };
  2568. Object.defineProperty(Object, 'getOwnPropertyDescriptor', _gOPD);
  2569. let getJQWrap = (n) => {
  2570. let name = n;
  2571. return {
  2572. enumerable: true,
  2573. get: () => _$[name],
  2574. set: x => {
  2575. if (_$_map.has(x)) {
  2576. _$[name] = _$_map.get(x);
  2577. return true;
  2578. }
  2579. if (x === _$.$ || x === _$.jQuery) {
  2580. _$[name] = x;
  2581. return true;
  2582. }
  2583. _$[name] = new Proxy(x, {
  2584. apply: (t, o, args) => {
  2585. let _res = t.apply(o, args);
  2586. if (_$_map.has(_res.is))
  2587. _res.is = _$_map.get(_res.is);
  2588. else {
  2589. let _is = _res.is;
  2590. _res.is = function(...args) {
  2591. if (args[0] === ':hidden')
  2592. return false;
  2593. return _is.apply(this, args);
  2594. };
  2595. _$_map.set(_is, _res.is);
  2596. }
  2597. return _res;
  2598. }
  2599. });
  2600. _$_map.set(x, _$[name]);
  2601. return true;
  2602. }
  2603. };
  2604. };
  2605. Object.defineProperty(win, '$', getJQWrap('$'));
  2606. Object.defineProperty(win, 'jQuery', getJQWrap('jQuery'));
  2607. let _dP = Object.defineProperty;
  2608. Object.defineProperty = function(...args) {
  2609. if (args[0] instanceof Window && (args[1] === '$' || args[1] === 'jQuery'))
  2610. return void 0;
  2611. return _dP.apply(this, args);
  2612. };
  2613. })
  2614. };
  2615.  
  2616. scripts['igra-prestoloff.cx'] = () => scriptLander(() => {
  2617. let nt = new nullTools();
  2618. /*jslint evil: true */ // yes, evil, I know
  2619. let _write = _document.write.bind(_document);
  2620. /*jslint evil: false */
  2621. nt.define(_document, 'write', t => {
  2622. let id = t.match(/jwplayer\("(\w+)"\)/i);
  2623. if (id && id[1])
  2624. return _write(`<div id="${id[1]}"></div>${t}`);
  2625. return _write('');
  2626. });
  2627. });
  2628.  
  2629. scripts['imageban.ru'] = () => { Object.defineProperty(win, 'V7x1J', { get: () => null }); };
  2630.  
  2631. scripts['ivi.ru'] = () => {
  2632. let _xhr_open = win.XMLHttpRequest.prototype.open;
  2633. win.XMLHttpRequest.prototype.open = function(method, url, ...args) {
  2634. if (typeof url === 'string')
  2635. if (url.endsWith('/track'))
  2636. return;
  2637. return _xhr_open.call(this, method, url, ...args);
  2638. };
  2639. let _responseText = Object.getOwnPropertyDescriptor(XMLHttpRequest.prototype, 'responseText');
  2640. let _responseText_get = _responseText.get;
  2641. _responseText.get = function() {
  2642. if (this.__responseText__)
  2643. return this.__responseText__;
  2644. let res = _responseText_get.apply(this, arguments);
  2645. let o;
  2646. try {
  2647. if (res)
  2648. o = JSON.parse(res);
  2649. } catch(ignore) {};
  2650. let changed = false;
  2651. if (o && o.result) {
  2652. if (o.result instanceof Array &&
  2653. 'adv_network_logo_url' in o.result[0]) {
  2654. o.result = [];
  2655. changed = true;
  2656. }
  2657. if (o.result.show_adv) {
  2658. o.result.show_adv = false;
  2659. changed = true;
  2660. }
  2661. }
  2662. if (changed) {
  2663. console.log('changed response >>', o);
  2664. res = JSON.stringify(o);
  2665. }
  2666. this.__responseText__ = res;
  2667. return res;
  2668. };
  2669. Object.defineProperty(XMLHttpRequest.prototype, 'responseText', _responseText);
  2670. };
  2671.  
  2672. scripts['kinopoisk.ru'] = {
  2673. now: () => {
  2674. // set no-branding body style
  2675. createStyle('body:not(#id) { background: #d5d5d5 url(/images/noBrandBg.jpg) 50% 0 no-repeat !important }');
  2676. },
  2677. dom: () => {
  2678. (style => style ? style.parentNode.removeChild(style) : console.log('Unable to locate branding style.')
  2679. )(_de.querySelector('#branding-style'));
  2680. }
  2681. };
  2682.  
  2683. scripts['korrespondent.net'] = {
  2684. now: () => scriptLander(() => {
  2685. let nt = new nullTools();
  2686. nt.define(win, 'holder', function(id) {
  2687. let div = _document.getElementById(id);
  2688. if (!div)
  2689. return;
  2690. if (div.parentNode.classList.contains('col__sidebar')) {
  2691. div.parentNode.appendChild(div);
  2692. div.style.height = '300px';
  2693. }
  2694. });
  2695. }, nullTools),
  2696. dom: () => {
  2697. for (let frame of _document.querySelectorAll('.unit-side-informer > iframe'))
  2698. frame.parentNode.style.width = '1px';
  2699. }
  2700. };
  2701.  
  2702. scripts['mail.ru'] = {
  2703. other: ['ok.ru'],
  2704. now: () => scriptLander(() => {
  2705. let nt = new nullTools();
  2706. // Trick to prevent mail.ru from removing 3rd-party styles
  2707. nt.define(Object.prototype, 'restoreVisibility', nt.func(null), false);
  2708. // Disable some of their counters
  2709. nt.define(win, 'rb_counter', nt.func(null, 'rb_counter'));
  2710. if (location.hostname === 'e.mail.ru')
  2711. nt.define(win, 'aRadar', nt.func(null, 'aRadar'));
  2712. else
  2713. nt.define(win, 'createRadar', nt.func(nt.func(null, 'aRadar'), 'createRadar'));
  2714.  
  2715. {
  2716. let redefiner = {
  2717. apply: (target, thisArg, args) => {
  2718. let res = void 0;
  2719. let skipLog = (name, ret) => (...args) => (console.log(`Skip ${name}(`, ...args, ')'), ret);
  2720. if (target._name === 'mrg-smokescreen/Welter')
  2721. res = {
  2722. isWelter: () => true,
  2723. wrap: skipLog(`${target._name}.wrap`)
  2724. };
  2725. if (target._name === 'mrg-smokescreen/StyleSheets')
  2726. res = {
  2727. update: skipLog(`${target._name}.update`),
  2728. remove: skipLog(`${target._name}.remove`),
  2729. insert: skipLog(`${target._name}.insert`)
  2730. };
  2731. if (target._name === 'mrg-honeypot/main')
  2732. res = {
  2733. check: skipLog(`${target._name}.check`, false)
  2734. };
  2735. if (target._name.startsWith('advert/rb/slot'))
  2736. res = {
  2737. slot: '0',
  2738. get: () => null,
  2739. getHTML: () => null,
  2740. createBlock: () => null,
  2741. onRedirect: () => null
  2742. };
  2743. if (target._name.startsWith('OK/banners/'))
  2744. res = {
  2745. activate: skipLog(`${target._name}.activate`),
  2746. deactivate: skipLog(`${target._name}.deactivate`)
  2747. };
  2748. if (!res)
  2749. res = target.apply(thisArg, args);
  2750. if (target._name === 'advert/RB') {
  2751. res.getSlots = () => [];
  2752. res.load._name = target._name + '.load';
  2753. res.load = new Proxy(res.load, redefiner);
  2754. }
  2755. console.log(target._name, '(',...args,') >>', res);
  2756. return res;
  2757. }
  2758. };
  2759.  
  2760. let wrapAdFuncs = {
  2761. apply: (target, thisArg, args) => {
  2762. let module = args[0];
  2763. if (typeof module === 'string')
  2764. if (module.startsWith('mrg-smoke') ||
  2765. module.startsWith('mrg-context') ||
  2766. module.startsWith('mrg-honeypot') ||
  2767. module.startsWith('advert') ||
  2768. module.startsWith('OK/banner') ||
  2769. module === 'OK/Smokescreen') {
  2770. let fun = args[args.length-1];
  2771. fun._name = module;
  2772. args[args.length-1] = new Proxy(fun, redefiner);
  2773. }// else
  2774. // console.log('Define:', args[0]);
  2775. return target.apply(thisArg, args);
  2776. }
  2777. };
  2778. let wrapDefine = def => {
  2779. if (!def)
  2780. return;
  2781. console.log('define =', def);
  2782. def = new Proxy(def, wrapAdFuncs);
  2783. def._name = 'define';
  2784. return def;
  2785. };
  2786. let _define = wrapDefine(win.define);
  2787. Object.defineProperty(win, 'define', {
  2788. get: () => _define,
  2789. set: x => {
  2790. if (_define === x)
  2791. return true;
  2792. _define = wrapDefine(x);
  2793. return true;
  2794. }
  2795. });
  2796. }
  2797.  
  2798. // Disable page scrambler on mail.ru to let extensions easily block ads there
  2799. let logger = {
  2800. apply: (target, thisArg, args) => {
  2801. let res = target.apply(thisArg, args);
  2802. console.log(`${target._name}(`, ...args, `) >>`, res);
  2803. return res;
  2804. }
  2805. };
  2806.  
  2807. function defineLocator(root) {
  2808. let _locator;
  2809.  
  2810. function wrapLocator(locator) {
  2811. if ('setup' in locator) {
  2812. let _setup = locator.setup;
  2813. locator.setup = function(o) {
  2814. if ('enable' in o) {
  2815. o.enable = false;
  2816. console.log('Disable mimic mode.');
  2817. }
  2818. if ('links' in o) {
  2819. o.links = [];
  2820. console.log('Call with empty list of sheets.');
  2821. }
  2822. return _setup.call(this, o);
  2823. };
  2824. locator.insertSheet = () => false;
  2825. locator.wrap = () => false;
  2826. }
  2827. try {
  2828. let names = [];
  2829. for (let name in locator)
  2830. if (locator[name] instanceof Function && name !== 'transform') {
  2831. locator[name]._name = "locator." + name;
  2832. locator[name] = new Proxy(locator[name], logger);
  2833. names.push(name);
  2834. }
  2835. console.log(`[locator] wrapped properties: ${names.length ? names.join(', ') : '[empty]'}`);
  2836. } catch(e) {
  2837. console.log(e);
  2838. }
  2839. _locator = locator;
  2840. }
  2841.  
  2842. if ('locator' in root && root.locator) {
  2843. console.log('Found existing "locator" object. :|', root.locator);
  2844. wrapLocator(root.locator);
  2845. }
  2846.  
  2847. let loc_desc = Object.getOwnPropertyDescriptor(root, 'locator');
  2848. if (!loc_desc || loc_desc.set !== wrapLocator)
  2849. try {
  2850. Object.defineProperty(root, 'locator', {
  2851. set: wrapLocator,
  2852. get: () => _locator
  2853. });
  2854. } catch (err) {
  2855. console.log('Unable to redefine "locator" object!!!', err);
  2856. }
  2857. }
  2858.  
  2859. function defineDetector(mr) {
  2860. let _honeyPot;
  2861. let __ = mr._ || {};
  2862. let check = function() {
  2863. __.STUCK_IN_POT = false;
  2864. return false;
  2865. };
  2866. check._name = 'honeyPot.check';
  2867. let setHoneyPot = o => {
  2868. console.log('[honeyPot]', o);
  2869. o.check = new Proxy(check, logger);
  2870. _honeyPot = o;
  2871. };
  2872. if ('honeyPot' in mr)
  2873. setHoneyPot(mr.honeyPot);
  2874. Object.defineProperty(mr, 'honeyPot', {
  2875. get: () => _honeyPot,
  2876. set: setHoneyPot
  2877. });
  2878.  
  2879. __ = new Proxy(__, {
  2880. get: (t, p) => t[p],
  2881. set: (t, p, v) => {
  2882. console.log(`mr._.${p} =`, v);
  2883. t[p] = v;
  2884. return true;
  2885. }
  2886. });
  2887. mr._ = __;
  2888. }
  2889.  
  2890. function defineAdd(mr) {
  2891. let _add;
  2892. let addWrapper = {
  2893. apply: (tgt, that, args) => {
  2894. let module = args[0];
  2895. if (module.startsWith('ad')) {
  2896. console.log('Skip module:', module);
  2897. return;
  2898. }
  2899. return logger.apply(tgt, that, args);
  2900. }
  2901. };
  2902. let setMrAdd = v => {
  2903. v._name = 'mr.add';
  2904. v = new Proxy(v, addWrapper);
  2905. _add = v;
  2906. };
  2907. if ('add' in mr)
  2908. setMrAdd(mr.add);
  2909. Object.defineProperty(mr, 'add', {
  2910. get: () => _add,
  2911. set: setMrAdd
  2912. });
  2913.  
  2914. }
  2915.  
  2916. try {
  2917. let _mr;
  2918. Object.defineProperty(win, 'mr', {
  2919. enumerable: true,
  2920. get: () => _mr,
  2921. set: (v) => {
  2922. if (v === _mr)
  2923. return true;
  2924. console.log('Trapped new "mr" object.');
  2925. defineLocator(v.mimic ? v.mimic : v);
  2926. defineDetector(v);
  2927. defineAdd(v);
  2928. _mr = v;
  2929. }
  2930. });
  2931. if (!('mr' in win))
  2932. throw 'Wat!?';
  2933. } catch (e) {
  2934. console.log('Found existing "mr" object.', e instanceof TypeError ? '' : e);
  2935. defineLocator(win.mr);
  2936. defineDetector(win.mr);
  2937. defineAdd(win.mr);
  2938. }
  2939. }, nullTools)
  2940. };
  2941.  
  2942. scripts['oms.matchat.online'] = () => scriptLander(() => {
  2943. let _rmpGlobals = void 0;
  2944. Object.defineProperty(win, 'rmpGlobals', {
  2945. get: () => _rmpGlobals,
  2946. set: x => {
  2947. if (x === _rmpGlobals)
  2948. return true;
  2949. _rmpGlobals = new Proxy(x, {
  2950. get: (obj, name) => {
  2951. if (name === 'adBlockerDetected')
  2952. return false;
  2953. return obj[name];
  2954. },
  2955. set: (obj, name, val) => {
  2956. if (name === 'adBlockerDetected')
  2957. console.warn('rmpGlobals.adBlockerDetected =', val)
  2958. else
  2959. obj[name] = val;
  2960. return true;
  2961. }
  2962. });
  2963. }
  2964. });
  2965. });
  2966.  
  2967. scripts['megogo.net'] = {
  2968. now: () => {
  2969. let nt = new nullTools();
  2970. nt.define(win, 'adBlock', false);
  2971. nt.define(win, 'showAdBlockMessage', nt.func(null));
  2972. }
  2973. };
  2974.  
  2975. scripts['naruto-base.su'] = () => gardener('div[id^="entryID"],.block', /href="http.*?target="_blank"/i);
  2976.  
  2977. scripts['newdeaf-online.net'] = {
  2978. dom: () => {
  2979. let adNodes = _document.querySelectorAll('.ads');
  2980. if (!adNodes)
  2981. return;
  2982. let getter = x => {
  2983. let val = x;
  2984. return () => (console.warn('read .ads', name, val), val);
  2985. };
  2986. let setter = x => console.warn('skip write .ads', name, x);
  2987. for (let adNode of adNodes)
  2988. for (let name of ['innerHTML'])
  2989. Object.defineProperty(adNode, name, {
  2990. get: getter(ads[name]),
  2991. set: setter
  2992. });
  2993. }
  2994. };
  2995.  
  2996. scripts['overclockers.ru'] = {
  2997. now: () => scriptLander(() => {
  2998. let _innerHTML = Object.getOwnPropertyDescriptor(_Element.prototype, 'innerHTML');
  2999. let _set_innerHTML = _innerHTML.set;
  3000. _innerHTML.set = function() {
  3001. if (this === _document.body) {
  3002. console.log('Anti-Adblock killed.');
  3003. return true;
  3004. }
  3005. _set_innerHTML.apply(this, arguments);
  3006. };
  3007. Object.defineProperty(_Element.prototype, 'innerHTML', _innerHTML);
  3008. }),
  3009. dom: () => scriptLander(() => {
  3010. let killed = () => console.log('Anti-Adblock killed.');
  3011. if ('$' in win)
  3012. win.$ = new Proxy($, {
  3013. apply: (tgt, that, args) => {
  3014. let res = tgt.apply(that, args);
  3015. if (res[0] && res[0] === _document.body) {
  3016. res.html = () => killed;
  3017. res.empty = () => killed;
  3018. }
  3019. return res;
  3020. }
  3021. });
  3022. })
  3023. };
  3024. scripts['forums.overclockers.ru'] = {
  3025. now: () => {
  3026. createStyle('.needblock {position: fixed; left: -10000px}');
  3027. Object.defineProperty(win, 'adblck', {
  3028. get: () => 'no',
  3029. set: () => undefined,
  3030. enumerable: true
  3031. });
  3032. }
  3033. };
  3034.  
  3035. scripts['pb.wtf'] = {
  3036. other: ['piratbit.org', 'piratbit.ru'],
  3037. dom: () => {
  3038. // line above topic content and images in the slider in the header
  3039. let remove = node => (console.log('removed', node), node.parentNode.removeChild(node));
  3040. for (let el of _document.querySelectorAll('.release-navbar a, #page_content a')) {
  3041. if (location.hostname === el.hostname &&
  3042. /^\/(\w{3}|exit)\/[\w=/]{20,}$/.test(el.pathname)) {
  3043. remove(el.closest('div, tr'));
  3044. continue;
  3045. }
  3046. // ads in the topic header in case filter above wasn't enough
  3047. let parent = el.closest('tr');
  3048. if (parent && parent.querySelector('span') &&
  3049. parent.querySelector('span').textContent.startsWith('Реклам'))
  3050. remove(parent);
  3051. }
  3052. // casino ad button in random places
  3053. for (let el of _document.querySelectorAll('.btn-group')) {
  3054. el = el.parentNode.parentNode;
  3055. if (el.tagName === 'TH')
  3056. remove(el);
  3057. }
  3058. // ads in comments
  3059. let el = _document.querySelector('tbody[id^="post_"] + tbody:not([id])');
  3060. if (el && el.parentNode.children[2] == el)
  3061. remove(el);
  3062. }
  3063. };
  3064.  
  3065. scripts['pikabu.ru'] = () => gardener('.story', /story__author[^>]+>ads</i, {root: '.inner_wrap', observe: true});
  3066.  
  3067. scripts['peka2.tv'] = () => {
  3068. let bodyClass = 'body--branding';
  3069. let checkNode = node => {
  3070. for (let className of node.classList)
  3071. if (className.includes('banner') || className === bodyClass) {
  3072. _removeAttribute.call(node, 'style');
  3073. node.classList.remove(className);
  3074. for (let attr of Array.from(node.attributes))
  3075. if (attr.name.startsWith('advert'))
  3076. _removeAttribute.call(node, attr.name);
  3077. }
  3078. };
  3079. (new MutationObserver(ms => {
  3080. let m, node;
  3081. for (m of ms) for (node of m.addedNodes)
  3082. if (node instanceof HTMLElement)
  3083. checkNode(node);
  3084. })).observe(_de, {childList: true, subtree: true});
  3085. (new MutationObserver(ms => {
  3086. for (let m of ms)
  3087. checkNode(m.target);
  3088. })).observe(_de, {attributes: true, subtree: true, attributeFilter: ['class']});
  3089. };
  3090.  
  3091. scripts['qaru.site'] = () => {
  3092. let _src = Object.getOwnPropertyDescriptor(HTMLScriptElement.prototype, 'src');
  3093. let _src_set = _src.set;
  3094. _src.set = function(val) {
  3095. if (val.includes('fuckadblock') || val.includes('googlesyndication'))
  3096. return;
  3097. return _src_set.apply(this, arguments);
  3098. };
  3099. Object.defineProperty(HTMLScriptElement.prototype, 'src', _src);
  3100.  
  3101. let _addEventListener = EventTarget.prototype.addEventListener;
  3102. let _toString = Function.prototype.call.bind(Function.prototype.toString);
  3103. EventTarget.prototype.addEventListener = function addEventListener() {
  3104. if (arguments[0] === 'load' && _toString(arguments[1]).includes("_creatBait"))
  3105. return _addEventListener.call(
  3106. this, arguments[0], () => {
  3107. if ('fuckAdBlock' in win)
  3108. win.fuckAdBlock.emitEvent('notDetected');
  3109. }, arguments[2]
  3110. );
  3111. return _addEventListener.apply(this, arguments);
  3112. };
  3113. };
  3114.  
  3115. scripts['qrz.ru'] = {
  3116. now: () => {
  3117. let nt = new nullTools();
  3118. nt.define(win, 'ab', false);
  3119. nt.define(win, 'tryMessage', nt.func(null));
  3120. }
  3121. };
  3122.  
  3123. scripts['razlozhi.ru'] = {
  3124. now: () => {
  3125. for (let func of ['createShadowRoot', 'attachShadow'])
  3126. if (func in _Element.prototype)
  3127. _Element.prototype[func] = function(){
  3128. return this.cloneNode();
  3129. };
  3130. }
  3131. };
  3132.  
  3133. scripts['rbc.ru'] = {
  3134. dom: () => {
  3135. let _preventDefault = Event.prototype.preventDefault;
  3136. Event.prototype.preventDefault = function preventDefault() {
  3137. let t = this.target;
  3138. if (t instanceof HTMLAnchorElement || t.closest('A'))
  3139. throw new Error('an.yandex redirect prevention');
  3140. return _preventDefault.call(this);
  3141. };
  3142.  
  3143. function cleaner(nodes) {
  3144. for (let node of nodes) {
  3145. if (!node.classList || !node.classList.contains('js-yandex-counter'))
  3146. continue;
  3147. node.classList.remove('js-yandex-counter');
  3148. node.removeAttribute('data-yandex-name');
  3149. node.removeAttribute('data-yandex-params');
  3150. }
  3151. }
  3152. cleaner(_de.querySelectorAll('.js-yandex-counter'));
  3153.  
  3154. (new MutationObserver(
  3155. ms => {
  3156. for (let m of ms) cleaner(m.addedNodes);
  3157. }
  3158. )).observe(_de, {childList: true, subtree: true});
  3159. }
  3160. };
  3161.  
  3162. scripts['rp5.ru'] = {
  3163. other: ['rp5.by', 'rp5.kz', 'rp5.ua'],
  3164. now: () => gardener('div[id][class]', /\?AdvertMgmt=|adsbygoogle/, { root: '#content-wrapper', log: true })
  3165. };
  3166.  
  3167. scripts['rutube.ru'] = () => scriptLander(() => {
  3168. let _parse = JSON.parse;
  3169. let _skip_enabled = false;
  3170. JSON.parse = (...args) => {
  3171. let res = _parse(...args),
  3172. log = false;
  3173. if (!res)
  3174. return res;
  3175. // parse player configuration
  3176. if ('appearance' in res || 'video_balancer' in res) {
  3177. log = true;
  3178. if (res.appearance) {
  3179. if ('forbid_seek' in res.appearance && res.appearance.forbid_seek)
  3180. res.appearance.forbid_seek = false;
  3181. if ('forbid_timeline_preview' in res.appearance && res.appearance.forbid_timeline_preview)
  3182. res.appearance.forbid_timeline_preview = false;
  3183. }
  3184. _skip_enabled = !!res.remove_unseekable_blocks;
  3185. //res.advert = [];
  3186. delete res.advert;
  3187. //for (let limit of res.limits)
  3188. // limit.limit = 0;
  3189. delete res.limits;
  3190. //res.yast = null;
  3191. //res.yast_live_online = null;
  3192. delete res.yast;
  3193. delete res.yast_live_online;
  3194. Object.defineProperty(res, 'stat', {
  3195. get: () => [],
  3196. set: () => true,
  3197. enumerable: true
  3198. });
  3199. }
  3200.  
  3201. // parse video configuration
  3202. if ('video_url' in res) {
  3203. log = true;
  3204. if (res.cuepoints && !_skip_enabled)
  3205. for (let point of res.cuepoints) {
  3206. point.is_pause = false;
  3207. point.show_navigation = true;
  3208. point.forbid_seek = false;
  3209. }
  3210. }
  3211.  
  3212. if (log)
  3213. console.log('[rutube]', res);
  3214. return res;
  3215. };
  3216. });
  3217.  
  3218. scripts['simpsonsua.com.ua'] = () => scriptLander(() => {
  3219. let _addEventListener = _Document.prototype.addEventListener;
  3220. _document.addEventListener = function(event, callback) {
  3221. if (event === 'DOMContentLoaded' && callback.toString().includes('show_warning'))
  3222. return;
  3223. return _addEventListener.apply(this, arguments);
  3224. };
  3225. });
  3226.  
  3227. scripts['smotret-anime.ru'] = () => scriptLander(() => {
  3228. deepWrapAPI(root => {
  3229. let _pause = root.Function.prototype.call.bind(root.Audio.prototype.pause);
  3230. let _addEventListener = root.Function.prototype.call.bind(root.Element.prototype.addEventListener);
  3231. let stopper = e => _pause(e.target);
  3232. root.Audio = new Proxy(root.Audio, {
  3233. construct: (audio, args) => {
  3234. let res = new audio(...args);
  3235. _addEventListener(res, 'play', stopper, true);
  3236. return res;
  3237. }
  3238. });
  3239. _createElement = root.Document.prototype.createElement;
  3240. root.Document.prototype.createElement = function createElement() {
  3241. let res = _createElement.apply(this, arguments);
  3242. if (res instanceof HTMLAudioElement)
  3243. _addEventListener(res, 'play', stopper, true);
  3244. return res;
  3245. };
  3246. });
  3247. }, deepWrapAPI);
  3248.  
  3249. scripts['spaces.ru'] = () => {
  3250. gardener('div:not(.f-c_fll) > a[href*="spaces.ru/?Cl="]', /./, { parent: 'div' });
  3251. gardener('.js-banner_rotator', /./, { parent: '.widgets-group' });
  3252. };
  3253.  
  3254. scripts['spam-club.blogspot.co.uk'] = () => {
  3255. let _clientHeight = Object.getOwnPropertyDescriptor(_Element.prototype, 'clientHeight'),
  3256. _clientWidth = Object.getOwnPropertyDescriptor(_Element.prototype, 'clientWidth');
  3257. let wrapGetter = (getter) => {
  3258. let _getter = getter;
  3259. return function() {
  3260. let _size = _getter.apply(this, arguments);
  3261. return _size ? _size : 1;
  3262. };
  3263. };
  3264. _clientHeight.get = wrapGetter(_clientHeight.get);
  3265. _clientWidth.get = wrapGetter(_clientWidth.get);
  3266. Object.defineProperty(_Element.prototype, 'clientHeight', _clientHeight);
  3267. Object.defineProperty(_Element.prototype, 'clientWidth', _clientWidth);
  3268. let _onload = Object.getOwnPropertyDescriptor(HTMLElement.prototype, 'onload'),
  3269. _set_onload = _onload.set;
  3270. _onload.set = function() {
  3271. if (this instanceof HTMLImageElement)
  3272. return true;
  3273. _set_onload.apply(this, arguments);
  3274. };
  3275. Object.defineProperty(HTMLElement.prototype, 'onload', _onload);
  3276. };
  3277.  
  3278. scripts['sport-express.ru'] = () => gardener('.js-relap__item',/>Реклама\s+<\//, {root:'.container', observe: true});
  3279.  
  3280. scripts['sports.ru'] = {
  3281. now: () => {
  3282. gardener('.aside-news-list__item', /aside-news-list__advert/i, {root:'.columns-layout__left', observe: true});
  3283. gardener('.material-list__item', /Реклама/i, {root:'.columns-layout', observe: true});
  3284. // extra functionality: shows/hides panel at the top depending on scroll direction
  3285. createStyle([
  3286. '.user-panel__fixed { transition: top 0.2s ease-in-out!important; }',
  3287. '.user-panel-up { top: -40px!important }'
  3288. ], {id: 'userPanelSlide'}, false);
  3289. },
  3290. dom: () => {
  3291. (function lookForPanel() {
  3292. let panel = _document.querySelector('.user-panel__fixed');
  3293. if (!panel)
  3294. setTimeout(lookForPanel, 100);
  3295. else
  3296. window.addEventListener(
  3297. 'wheel', function(e) {
  3298. if (e.deltaY > 0 && !panel.classList.contains('user-panel-up'))
  3299. panel.classList.add('user-panel-up');
  3300. else if (e.deltaY < 0 && panel.classList.contains('user-panel-up'))
  3301. panel.classList.remove('user-panel-up');
  3302. }, false
  3303. );
  3304. })();
  3305. }
  3306. };
  3307.  
  3308. scripts['stealthz.ru'] = {
  3309. dom: () => {
  3310. // skip timeout
  3311. let $ = _document.querySelector.bind(_document);
  3312. let [timer_1, timer_2] = [$('#timer_1'), $('#timer_2')];
  3313. if (!timer_1 || !timer_2)
  3314. return;
  3315. timer_1.style.display = 'none';
  3316. timer_2.style.display = 'block';
  3317. }
  3318. };
  3319.  
  3320. scripts['xittv.net'] = () => scriptLander(() => {
  3321. let logNames = ['setup', 'trigger', 'on', 'off', 'onReady', 'onError', 'getConfig', 'addPlugin', 'getAdBlock'];
  3322. let skipEvents = ['adComplete', 'adSkipped', 'adBlock', 'adRequest', 'adMeta', 'adImpression', 'adError', 'adTime', 'adStarted', 'adClick'];
  3323. let _jwplayer = void 0;
  3324. Object.defineProperty(win, 'jwplayer', {
  3325. get: () => _jwplayer,
  3326. set: x => {
  3327. _jwplayer = new Proxy(x, {
  3328. apply: (fun, that, args) => {
  3329. let res = fun.apply(that, args);
  3330. res = new Proxy(res, {
  3331. get: (obj, name) => {
  3332. if (logNames.includes(name) && obj[name] instanceof Function)
  3333. return new Proxy(obj[name], {
  3334. apply: (fun, that, args) => {
  3335. if (name === 'setup') {
  3336. let o = args[0];
  3337. if (o)
  3338. delete o.advertising;
  3339. }
  3340. if (name === 'on' || name === 'trigger') {
  3341. let events = typeof args[0] === 'string' ? args[0].split(" ") : null;
  3342. if (events.length === 1 && skipEvents.includes(events[0]))
  3343. return res;
  3344. if (events.length > 1) {
  3345. let names = [];
  3346. for (let event of events)
  3347. if (!skipEvents.includes(event))
  3348. names.push(event);
  3349. if (names.length > 0)
  3350. args[0] = names.join(" ");
  3351. else
  3352. return res;
  3353. }
  3354. }
  3355. let subres = fun.apply(that, args);
  3356. console.warn(`jwplayer().${name}(`, ...args, `) >>`, res);
  3357. return subres;
  3358. }
  3359. });
  3360. return obj[name];
  3361. }
  3362. });
  3363. return res;
  3364. }
  3365. });
  3366. console.log('jwplayer =', x);
  3367. }
  3368. });
  3369. });
  3370.  
  3371. scripts['yap.ru'] = {
  3372. other: ['yaplakal.com'],
  3373. now: () => {
  3374. gardener('form > table[id^="p_row_"]:nth-of-type(2)', /member1438|Administration/);
  3375. gardener('.icon-comments', /member1438|Administration|\/go\/\?http/, {parent:'tr', siblings:-2});
  3376. }
  3377. };
  3378.  
  3379. scripts['rambler.ru'] = {
  3380. other: ['championat.com', 'gazeta.ru', 'lenta.ru', 'media.eagleplatform.com', 'quto.ru', 'rns.online'],
  3381. now: () => scriptLander(() => {
  3382. // Prevent autoplay
  3383. if (!('EaglePlayer' in win)) {
  3384. let _EaglePlayer = void 0;
  3385. Object.defineProperty(win, 'EaglePlayer', {
  3386. enumerable: true,
  3387. get: () => _EaglePlayer,
  3388. set: x => {
  3389. if (x === _EaglePlayer)
  3390. return true;
  3391. _EaglePlayer = new Proxy(x, {
  3392. construct: (targ, args) => {
  3393. let player = new targ(...args);
  3394. if (!player.options) {
  3395. console.log('EaglePlayer: no options', EaglePlayer);
  3396. return player;
  3397. }
  3398. Object.defineProperty(player.options, 'autoplay', {
  3399. get: () => false,
  3400. set: () => true
  3401. });
  3402. Object.defineProperty(player.options, 'scroll', {
  3403. get: () => false,
  3404. set: () => true
  3405. });
  3406. return player;
  3407. }
  3408. });
  3409. }
  3410. });
  3411. let _setAttribute = _Element.prototype.setAttribute;
  3412. let isAutoplay = /^autoplay$/i;
  3413. _Element.prototype.setAttribute = function setAttribute(name) {
  3414. if (!this._stopped && isAutoplay.test(name)) {
  3415. console.log('Prevented assigning autoplay attribute.');
  3416. return null;
  3417. }
  3418. return _setAttribute.apply(this, arguments);
  3419. };
  3420. } else {
  3421. console.log('EaglePlayer function already exists.');
  3422. if (inIFrame) {
  3423. let _setAttribute = _Element.prototype.setAttribute;
  3424. let isAutoplay = /^autoplay$/i;
  3425. _Element.prototype.setAttribute = function setAttribute(name) {
  3426. if (!this._stopped && isAutoplay.test(name)) {
  3427. console.log('Prevented assigning autoplay attribute.');
  3428. this._stopped = true;
  3429. this.play = () => {
  3430. console.log('Prevented attempt to force-start playback.');
  3431. delete this.play;
  3432. };
  3433. return null;
  3434. }
  3435. return _setAttribute.apply(this, arguments);
  3436. };
  3437. }
  3438. }
  3439. if (location.hostname.endsWith('.media.eagleplatform.com'))
  3440. return;
  3441. // prevent ads from loading
  3442. let blockObfuscated = false;
  3443. let obfuscation = /\[[a-z]{4}\("0x\d+"\)\]/i;
  3444. let _toString = Function.prototype.call.bind(Function.prototype.toString);
  3445. let CSSRuleProto = 'cssText' in CSSRule.prototype ? CSSRule.prototype : CSSStyleRule.prototype;
  3446. let _cssText = Object.getOwnPropertyDescriptor(CSSRuleProto, 'cssText');
  3447. let _cssText_get = _cssText.get;
  3448. _cssText.configurable = false;
  3449. _cssText.get = function() {
  3450. let cssText = _cssText_get.call(this);
  3451. if (cssText.includes('content:')) {
  3452. console.warn('Blocked access to suspicious cssText:', cssText.slice(0,60), '\u2026', cssText.length);
  3453. blockObfuscated = true;
  3454. return null;
  3455. }
  3456. return cssText;
  3457. };
  3458. Object.defineProperty(CSSRuleProto, 'cssText', _cssText);
  3459. let _setTimeout = win.setTimeout;
  3460. win.setTimeout = function(f) {
  3461. if (blockObfuscated && obfuscation.test(_toString(f))) {
  3462. console.warn('Stopped setTimeout for:', _toString(f).slice(0,100), '\u2026');
  3463. return null;
  3464. };
  3465. return _setTimeout.apply(this, arguments);
  3466. };
  3467. // fake global Adf object
  3468. let nt = new nullTools();
  3469. let Adf_banner = {};
  3470. [
  3471. 'reloadssp', 'sspScroll',
  3472. 'sspRich', 'ssp'
  3473. ].forEach(name => void(Adf_banner[name] = nt.proxy(() => new Promise(r => r({status: true})))));
  3474. nt.define(win, 'Adf', nt.proxy({
  3475. banner: nt.proxy(Adf_banner)
  3476. }));
  3477. // extra script to remove partner news on gazeta.ru
  3478. if (!location.hostname.includes('gazeta.ru'))
  3479. return;
  3480. (new MutationObserver(
  3481. (ms) => {
  3482. let m, node, header;
  3483. for (m of ms) for (node of m.addedNodes)
  3484. if (node instanceof HTMLDivElement && node.matches('.sausage')) {
  3485. header = node.querySelector('.sausage-header');
  3486. if (header && /новости\s+партн[её]ров/i.test(header.textContent))
  3487. node.style.display = 'none';
  3488. }
  3489. }
  3490. )).observe(_document.documentElement, { childList:true, subtree: true });
  3491. }, `let inIFrame = ${inIFrame}`, nullTools)
  3492. };
  3493.  
  3494. scripts['reactor.cc'] = {
  3495. other: ['joyreactor.cc', 'pornreactor.cc'],
  3496. now: () => {
  3497. selectiveEval();
  3498. scriptLander(() => {
  3499. let nt = new nullTools();
  3500. win.open = function(){
  3501. throw new Error('Redirect prevention.');
  3502. };
  3503. nt.define(win, 'Worker', function(){});
  3504. nt.define(win, 'JRCH', win.CoinHive);
  3505. }, nullTools);
  3506. },
  3507. click: function(e) {
  3508. let node = e.target;
  3509. if (node.nodeType === _Node.ELEMENT_NODE &&
  3510. node.style.position === 'absolute' &&
  3511. node.style.zIndex > 0)
  3512. node.parentNode.removeChild(node);
  3513. },
  3514. dom: function() {
  3515. let words = new RegExp(
  3516. 'блокировщик рекламы'
  3517. .split('')
  3518. .map(function(e){
  3519. return e+'[\u200b\u200c\u200d]*';
  3520. })
  3521. .join('')
  3522. .replace(' ', '\\s*')
  3523. .replace(/[аоре]/g, function(e){
  3524. return ['[аa]','[оo]','[рp]','[еe]']['аоре'.indexOf(e)];
  3525. }),
  3526. 'i'),
  3527. can;
  3528. function deeper(spider) {
  3529. for (let child of spider.childNodes)
  3530. if (words.test(child.innerText))
  3531. if (child.offsetHeight >= 750)
  3532. deeper(child);
  3533. else
  3534. can.push(child);
  3535. }
  3536. function probe() {
  3537. can = [];
  3538. deeper(_document.body);
  3539. for (let spider of can)
  3540. _setAttribute.call(spider, 'style', 'background:none!important');
  3541. }
  3542. (new MutationObserver(probe))
  3543. .observe(_document, { childList:true, subtree:true });
  3544. }
  3545. };
  3546.  
  3547. scripts['auto.ru'] = () => {
  3548. let words = /Реклама|Яндекс.Директ|yandex_ad_/;
  3549. let userAdsListAds = (
  3550. '.listing-list > .listing-item,'+
  3551. '.listing-item_type_fixed.listing-item'
  3552. );
  3553. let catalogAds = (
  3554. 'div[class*="layout_catalog-inline"],'+
  3555. 'div[class$="layout_horizontal"]'
  3556. );
  3557. let otherAds = (
  3558. '.advt_auto,'+
  3559. '.sidebar-block,'+
  3560. '.pager-listing + div[class],'+
  3561. '.card > div[class][style],'+
  3562. '.sidebar > div[class],'+
  3563. '.main-page__section + div[class],'+
  3564. '.listing > tbody'
  3565. );
  3566. gardener(userAdsListAds, words, {root:'.listing-wrap', observe:true});
  3567. gardener(catalogAds, words, {root:'.catalog__page,.content__wrapper', observe:true});
  3568. gardener(otherAds, words);
  3569. };
  3570.  
  3571. scripts['rsload.net'] = {
  3572. load: () => {
  3573. let dis = _document.querySelector('label[class*="cb-disable"]');
  3574. if (dis)
  3575. dis.click();
  3576. },
  3577. click: e => {
  3578. let t = e.target;
  3579. if (t && t.href && (/:\/\/\d+\.\d+\.\d+\.\d+\//.test(t.href)))
  3580. t.href = t.href.replace('://','://rsload.net:rsload.net@');
  3581. }
  3582. };
  3583.  
  3584. let domain;
  3585. // add alternative domain names if present and wrap functions into objects
  3586. for (let name in scripts) {
  3587. if (scripts[name] instanceof Function)
  3588. scripts[name] = { now: scripts[name] };
  3589. for (domain of (scripts[name].other||[])) {
  3590. if (domain in scripts)
  3591. console.log('Error in scripts list. Script for', name, 'replaced script for', domain);
  3592. scripts[domain] = scripts[name];
  3593. }
  3594. delete scripts[name].other;
  3595. }
  3596. // look for current domain in the list and run appropriate code
  3597. domain = _document.domain;
  3598. while (domain.includes('.')) {
  3599. if (domain in scripts) for (let when in scripts[domain])
  3600. switch(when) {
  3601. case 'now':
  3602. scripts[domain][when]();
  3603. break;
  3604. case 'dom':
  3605. _document.addEventListener('DOMContentLoaded', scripts[domain][when], false);
  3606. break;
  3607. default:
  3608. _document.addEventListener (when, scripts[domain][when], false);
  3609. }
  3610. domain = domain.slice(domain.indexOf('.') + 1);
  3611. }
  3612.  
  3613. // Batch script lander
  3614. if (!skipLander)
  3615. landScript(batchLand, batchPrepend);
  3616.  
  3617. { // JS Fixes Tools Menu
  3618. let openOptions = function() {
  3619. let ovl = _createElement('div'),
  3620. inner = _createElement('div');
  3621. ovl.style = (
  3622. 'position: fixed;'+
  3623. 'top:0; left:0;'+
  3624. 'bottom: 0; right: 0;'+
  3625. 'background: rgba(0,0,0,0.85);'+
  3626. 'z-index: 2147483647;'+
  3627. 'padding: 5em'
  3628. );
  3629. inner.style = (
  3630. 'background: whitesmoke;'+
  3631. 'font-size: 10pt;'+
  3632. 'color: black;'+
  3633. 'padding: 1em'
  3634. );
  3635. inner.textContent = 'JS Fixes Tools';
  3636. inner.appendChild(_createElement('br'));
  3637. inner.appendChild(_createElement('br'));
  3638. ovl.addEventListener(
  3639. 'click', function(e) {
  3640. if (e.target === ovl) {
  3641. ovl.parentNode.removeChild(ovl);
  3642. e.preventDefault();
  3643. }
  3644. e.stopPropagation();
  3645. }, false
  3646. );
  3647.  
  3648. let sObjBtn = _createElement('button');
  3649. sObjBtn.onclick = getStrangeObjectsList;
  3650. sObjBtn.textContent = 'Print (in console) list of unusual window properties';
  3651. inner.appendChild(_createElement('br'));
  3652. inner.appendChild(sObjBtn);
  3653.  
  3654. _document.body.appendChild(ovl);
  3655. ovl.appendChild(inner);
  3656. };
  3657.  
  3658. // monitor keys pressed for Ctrl+Alt+Shift+J > s > f code
  3659. let opPos = 0, opKey = ['KeyJ','KeyS','KeyF'];
  3660. _document.addEventListener(
  3661. 'keydown', function(e) {
  3662. if ((e.code === opKey[opPos] || e.location) &&
  3663. (!!opPos || e.altKey && e.ctrlKey && e.shiftKey)) {
  3664. opPos += e.location ? 0 : 1;
  3665. e.stopPropagation();
  3666. e.preventDefault();
  3667. } else
  3668. opPos = 0;
  3669. if (opPos === opKey.length) {
  3670. opPos = 0;
  3671. openOptions();
  3672. }
  3673. }, false
  3674. );
  3675. }
  3676. })();

QingJ © 2025

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