RU AdList JS Fixes

try to take over the world!

目前為 2018-02-26 提交的版本,檢視 最新版本

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

QingJ © 2025

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