RU AdList JS Fixes

try to take over the world!

当前为 2017-12-19 提交的版本,查看 最新版本

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

QingJ © 2025

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