RU AdList JS Fixes

try to take over the world!

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

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

QingJ © 2025

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