RU AdList JS Fixes

try to take over the world!

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

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