RU AdList JS Fixes

try to take over the world!

当前为 2017-09-30 提交的版本,查看 最新版本

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

QingJ © 2025

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