RU AdList JS Fixes

try to take over the world!

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

  1. // ==UserScript==
  2. // @name RU AdList JS Fixes
  3. // @namespace ruadlist_js_fixes
  4. // @version 20170512.1
  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. var 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. _getAttribute = Element.prototype.getAttribute,
  25. _setAttribute = Element.prototype.setAttribute,
  26. _de = document.documentElement,
  27. _appendChild = Document.prototype.appendChild.bind(_de),
  28. _removeChild = Document.prototype.removeChild.bind(_de);
  29.  
  30. // NodeList iterator polyfill (mostly for Safari)
  31. // https://jakearchibald.com/2014/iterators-gonna-iterate/
  32. if (!NodeList.prototype[Symbol.iterator]) {
  33. NodeList.prototype[Symbol.iterator] = Array.prototype[Symbol.iterator];
  34. }
  35.  
  36. // Options
  37. var opts = {
  38. 'useWSIFunc': useWSI
  39. };
  40. (function(){
  41. function optsCall(callback) {
  42. // Register event listener
  43. var key = "optsCallEvent_" + Math.random().toString(36).substr(2),
  44. cb = callback.func.bind(callback.name);
  45. window.addEventListener(key, cb, false);
  46. // Generate and dispatch synthetic event
  47. var ev = document.createEvent("HTMLEvents");
  48. ev.initEvent(key, true, false);
  49. window.dispatchEvent(ev);
  50. // Remove listener
  51. window.removeEventListener(key, cb, false);
  52. }
  53. function initOptsHandler() {
  54. /*jshint validthis:true */
  55. opts[this] = GM_getValue(this, true);
  56. if(opts[this]) {
  57. opts[this+'Func']();
  58. }
  59. }
  60. optsCall({
  61. func: initOptsHandler,
  62. name: 'useWSI'
  63. });
  64. // show options page
  65. function openOptions() {
  66. var ovl = document.createElement('div'),
  67. inner = document.createElement('div');
  68. ovl.style = (
  69. 'position: fixed;'+
  70. 'top:0; left:0;'+
  71. 'bottom: 0; right: 0;'+
  72. 'background: rgba(0,0,0,0.85);'+
  73. 'z-index: 2147483647;'+
  74. 'padding: 5em'
  75. );
  76. inner.style = (
  77. 'background: whitesmoke;'+
  78. 'font-size: 10pt;'+
  79. 'color: black;'+
  80. 'padding: 1em'
  81. );
  82. inner.textContent = 'JS Fixes Options: (reload page to apply)';
  83. inner.appendChild(document.createElement('br'));
  84. inner.appendChild(document.createElement('br'));
  85. ovl.addEventListener('click', function(e){
  86. if (e.target === ovl) {
  87. ovl.parentNode.removeChild(ovl);
  88. e.preventDefault();
  89. }
  90. e.stopPropagation();
  91. }, false);
  92. // append checkbox with label function
  93. function addCheckbox(optName, optLabel) {
  94. var c = document.createElement('input'),
  95. l = document.createElement('label');
  96. c.type = 'checkbox';
  97. c.id = optName;
  98. optsCall({
  99. func:function(){
  100. c.checked = GM_getValue(this);
  101. },
  102. name:optName
  103. });
  104. c.addEventListener('click', function(e) {
  105. optsCall({
  106. func:function(){
  107. GM_setValue(this, e.target.checked);
  108. opts[this] = e.target.checked;
  109. },
  110. name:optName
  111. });
  112. }, true);
  113. l.textContent = optLabel;
  114. l.setAttribute('for', optName);
  115. inner.appendChild(c);
  116. inner.appendChild(l);
  117. inner.appendChild(document.createElement('br'));
  118. }
  119. // append checkboxes
  120. addCheckbox('useWSI', 'Use WebSocket filter. Disable if experience problems with WebSocket connections.');
  121. document.body.appendChild(ovl);
  122. ovl.appendChild(inner);
  123. }
  124. // monitor keys pressed for Ctrl+Alt+Shift+J > s > f code
  125. var opPos = 0, opKey = 'Jsf', isNotKey;
  126. document.addEventListener('keydown', function(e) {
  127. isNotKey = (e.key.length > 1);
  128. if ((e.key === opKey[opPos] || isNotKey) &&
  129. (!!opPos || e.altKey && e.ctrlKey)) {
  130. opPos += (isNotKey ? 0 : 1);
  131. e.stopPropagation();
  132. e.preventDefault();
  133. } else {
  134. opPos = 0;
  135. }
  136. if (opPos === opKey.length) {
  137. opPos = 0;
  138. openOptions();
  139. }
  140. }, false);
  141. })();
  142.  
  143. // Special wrapper script to run scripts designed to override standard DOM functions
  144. // In Firefox appends supplied script to a page to make it run in page context and let
  145. // page content access overridden functions. In other browsers just run it as-is.
  146. function scriptLander(func, prepend) {
  147. if (!isFirefox) {
  148. func();
  149. return;
  150. }
  151. var s = document.createElement('script');
  152. s.textContent = '(function(){' + (
  153. prepend && prepend.join('') || ''
  154. ) + '!' + func + '();})();';
  155. _appendChild(s);
  156. _removeChild(s);
  157. }
  158.  
  159. // Creates and return protected style (unless protection is manually disabled).
  160. // Protected style will re-add itself on removal and remaind enabled on attempt to disable it.
  161. function createStyle(rules, props, skip_protect) {
  162. var prop = '',
  163. root = _de;
  164.  
  165. function _createGetterSetter(obj) {
  166. return {
  167. get: function() {return obj;}, //pretend to be empty
  168. set: function() {},
  169. enumerable: true
  170. };
  171. }
  172. function _protect(style) {
  173. Object.defineProperty(style, 'sheet', {
  174. value: style.sheet,
  175. enumerable: true
  176. });
  177. for (prop of ['rules', 'cssRules']) {
  178. Object.defineProperty(style.sheet, prop, _createGetterSetter([]));
  179. }
  180. Object.defineProperty(style, 'disabled', {
  181. get: function() {return true;}, //pretend to be disabled
  182. set: function() {},
  183. enumerable: true
  184. });
  185. var o = new MutationObserver(function() {
  186. root.removeChild(style);
  187. });
  188. o.observe(style, {childList: true});
  189. }
  190.  
  191. function _create() {
  192. var style = root.appendChild(document.createElement('style')),
  193. prop, rule;
  194. style.type = 'text/css';
  195. for (prop in props) {
  196. if (style[prop] !== undefined) {
  197. style[prop] = props[prop];
  198. }
  199. }
  200. function insertRule(rule) {
  201. try {
  202. style.sheet.insertRule(rule, 0);
  203. } catch (e) {
  204. console.error(e);
  205. }
  206. }
  207. if (typeof rules === 'string') {
  208. insertRule(rules);
  209. } else {
  210. rules.forEach(insertRule);
  211. }
  212. if (!skip_protect) {
  213. _protect(style);
  214. }
  215. return style;
  216. }
  217.  
  218. var style = _create();
  219. if (skip_protect) {
  220. return style;
  221. }
  222.  
  223. var o = new MutationObserver(function(ms){
  224. var m, node, rule;
  225. for (m of ms) {
  226. for (node of m.removedNodes) {
  227. if (node === style) {
  228. (new Promise(function(resolve){
  229. setTimeout(function(resolve){
  230. resolve(_create());
  231. }, 0, resolve);
  232. })).then(function(st){
  233. style = st;
  234. });
  235. }
  236. }
  237. }
  238. });
  239. o.observe(root, {childList:true});
  240.  
  241. return style;
  242. }
  243.  
  244. // https://gf.qytechs.cn/scripts/19144-websuckit/
  245. function useWSI() {
  246. // check does browser support Proxy and WebSocket
  247. if (typeof Proxy !== 'function' ||
  248. typeof WebSocket !== 'function') {
  249. return;
  250. }
  251.  
  252. function getWrappedCode(removeSelf) {
  253. var text = getWrappedCode.toString()+WSI.toString();
  254. text = (
  255. '(function(){"use strict";'+
  256. text.replace(/\/\/[^\r\n]*/g,'').replace(/[\s\r\n]+/g,' ')+
  257. '(new WSI(self||window)).init();'+
  258. '})();\n'+
  259. (removeSelf?'var s = document.currentScript; if (s) {s.parentNode.removeChild(s);}':'')
  260. );
  261. return text;
  262. }
  263.  
  264. function WSI(win, safeWin) {
  265. safeWin = safeWin || win;
  266. var masks = [], filter;
  267. for (filter of [// blacklist
  268. '||10root25.website^', '||24video.xxx^',
  269. '||adlabs.ru^', '||adspayformymortgage.win^', '||aviabay.ru^',
  270. '||bgrndi.com^', '||brokeloy.com^',
  271. '||cnamerutor.ru^',
  272. '||docfilms.info^', '||dreadfula.ru^',
  273. '||et-code.ru^',
  274. '||film-doma.ru^',
  275. '||free-torrent.org^', '||free-torrent.pw^',
  276. '||free-torrents.org^', '||free-torrents.pw^',
  277. '||game-torrent.info^', '||gocdn.ru^',
  278. '||hdkinoshka.com^', '||hghit.com^', '||hindcine.net^',
  279. '||kiev.ua^', '||kinotochka.net^',
  280. '||kinott.com^', '||kinott.ru^', '||kuveres.com^',
  281. '||lepubs.com^', '||luxadv.com^', '||luxup.ru^', '||luxupcdna.com^',
  282. '||mail.ru^', '||marketgid.com^', '||mixadvert.com^', '||mxtads.com^',
  283. '||nickhel.com^',
  284. '||oconner.biz^', '||oconner.link^',
  285. '||pkpojhc.com^',
  286. '||psma01.com^', '||psma02.com^', '||psma03.com^',
  287. '||recreativ.ru^', '||redtram.com^', '||regpole.com^', '||rootmedia.ws^', '||ruttwind.com^',
  288. '||skidl.ru^',
  289. '||torvind.com^', '||traffic-media.co^', '||trafmag.com^',
  290. '||webadvert-gid.ru^', '||webadvertgid.ru^',
  291. '||xxuhter.ru^',
  292. '||yuiout.online^',
  293. '||zoom-film.ru^'
  294. ]) {
  295. masks.push(new RegExp(
  296. filter.replace(/([\\\/\[\].*+?(){}$])/g, '\\$1')
  297. .replace(/\^(?!$)/g,'\\.?[^\\w%._-]')
  298. .replace(/\^$/,'\\.?([^\\w%._-]|$)')
  299. .replace(/^\|\|/,'^(ws|http)s?:\\/+([^\/.]+\\.)*'),
  300. 'i'));
  301. }
  302.  
  303. function isBlocked(url) {
  304. for (var mask of masks) {
  305. if (mask.test(url)) {
  306. return true;
  307. }
  308. }
  309. return false;
  310. }
  311.  
  312. var realWebSocket = win.WebSocket;
  313. function wsGetter (target, name) {
  314. try {
  315. if (typeof realWebSocket.prototype[name] === 'function') {
  316. if (name === 'close' || name === 'send') { // send also closes connection
  317. target.readyState = realWebSocket.CLOSED;
  318. }
  319. return (
  320. function fake() {
  321. console.log('[WSI] Invoked function "'+name+'"', '| Tracing', (new Error()));
  322. return;
  323. }
  324. );
  325. }
  326. if (typeof realWebSocket.prototype[name] === 'number') {
  327. return realWebSocket[name];
  328. }
  329. } catch(ignore) {}
  330. return target[name];
  331. }
  332.  
  333. function createWebSocketWrapper(target) {
  334. return new Proxy(realWebSocket, {
  335. construct: function (target, args) {
  336. var url = args[0];
  337. console.log('[WSI] Opening socket on ' + url + ' \u2026');
  338. if (isBlocked(url)) {
  339. console.log("[WSI] Blocked.");
  340. return new Proxy({
  341. url: url,
  342. readyState: realWebSocket.OPEN
  343. }, {
  344. get: wsGetter
  345. });
  346. }
  347. return new target(args[0], args[1]);
  348. }
  349. });
  350. }
  351.  
  352. function WorkerWrapper() {
  353. var realWorker = win.Worker;
  354. function wrappedWorker(resourceURI) {
  355. var isBlobURL = /^blob:/i,
  356. xhr = null,
  357. _callbacks = new WeakMap(),
  358. _worker = null,
  359. _terminate = false,
  360. _onerror = null,
  361. _onmessage = null,
  362. _messages = [],
  363. _events = [],
  364. /*jshint validthis:true */
  365. _self = this;
  366.  
  367. function callbackWrapper(func) {
  368. if (typeof func !== 'function') {
  369. return undefined;
  370. }
  371. return (
  372. function callback() {
  373. func.apply(_self, arguments);
  374. }
  375. );
  376. }
  377.  
  378. _self.terminate = function(){
  379. _terminate = true;
  380. if (_worker) {
  381. _worker.terminate();
  382. }
  383. };
  384. Object.defineProperty(_self, 'onmessage', {
  385. get: function() {
  386. return _onmessage;
  387. },
  388. set: function(val) {
  389. _onmessage = val;
  390. if (_worker) {
  391. _worker.onmessage = callbackWrapper(val);
  392. }
  393. }
  394. });
  395. Object.defineProperty(_self, 'onerror', {
  396. get: function() {
  397. return _onerror;
  398. },
  399. set: function(val) {
  400. _onerror = val;
  401. if (_worker) {
  402. _worker.onerror = callbackWrapper(val);
  403. }
  404. }
  405. });
  406. _self.postMessage = function(message){
  407. if (_worker) {
  408. _worker.postMessage(message);
  409. } else {
  410. _messages.push(message);
  411. }
  412. };
  413. _self.terminate = function() {
  414. _terminate = true;
  415. if (_worker) {
  416. _worker.terminate();
  417. }
  418. };
  419. _self.addEventListener = function(){
  420. if (typeof arguments[1] !== 'function') {
  421. return;
  422. }
  423. if (!_callbacks.has(arguments[1])) {
  424. _callbacks.set(arguments[1], callbackWrapper(arguments[1]));
  425. }
  426. arguments[1] = _callbacks.get(arguments[1]);
  427. if (_worker) {
  428. _worker.addEventListener.apply(_worker, arguments);
  429. } else {
  430. _events.push(['addEventListener', arguments]);
  431. }
  432. };
  433. _self.removeEventListener = function(){
  434. if (typeof arguments[1] !== 'function' || !_callbacks.has(arguments[1])) {
  435. return;
  436. }
  437. arguments[1] = _callbacks.get(arguments[1]);
  438. _callbacks.delete(arguments[1]);
  439. if (_worker) {
  440. _worker.removeEventListener.apply(_worker, arguments);
  441. } else {
  442. _events.push(['removeEventListener', arguments]);
  443. }
  444. };
  445.  
  446. if (!isBlobURL.test(resourceURI)) {
  447. _worker = new realWorker(resourceURI);
  448. return; // not a blob, no need to wrap
  449. }
  450.  
  451. xhr = new XMLHttpRequest();
  452. xhr.responseType = 'blob';
  453. try {
  454. xhr.open('GET', resourceURI, true);
  455. } catch(ignore) {
  456. _worker = new realWorker(resourceURI);
  457. return; // failed to open connection, unable to continue wrapping procedure
  458. }
  459. (new Promise(function(resolve, reject){
  460. if (xhr.readyState !== XMLHttpRequest.OPENED) {
  461. // connection wasn't opened, unable to continue wrapping procedure
  462. return reject();
  463. }
  464. xhr.onload = function(){
  465. if (this.status === 200) {
  466. var reader = new FileReader();
  467. reader.addEventListener("loadend", function() {
  468. resolve(new realWorker(URL.createObjectURL(
  469. new Blob([getWrappedCode(false)+this.result])
  470. )));
  471. });
  472. reader.readAsText(this.response);
  473. }
  474. };
  475. xhr.send();
  476. })).then(function(val) {
  477. _worker = val;
  478. _worker.onerror = callbackWrapper(_onerror);
  479. _worker.onmessage = callbackWrapper(_onmessage);
  480. var _e;
  481. while(_events.length) {
  482. _e = _events.shift();
  483. _worker[_e[0]].apply(_worker, _e[1]);
  484. }
  485. while(_messages.length) {
  486. _worker.postMessage(_messages.shift());
  487. }
  488. if (_terminate) {
  489. _worker.terminate();
  490. }
  491. }).catch(function(){});
  492.  
  493. }
  494. win.Worker = wrappedWorker.bind(safeWin);
  495. }
  496.  
  497. function CreateElementWrapper() {
  498. var realCreateElement = Document.prototype.createElement,
  499. _addEventListener = Element.prototype.addEventListener,
  500. code = encodeURIComponent('<scr'+'ipt>'+getWrappedCode(true)+'</scr'+'ipt>\n'),
  501. isDataURL = /^data:/i,
  502. isBlobURL = /^blob:/i;
  503.  
  504. function frameRewrite(e) {
  505. var f = e.target,
  506. w = f.contentWindow;
  507. if (!f.src || (w && isBlobURL.test(f.src))) {
  508. w.WebSocket = createWebSocketWrapper();
  509. }
  510. if (isDataURL.test(f.src) && f.src.indexOf(code) < 0) {
  511. f.src = f.src.replace(',',',' + code);
  512. }
  513. }
  514.  
  515. var scriptMap = new WeakMap();
  516. scriptMap.isBlocked = isBlocked;
  517. var onErrorWrapper = {
  518. set: function(val) {
  519. if (scriptMap.has(this)) {
  520. this.removeEventListener('error', scriptMap.get(this).wrp, false);
  521. scriptMap.delete(this);
  522. }
  523. if (!val || typeof val !== 'function') {
  524. return val;
  525. }
  526. scriptMap.set(this, {
  527. org: val,
  528. wrp: function() {
  529. if (scriptMap.isBlocked(this.src)) {
  530. console.log('[WSI] Blocked "onerror" callback from', this);
  531. return;
  532. }
  533. scriptMap.get(this).org.apply(this, arguments);
  534. }
  535. });
  536. this.addEventListener('error', scriptMap.get(this).wrp, false);
  537. return val;
  538. },
  539. get: function() {
  540. return scriptMap.has(this) ? scriptMap.get(this).org : null;
  541. },
  542. enumerable: true
  543. };
  544. function wrappedCreateElement(name) {
  545. /*jshint validthis:true */
  546. var el = realCreateElement.apply(this, arguments);
  547. if (el.tagName === 'IFRAME') {
  548. _addEventListener.call(el, 'load', frameRewrite, false);
  549. }
  550. if (el.tagName === 'SCRIPT') {
  551. Object.defineProperty(el, 'onerror', onErrorWrapper);
  552. }
  553. return el;
  554. }
  555. Document.prototype.createElement = wrappedCreateElement;
  556.  
  557. document.addEventListener('DOMContentLoaded', function(){
  558. for (var ifr of document.querySelectorAll('IFRAME')) {
  559. _addEventListener.call(ifr, 'load', frameRewrite, false);
  560. }
  561. }, false);
  562. }
  563.  
  564. this.init = function() {
  565. win.WebSocket = createWebSocketWrapper();
  566. if (!(/firefox/i.test(navigator.userAgent))) {
  567. WorkerWrapper(); // skip WorkerWrapper in Firefox
  568. }
  569. if (typeof document !== 'undefined') {
  570. CreateElementWrapper();
  571. }
  572. };
  573. }
  574.  
  575. if (isFirefox) {
  576. var script = document.createElement('script');
  577. script.appendChild(document.createTextNode(getWrappedCode(true)));
  578. document.head.insertBefore(script, document.head.firstChild);
  579. return; //we don't want to call functions on page from here in Fx, so exit
  580. }
  581.  
  582. (new WSI((unsafeWindow||self||window),(self||window))).init();
  583. }
  584.  
  585. if (!isFirefox) { // scripts for non-Firefox browsers
  586.  
  587. // https://gf.qytechs.cn/scripts/14720-it-s-not-important
  588. (function(){
  589. var imptt = /((display|(margin|padding)(-top|-bottom)?)\s*:[^;!]*)!\s*important/ig;
  590.  
  591. function unimportanter(el, si) {
  592. if (!imptt.test(si) || el.style.display === 'none') {
  593. return 0; // get out if we have nothing to do here
  594. }
  595. if (el.nodeName === 'IFRAME' && el.src &&
  596. el.src.slice(0,17) === 'chrome-extension:') {
  597. return 0; // Web of Trust uses this method to add their frame
  598. }
  599. var so = si.replace(imptt, function(){return arguments[1];}), ret = 0;
  600. if (si !== so) {
  601. ret = 1;
  602. _setAttribute.call(el, 'style', so);
  603. }
  604. return ret;
  605. }
  606.  
  607. function logger(c) {
  608. if (c) {
  609. console.log('Some page elements became a bit less important.');
  610. }
  611. }
  612.  
  613. function checkTarget(node, cnt) {
  614. if (!(node && node.getAttribute)) {
  615. return 0;
  616. }
  617. var si = _getAttribute.call(node, 'style');
  618. if (si && si.indexOf('!') > -1) {
  619. cnt += unimportanter(node, si);
  620. }
  621. return cnt;
  622. }
  623.  
  624. var observer = new MutationObserver(function(mutations) {
  625. setTimeout(function(ms) {
  626. var cnt = 0, m, node;
  627. for (m of ms) {
  628. cnt = checkTarget(m.target, cnt);
  629. for (node of m.addedNodes) {
  630. cnt += checkTarget(node, cnt);
  631. }
  632. }
  633. logger(cnt);
  634. }, 0, mutations);
  635. });
  636.  
  637. observer.observe(document, { childList : true, attributes : true, attributeFilter : ['style'], subtree : true });
  638.  
  639. win.addEventListener ("load", function(){
  640. var c = 0, imp;
  641. for (imp of document.querySelectorAll('[style*="!"]')) {
  642. c+= checkTarget(imp, c);
  643. }
  644. logger(c);
  645. }, false);
  646. })();
  647.  
  648. }
  649.  
  650. if (/^https?:\/\/(mail\.yandex\.|music\.yandex\.|news\.yandex\.|(www\.)?yandex\.[^\/]+\/(yand)?search[\/?])/i.test(win.location.href)) {
  651. // https://gf.qytechs.cn/en/scripts/809-no-yandex-ads
  652. (function(){
  653. var adWords = ['Яндекс.Директ','Реклама','Ad'];
  654. function remove(node) {
  655. node.parentNode.removeChild(node);
  656. }
  657. // Generic ads removal and fixes
  658. function removeGenericAds() {
  659. var s, i;
  660. s = document.querySelector('.serp-header');
  661. if (s) {
  662. s.style.marginTop='0';
  663. }
  664. for (s of document.querySelectorAll('.serp-adv__head + .serp-item, #adbanner, .serp-adv, .b-spec-adv, div[class*="serp-adv__"]:not(.serp-adv__found):not(.serp-adv__displayed)')) {
  665. remove(s);
  666. }
  667. }
  668. // Search ads
  669. function removeSearchAds() {
  670. var s, item, l;
  671. for (s of document.querySelectorAll('.t-construct-adapter__legacy')) {
  672. item = s.querySelector('.organic__subtitle');
  673. l = window.getComputedStyle(item, ':after').content;
  674. if (item && adWords.indexOf(l.replace(/"/g,'')) > -1) {
  675. remove(s);
  676. console.log('Ads removed.');
  677. }
  678. }
  679. }
  680. // News ads
  681. function removeNewsAds() {
  682. for (var s of document.querySelectorAll(
  683. '.page-content__left > *,'+
  684. '.page-content__right > *:not(.page-content__col),'+
  685. '.page-content__right > .page-content__col > *'
  686. )) {
  687. if (s.textContent.indexOf(adWords[0]) > -1 ||
  688. (s.clientHeight < 15 && s.classList.contains('rubric'))) {
  689. remove(s);
  690. console.log('Ads removed.');
  691. }
  692. }
  693. }
  694. // Music ads
  695. function removeMusicAds() {
  696. for (var s of document.querySelectorAll('.ads-block')) {
  697. remove(s);
  698. }
  699. }
  700. // Mail ads
  701. function removeMailAds() {
  702. var slice = Array.prototype.slice,
  703. nodes = slice.call(document.querySelectorAll('.ns-view-folders')),
  704. node, len, classes, cls;
  705. for (node of nodes) {
  706. if (!len || len > node.classList.length) {
  707. len = node.classList.length;
  708. }
  709. }
  710. node = nodes.pop();
  711. while (node) {
  712. if (node.classList.length > len) {
  713. for (cls of slice.call(node.classList)) {
  714. if (cls.indexOf('-') === -1) {
  715. remove(node);
  716. break;
  717. }
  718. }
  719. }
  720. node = nodes.pop();
  721. }
  722. }
  723. // News fixes
  724. function removePageAdsClass() {
  725. if (document.body.classList.contains("b-page_ads_yes")){
  726. document.body.classList.remove("b-page_ads_yes");
  727. console.log('Page ads class removed.');
  728. }
  729. }
  730. // Function to attach an observer to monitor dynamic changes on the page
  731. function pageUpdateObserver(func, obj, params) {
  732. if (obj) {
  733. var o = new MutationObserver(func);
  734. o.observe(obj,(params || {childList:true, subtree:true}));
  735. }
  736. }
  737. // Cleaner
  738. document.addEventListener ('DOMContentLoaded', function() {
  739. removeGenericAds();
  740. if (win.location.hostname.search(/^mail\./i) === 0) {
  741. pageUpdateObserver(function(ms, o){
  742. var aside = document.querySelector('.mail-Layout-Aside');
  743. if (aside) {
  744. o.disconnect();
  745. pageUpdateObserver(removeMailAds, aside);
  746. }
  747. }, document.querySelector('BODY'));
  748. removeMailAds();
  749. } else if (win.location.hostname.search(/^music\./i) === 0) {
  750. pageUpdateObserver(removeMusicAds, document.querySelector('.sidebar'));
  751. removeMusicAds();
  752. } else if (win.location.hostname.search(/^news\./i) === 0) {
  753. pageUpdateObserver(removeNewsAds, document.querySelector('BODY'));
  754. pageUpdateObserver(removePageAdsClass, document.body, {attributes:true, attributesFilter:['class']});
  755. removeNewsAds();
  756. removePageAdsClass();
  757. } else {
  758. pageUpdateObserver(removeSearchAds, document.querySelector('.main__content'));
  759. removeSearchAds();
  760. }
  761. });
  762. })();
  763. }
  764. // Yandex Link Tracking
  765. if (/^https?:\/\/([^.]+\.)*yandex\.[^\/]+/i.test(win.location.href)) {
  766. // Partially based on https://gf.qytechs.cn/en/scripts/22737-remove-yandex-redirect
  767. (function(){
  768. var link;
  769. function removeTracking(scope) {
  770. for (link of scope.querySelectorAll('A')) {
  771. if (link.hasAttribute('onmousedown') &&
  772. /\/jsredir/i.test(link.getAttribute('onmousedown'))) {
  773. link.removeAttribute('onmousedown');
  774. }
  775. if (link.hasAttribute('data-vdir-href')) {
  776. link.removeAttribute('data-vdir-href');
  777. link.removeAttribute('data-orig-href');
  778. }
  779. if (link.hasAttribute('data-counter')) {
  780. link.removeAttribute('data-counter');
  781. link.removeAttribute('data-bem');
  782. }
  783. }
  784. }
  785. removeTracking(_de);
  786. var o = new MutationObserver(function(ms) {
  787. var m, node;
  788. for (m of ms) {
  789. for (node of m.addedNodes) {
  790. if (node.nodeType === Node.ELEMENT_NODE) {
  791. removeTracking(node);
  792. }
  793. }
  794. }
  795. });
  796. o.observe(_de, {childList: true, subtree: true});
  797. })();
  798. return; //skip fixes for other sites
  799. }
  800.  
  801. // https://gf.qytechs.cn/en/scripts/21937-moonwalk-hdgo-kodik-fix v0.8 (adapted)
  802. document.addEventListener ('DOMContentLoaded', function() {
  803. var tmp;
  804. function log (e) {
  805. console.log('Moonwalk&HDGo&Kodik FIX: ' + e + ' player in ' + win.location.href);
  806. }
  807. if (win.adv_enabled !== undefined && win.condition_detected !== undefined) { // moonwalk
  808. log('Moonwalk');
  809. if (win.adv_enabled) {
  810. win.adv_enabled = false;
  811. }
  812. win.condition_detected = false;
  813. if (win.MXoverrollCallback) {
  814. document.addEventListener('click', function catcher(e){
  815. e.stopPropagation();
  816. win.MXoverrollCallback.call(window);
  817. document.removeEventListener('click', catcher, true);
  818. }, true);
  819. }
  820. } else if (win.stat_url !== undefined && win.is_html5 !== undefined && win.is_wp8 !== undefined) { // hdgo
  821. log('HDGo');
  822. document.body.onclick = null;
  823. tmp = document.querySelector('#swtf');
  824. if (tmp) {
  825. tmp.style.display = 'none';
  826. }
  827. if (win.banner_second !== undefined) {
  828. win.banner_second = 0;
  829. }
  830. if (win.$banner_ads !== undefined) {
  831. win.$banner_ads = false;
  832. }
  833. if (win.$new_ads !== undefined) {
  834. win.$new_ads = false;
  835. }
  836. if (win.createCookie !== undefined) {
  837. win.createCookie('popup','true','999');
  838. }
  839. if (win.canRunAds !== undefined && win.canRunAds !== true) {
  840. win.canRunAds = true;
  841. }
  842. } else if (win.MXoverrollCallback && win.iframeSearch !== undefined) { // kodik
  843. log('Kodik');
  844. tmp = document.querySelector('.play_button');
  845. if (tmp) {
  846. tmp.onclick = win.MXoverrollCallback.bind(window);
  847. }
  848. win.IsAdBlock = false;
  849. }
  850. }, false);
  851.  
  852. // Automated protection against specific circumvention method based on unwrapping various functions,
  853. // hiding ads in the Shadow DOM and injecting iFrames with ads. Previously this code were known as
  854. // apiBreaker since it were breaking Shadow DOM and onerror/onload API on specific domains. This
  855. // version should be safe enough to run on majority of sites without actually breaking them.
  856. scriptLander(function() {
  857. var blacklist = new WeakMap(),
  858. replacer, func;
  859. /* Wrap functions used to attach shadow root to a node */
  860. replacer = function (func) {
  861. return function() {
  862. blacklist.set(this, true);
  863. return func.apply(this, arguments);
  864. };
  865. };
  866. for (func of ['createShadowRoot', 'attachShadow']) {
  867. if (func in Element.prototype) {
  868. Element.prototype[func] = replacer(Element.prototype[func]);
  869. }
  870. }
  871. /* Wrap functions used to insert/append elements to check for IFRAME objects */
  872. replacer = function (func) {
  873. return function(el, par) {
  874. if (el.tagName === 'IFRAME' &&
  875. ((typeof par === 'object' && blacklist.get(par))/* ||
  876. el.style.display === 'none'*/)) {
  877. console.log('Blocked suspicious', func.name, arguments);
  878. return null;
  879. }
  880. return func.apply(this, arguments);
  881. };
  882. };
  883. for (func of [/*'appendChild', */'insertBefore']) {
  884. Object.defineProperty(Element.prototype, func, {
  885. value: replacer(Element.prototype[func]), enumerable: true
  886. });
  887. }
  888. });
  889.  
  890. // === Helper functions ===
  891.  
  892. // function to search and remove nodes by content
  893. // selector - standard CSS selector to define set of nodes to check
  894. // words - regular expression to check content of the suspicious nodes
  895. // params - object with multiple extra parameters:
  896. // .hide - set display to none instead of removing from the page
  897. // .parent - parent node to remove if content is found in the child node
  898. // .siblings - number of simling nodes to remove (excluding text nodes)
  899. function scRemove(e) {e.parentNode.removeChild(e);}
  900. function scHide(e) {
  901. var s = _getAttribute.call(e, 'style') || '',
  902. h = ';display:none!important;';
  903. if (s.indexOf(h) < 0) {
  904. _setAttribute.call(e, 'style', s+h);
  905. }
  906. }
  907. function scissors (selector, words, scope, params) {
  908. var remFunc = (params.hide ? scHide : scRemove),
  909. iterFunc = (params.siblings > 0 ?
  910. 'nextSibling' :
  911. 'previousSibling'),
  912. toRemove = [],
  913. siblings,
  914. node;
  915. for (node of scope.querySelectorAll(selector)) {
  916. if (params.parent) {
  917. while(node !== scope && !(node.matches(params.parent))) {
  918. node = node.parentNode;
  919. }
  920. }
  921. if (words.test(node.innerHTML) || !node.childNodes.length) {
  922. // drill up to the specified parent node if required
  923. if (node === scope) {
  924. break;
  925. }
  926. toRemove.push(node);
  927. // add multiple nodes if defined more than one sibling
  928. siblings = Math.abs(params.siblings) || 0;
  929. while (siblings) {
  930. node = node[iterFunc];
  931. toRemove.push(node);
  932. if (node.nodeType === Node.ELEMENT_NODE) {
  933. siblings -= 1; //count only element nodes
  934. }
  935. }
  936. }
  937. }
  938. for (node of toRemove) {
  939. remFunc(node);
  940. }
  941. return toRemove.length;
  942. }
  943.  
  944. // function to perform multiple checks if ads inserted with a delay
  945. // by default does 30 checks withing a 3 seconds unless nonstop mode specified
  946. // also does 1 extra check when a page completely loads
  947. // selector and words - passed dow to scissors
  948. // params - object with multiple extra parameters:
  949. // .root - selector to narrow down scope to scan;
  950. // .observe - if true then check will be performed continuously;
  951. // Other parameters passed down to scissors.
  952. function gardener(selector, words, params) {
  953. params = params || {};
  954. var scope = document,
  955. nonstop = false;
  956. // narrow down scope to a specific element
  957. if (params.root) {
  958. scope = scope.querySelector(params.root);
  959. if (!scope) {// exit if the root element is not present on the page
  960. return 0;
  961. }
  962. }
  963. // add observe mode if required
  964. if (params.observe) {
  965. if (typeof MutationObserver === 'function') {
  966. var o = new MutationObserver(function(ms){
  967. for (var m of ms) {
  968. if (m.addedNodes.length) {
  969. scissors(selector, words, scope, params);
  970. }
  971. }
  972. });
  973. o.observe(scope, {childList:true, subtree: true});
  974. } else {
  975. nonstop = true;
  976. }
  977. }
  978. // wait for a full page load to do one extra cut
  979. win.addEventListener('load',function(){
  980. scissors(selector, words, scope, params);
  981. });
  982. // do multiple cuts until ads removed
  983. function cut(sci, s, w, sc, p, i) {
  984. if (i > 0) {
  985. i -= 1;
  986. }
  987. if (i && !sci(s, w, sc, p)) {
  988. setTimeout(cut, 100, sci, s, w, sc, p, i);
  989. }
  990. }
  991. cut(scissors, selector, words, scope, params, (nonstop ? -1 : 30));
  992. }
  993.  
  994. // Helper function to close background tab if site opens itself in a new tab and then
  995. // loads a 3rd-party page in the background one (thus performing background redirect).
  996. function preventBackgroundRedirect() {
  997. // create "cose_me" event to call high-level window.close()
  998. var key = Math.random().toString(36).substr(2);
  999. window.addEventListener('close_me_'+key, function(e) {
  1000. window.close();
  1001. });
  1002.  
  1003. // window.open wrapper
  1004. function pbrLander() {
  1005. var orgOpen = window.open.bind(window),
  1006. idx = String.prototype.indexOf,
  1007. event = new CustomEvent("close_me_%key%", {});
  1008. function closeWindow(){
  1009. // site went to a new tab and attempts to unload
  1010. // call for high-level close through event
  1011. window.dispatchEvent(event);
  1012. }
  1013. // window.open wrapper
  1014. function open(){
  1015. console.log(arguments, window.location.host);
  1016. if (arguments[0] &&
  1017. (idx.call(arguments[0], window.location.host) > -1 ||
  1018. idx.call(arguments[0], '://') === -1)) {
  1019. window.addEventListener('unload', closeWindow, true);
  1020. }
  1021. orgOpen.apply(window, arguments);
  1022. }
  1023. window.open = open.bind(window);
  1024. // Node.createElement wrapper to prevent click-dispatch in Google Chrome and similar browsers
  1025. var realCreateElement = Document.prototype.createElement;
  1026. function wrappedCreateElement(name) {
  1027. /*jshint validthis:true */
  1028. var el = realCreateElement.apply(this, arguments);
  1029. if (el.tagName === 'A') {
  1030. el.addEventListener('click', function(e){
  1031. if (!e.target.parentNode || !e.isTrusted) {
  1032. window.addEventListener('unload', closeWindow, true);
  1033. }
  1034. }, false);
  1035. }
  1036. return el;
  1037. }
  1038. Document.prototype.createElement = wrappedCreateElement;
  1039. }
  1040.  
  1041. // land wrapper on the page
  1042. var script = document.createElement('script');
  1043. script.appendChild(document.createTextNode('('+pbrLander.toString().replace(/%key%/g,key)+')();'));
  1044. document.head.insertBefore(script, document.head.firstChild);
  1045. script.parentNode.removeChild(script);
  1046. console.log("Background redirect prevention enabled.");
  1047. }
  1048.  
  1049. // Function to catch and block various methods to open a new window with 3rd-party content.
  1050. // Some advertisement networks went way past simple window.open call to circumvent default popup protection.
  1051. // This funciton blocks window.open, ability to restore original window.open from an IFRAME object,
  1052. // ability to perform an untrusted (not initiated by user) click on a link, click on a link without a parent
  1053. // node or simply a link with piece of javascript code in the HREF attribute.
  1054. function preventPopups() {
  1055. function open(){
  1056. console.log('Site attempted to open a new window', arguments);
  1057. function nil(){}
  1058. return {
  1059. document: {
  1060. write: nil,
  1061. writeln: nil
  1062. }
  1063. };
  1064. }
  1065. win.open = exportFunction(open, win);
  1066.  
  1067. function wrapFunctions() {
  1068. var realCreateElement = Document.prototype.createElement,
  1069. realAppendChild = Element.prototype.appendChild;
  1070. Document.prototype.createElement = function createElement(name) {
  1071. /*jshint validthis:true */
  1072. var el = realCreateElement.apply(this, arguments);
  1073. if (el.tagName === 'A') {
  1074. el.addEventListener('click', function(e) {
  1075. if (!e.target.parentNode || !e.isTrusted ||
  1076. (e.target.href && e.target.href.toLowerCase().indexOf('javascript') > -1)) {
  1077. e.preventDefault();
  1078. console.log('Blocked suspicious click event', e, 'on', e.target);
  1079. }
  1080. }, false);
  1081. }
  1082. if (el.tagName === 'IFRAME') {
  1083. el.addEventListener('load', function(){
  1084. try {
  1085. this.contentWindow.open = open;
  1086. } catch(ignore) {}
  1087. }, false);
  1088. }
  1089. return el;
  1090. };
  1091. Element.prototype.appendChild = function appendChild() {
  1092. var child = realAppendChild.apply(this, arguments);
  1093. if (child && child.nodeType === Node.ELEMENT_NODE && child.tagName === 'IFRAME') {
  1094. try {
  1095. child.contentWindow.open = open;
  1096. } catch(ignore) {}
  1097. }
  1098. return child;
  1099. };
  1100. }
  1101.  
  1102. scriptLander(wrapFunctions, [open]);
  1103. }
  1104.  
  1105. // Currently unused piece of code developed to prevent site from registering serviceWorker
  1106. // and uninstall any existing instances of serivceWorker in case there is one already.
  1107. /* Commented out since not used
  1108. function forbidServiceWorker() {
  1109. if (!("serviceWorker" in navigator)) {
  1110. return;
  1111. }
  1112. var svr = navigator.serviceWorker.ready;
  1113. Object.defineProperty(navigator, 'serviceWorker', {
  1114. value: {
  1115. register: function(){
  1116. console.log('Registration of serviceWorker ' + arguments[0] + ' blocked.');
  1117. return new Promise(function(){});
  1118. },
  1119. ready: new Promise(function(){}),
  1120. addEventListener:function(){}
  1121. }
  1122. });
  1123. document.addEventListener('DOMContentLoaded', function() {
  1124. if (!svr) {
  1125. return;
  1126. }
  1127. svr.then(function(sw) {
  1128. console.log('Found existing serviceWorker:', sw);
  1129. console.log('Attempting to unregister...');
  1130. sw.unregister().then(function() {
  1131. console.log('Unregistered! :)');
  1132. }).catch(function(err) {
  1133. console.log('Unregistration failed. :(', err);
  1134. console.log('Try to remove it manually:');
  1135. console.log(' 1. Open: chrome://serviceworker-internals/ (Google Chrome and alike) or about:serviceworkers (Mozilla Firefox) in a new tab.');
  1136. console.log(' 2. Search there for one with "'+document.domain+'" in the name.');
  1137. console.log(' 3. Use buttons in the same block with service you found to stop it and uninstall/unregister.');
  1138. });
  1139. }).catch(function(err) {
  1140. console.log("Lol, it failed on it's own. -_-", err);
  1141. });
  1142. }, false);
  1143. }
  1144. /**/
  1145.  
  1146. // Currently obsolete code developed to prevent error and load calls on objects supposed to load resources
  1147. // from the internet like IMG or IFRAME, but missing SRC/HREF attribute. Usually tricks like this are used
  1148. // to unwrap wrapped functions to be able to load ads.
  1149. /* Commented out since not used
  1150. function errorAndLoadEventsFilter() {
  1151. var toString = Function.prototype.toString,
  1152. addEventListener = Element.prototype.addEventListener,
  1153. removeEventListener = Element.prototype.removeEventListener,
  1154. hasAttribute = Element.prototype.hasAttribute,
  1155. evtMap = new WeakMap();
  1156. Element.prototype.addEventListener = function(evt, func, capt) {
  1157. if (evt === 'error' || evt === 'load') {
  1158. if (!evtMap.get(func)) {
  1159. evtMap.set(func, function() {
  1160. if (hasAttribute.call(this, 'src') ||
  1161. hasAttribute.call(this, 'href')) {
  1162. func.apply(this, arguments);
  1163. } else {
  1164. console.log('Blocked', evt, 'handler', toString.call(func), 'on', this);
  1165. }
  1166. });
  1167. }
  1168. }
  1169. addEventListener.call(this, evt, (evtMap.get(func) || func), capt);
  1170. };
  1171. Element.prototype.removeEventListener = function(evt, func, capt) {
  1172. removeEventListener.call(this, evt, (evtMap.get(func) || func), capt);
  1173. };
  1174. Object.defineProperty(HTMLElement.prototype, 'onload', {
  1175. set: function(func) {
  1176. if(evtMap.has(this)) {
  1177. if (evtMap.get(this).onload) {
  1178. Element.prototype.removeEventListener.call(this, 'load', evtMap.get(this).onload, false);
  1179. }
  1180. evtMap.get(this).onload = func;
  1181. } else {
  1182. evtMap.set(this, { onload: func });
  1183. }
  1184. if (func) {
  1185. Element.prototype.addEventListener.call(this, 'load', func, false);
  1186. }
  1187. return func;
  1188. },
  1189. get: function() {
  1190. return evtMap.has(this) ? evtMap.get(this).onload : null;
  1191. }
  1192. });
  1193. Object.defineProperty(HTMLElement.prototype, 'onerror', {
  1194. set: function(func) {
  1195. if (evtMap.has(this)) {
  1196. evtMap.get(this).onerror = func;
  1197. } else {
  1198. evtMap.set(this, { onerror: func });
  1199. }
  1200. if (func) {
  1201. console.log('Blocked error handler', toString.call(func), 'on', this);
  1202. }
  1203. return func;
  1204. },
  1205. get: function() {
  1206. return evtMap.has(this) ? evtMap.get(this).onerror : null;
  1207. }
  1208. });
  1209. }
  1210. /**/
  1211.  
  1212. // === Scripts for specific domains ===
  1213.  
  1214. var scripts = {};
  1215. // prevent popups and redirects block
  1216. var preventPopupsNow = { 'now': preventPopups },
  1217. preventBackgroundRedirectNow = { 'now': preventBackgroundRedirect };
  1218. // Popups
  1219. scripts['biqle.ru'] = preventPopupsNow;
  1220. scripts['chaturbate.com'] = preventPopupsNow;
  1221. scripts['dfiles.ru'] = preventPopupsNow;
  1222. scripts['hentaiz.org'] = preventPopupsNow;
  1223. scripts['mirrorcreator.com'] = preventPopupsNow;
  1224. scripts['online-multy.ru'] = preventPopupsNow;
  1225. scripts['openload.co'] = preventPopupsNow;
  1226. scripts['radikal.ru'] = preventPopupsNow;
  1227. scripts['seedoff.cc'] = preventPopupsNow;
  1228. scripts['tapochek.net'] = preventPopupsNow;
  1229. scripts['thepiratebay.org'] = preventPopupsNow;
  1230. scripts['torseed.net'] = preventPopupsNow;
  1231. scripts['zippyshare.com'] = preventPopupsNow;
  1232. // Background redirects
  1233. scripts['mediafire.com'] = preventBackgroundRedirectNow;
  1234. scripts['megapeer.org'] = preventBackgroundRedirectNow;
  1235. scripts['megapeer.ru'] = preventBackgroundRedirectNow;
  1236. scripts['perfectgirls.net'] = preventBackgroundRedirectNow;
  1237. scripts['turbobit.net'] = preventBackgroundRedirectNow;
  1238.  
  1239. // other
  1240. scripts['4pda.ru'] = {
  1241. 'now': function() {
  1242. // https://gf.qytechs.cn/en/scripts/14470-4pda-unbrender
  1243. var isForum = document.location.href.search('/forum/') !== -1,
  1244. hStyle;
  1245.  
  1246. function remove(n) {
  1247. if (n) {
  1248. n.parentNode.removeChild(n);
  1249. }
  1250. }
  1251.  
  1252. function afterClean() {
  1253. hStyle.disabled = true;
  1254. remove(hStyle);
  1255. }
  1256.  
  1257. function beforeClean() {
  1258. // attach styles before document displayed
  1259. hStyle = createStyle([
  1260. 'html { overflow-y: scroll }',
  1261. 'section[id] {'+(
  1262. 'position: absolute;'+
  1263. 'width: 100%'
  1264. )+'}',
  1265. 'article + aside * { display: none !important }',
  1266. '#header + div:after {'+(
  1267. 'content: "";'+
  1268. 'position: fixed;'+
  1269. 'top: 0;'+
  1270. 'left: 0;'+
  1271. 'width: 100%;'+
  1272. 'height: 100%;'+
  1273. 'background-color: #E6E7E9'
  1274. )+'}',
  1275. // http://codepen.io/Beaugust/pen/DByiE
  1276. '@keyframes spin { 100% { transform: rotate(360deg) } }',
  1277. 'article + aside:after {'+(
  1278. 'content: "";'+
  1279. 'position: absolute;'+
  1280. 'width: 150px;'+
  1281. 'height: 150px;'+
  1282. 'top: 150px;'+
  1283. 'left: 50%;'+
  1284. 'margin-top: -75px;'+
  1285. 'margin-left: -75px;'+
  1286. 'box-sizing: border-box;'+
  1287. 'border-radius: 100%;'+
  1288. 'border: 10px solid rgba(0, 0, 0, 0.2);'+
  1289. 'border-top-color: rgba(0, 0, 0, 0.6);'+
  1290. 'animation: spin 2s infinite linear'
  1291. )+'}'
  1292. ], {id:'ubrHider'}, true);
  1293.  
  1294. // display content of a page if time to load a page is more than 2 seconds to avoid
  1295. // blocking access to a page if it is loading for too long or stuck in a loading state
  1296. setTimeout(2000, afterClean);
  1297. }
  1298.  
  1299. createStyle([
  1300. '#nav .use-ad { display: block !important }',
  1301. 'article:not(.post) + article:not(#id), a[target="_blank"] img[height="90"] { display: none !important }'
  1302. ]);
  1303.  
  1304. if (!isForum) {
  1305. beforeClean();
  1306. }
  1307.  
  1308. // save links to non-overridden functions to use later
  1309. var protectedElems;
  1310. // protect/hide changed attributes in case site attempt to restore them
  1311. function styleProtector(eventMode) {
  1312. var oRAN = Element.prototype.removeAttributeNode,
  1313. isStyleText = function(t){ return t === 'style'; },
  1314. isStyleAttr = function(a){ return a instanceof Attr && a.nodeName === 'style'; },
  1315. returnUndefined = function(){},
  1316. protectedElems = new WeakMap();
  1317. function protoOverride(element, functionName, isStyleCheck, returnIfProtected) {
  1318. var oF = element.prototype[functionName], r;
  1319. element.prototype[functionName] = function() {
  1320. if (protectedElems.has(this) && isStyleCheck(arguments[0])) {
  1321. return returnIfProtected(this, arguments);
  1322. }
  1323. r = oF.apply(this, arguments);
  1324. return r;
  1325. };
  1326. }
  1327. protoOverride(Element, 'removeAttribute', isStyleText, returnUndefined);
  1328. protoOverride(Element, 'hasAttribute', isStyleText, function(_this) {
  1329. return protectedElems.get(_this) !== null;
  1330. });
  1331. protoOverride(Element, 'setAttribute', isStyleText, function(_this, args) {
  1332. protectedElems.set(_this, args[1]);
  1333. });
  1334. protoOverride(Element, 'getAttribute', isStyleText, function(_this) {
  1335. return protectedElems.get(_this);
  1336. });
  1337. if (eventMode) {
  1338. var e = document.createEvent('Event');
  1339. e.initEvent('protoOverride', false, false);
  1340. window.protectedElems = protectedElems;
  1341. window.dispatchEvent(e);
  1342. } else {
  1343. return protectedElems;
  1344. }
  1345. }
  1346. if (isFirefox) {
  1347. var s = document.createElement('script');
  1348. s.textContent = '(' + styleProtector.toString() + ')(true);';
  1349. window.addEventListener('protoOverride', function protoOverrideCallback(e){
  1350. if (win.protectedElems) {
  1351. protectedElems = win.protectedElems;
  1352. delete win.protectedElems;
  1353. }
  1354. document.removeEventListener('protoOverride', protoOverrideCallback, true);
  1355. }, true);
  1356. _appendChild(s);
  1357. _removeChild(s);
  1358. } else {
  1359. protectedElems = styleProtector(false);
  1360. }
  1361.  
  1362. // clean a page
  1363. window.addEventListener('DOMContentLoaded', function(){
  1364. var rem, si, itm;
  1365. function width(){ return window.innerWidth||_de.clientWidth||document.body.clientWidth||0; }
  1366. function height(){ return window.innerHeight||_de.clientHeight||document.body.clientHeight||0; }
  1367.  
  1368.  
  1369. if (isForum) {
  1370. si = document.querySelector('#logostrip');
  1371. if (si) {
  1372. remove(si.parentNode.nextSibling);
  1373. }
  1374. }
  1375.  
  1376. if (document.location.href.search('/forum/dl/') !== -1) {
  1377. document.body.setAttribute('style', (document.body.getAttribute('style')||'')+
  1378. ';background-color:black!important');
  1379. for (itm of document.querySelectorAll('body>div')) {
  1380. if (!itm.querySelector('.dw-fdwlink')) {
  1381. remove(itm);
  1382. }
  1383. }
  1384. }
  1385.  
  1386. if (isForum) { // Do not continue if it's a forum
  1387. return;
  1388. }
  1389.  
  1390. si = document.querySelector('#header');
  1391. if (si) {
  1392. rem = si.previousSibling;
  1393. while (rem) {
  1394. si = rem.previousSibling;
  1395. remove(rem);
  1396. rem = si;
  1397. }
  1398. }
  1399.  
  1400. for (itm of document.querySelectorAll('#nav li[class]')) {
  1401. if (itm && itm.querySelector('a[href^="/tag/"]')) {
  1402. remove(itm);
  1403. }
  1404. }
  1405.  
  1406. var style, result;
  1407. for (itm of document.querySelectorAll('DIV, A')) {
  1408. if (itm.tagName ==='DIV' && itm.offsetWidth > 0.95 * width() && itm.offsetHeight > 0.85 * height()) {
  1409. style = window.getComputedStyle(itm, null);
  1410. result = [];
  1411. if (style.backgroundImage !== 'none') {
  1412. result.push('background-image:none!important');
  1413. }
  1414. if (style.backgroundColor !== 'transparent' &&
  1415. style.backgroundColor !== 'rgba(0, 0, 0, 0)') {
  1416. result.push('background-color:transparent!important');
  1417. }
  1418. if (result.length) {
  1419. if (itm.getAttribute('style')) {
  1420. result.unshift(itm.getAttribute('style'));
  1421. }
  1422. (function(){
  1423. var fakeStyle = {
  1424. 'backgroundImage': itm.style.backgroundImage,
  1425. 'backgroundColor': itm.style.backgroundColor
  1426. };
  1427. try {
  1428. Object.defineProperty(itm, 'style', {
  1429. value: new Proxy(itm.style, {
  1430. get: function(target, prop){
  1431. if (fakeStyle.hasOwnProperty(prop)) {
  1432. return fakeStyle[prop];
  1433. } else {
  1434. return target[prop];
  1435. }
  1436. },
  1437. set: function(target, prop, value){
  1438. if (fakeStyle.hasOwnProperty(prop)) {
  1439. fakeStyle[prop] = value;
  1440. } else {
  1441. target[prop] = value;
  1442. }
  1443. return value;
  1444. }
  1445. }),
  1446. enumerable: true
  1447. });
  1448. } catch (e) {
  1449. console.log('Unable to protect style property.', e);
  1450. }
  1451. })();
  1452. if (protectedElems) {
  1453. protectedElems.set(itm, _getAttribute.call(itm, 'style'));
  1454. }
  1455. _setAttribute.call(itm, 'style', result.join(';'));
  1456. }
  1457. }
  1458. if (itm.tagName ==='A' && (itm.offsetWidth > 0.95 * width() || itm.offsetHeight > 0.85 * height())) {
  1459. if (protectedElems) {
  1460. protectedElems.set(itm, _getAttribute.call(itm, 'style'));
  1461. }
  1462. _setAttribute.call(itm, 'style', 'display:none!important');
  1463. }
  1464. }
  1465.  
  1466. for (itm of document.querySelectorAll('ASIDE>DIV')) {
  1467. if ( ((itm.querySelector('script, iframe, a[href*="/ad/www/"]') ||
  1468. itm.querySelector('img[src$=".gif"]:not([height="0"]), img[height="400"]')) &&
  1469. !itm.classList.contains('post') ) || !itm.childNodes.length ) {
  1470. remove(itm);
  1471. }
  1472. }
  1473.  
  1474. document.body.setAttribute('style', (document.body.getAttribute('style')||'')+';background-color:#E6E7E9!important');
  1475.  
  1476. // display content of the page
  1477. afterClean();
  1478. });
  1479. }
  1480. };
  1481.  
  1482. scripts['allmovie.pro'] = function() {
  1483. // pretend to be Android to make site use different played for ads
  1484. if (isSafari) {
  1485. return;
  1486. }
  1487. Object.defineProperty(navigator, 'userAgent', {
  1488. 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'; },
  1489. enumerable: true
  1490. });
  1491. };
  1492. scripts['rufilmtv.org'] = scripts['allmovie.pro'];
  1493.  
  1494. scripts['anidub-online.ru'] = function() {
  1495. var script = document.createElement('script');
  1496. script.type = "text/javascript";
  1497. script.innerHTML = "function ogonekstart1() {}";
  1498. document.getElementsByTagName('head')[0].appendChild(script);
  1499.  
  1500. var style = document.createElement('style');
  1501. style.type = 'text/css';
  1502. style.appendChild(document.createTextNode('.background {background: none!important;}'));
  1503. style.appendChild(document.createTextNode('.background > script + div, .background > script ~ div:not([id]):not([class]) + div[id][class] {display:none!important}'));
  1504. document.head.appendChild(style);
  1505. };
  1506. scripts['online.anidub.com'] = scripts['anidub-online.ru'];
  1507.  
  1508. scripts['fs.to'] = function() {
  1509. function skipClicker(i) {
  1510. if (!i) {
  1511. return;
  1512. }
  1513. var skip = document.querySelector('.b-aplayer-banners__close');
  1514. if (skip) {
  1515. skip.click();
  1516. } else {
  1517. setTimeout(skipClicker, 100, i-1);
  1518. }
  1519. }
  1520. setTimeout(skipClicker, 100, 30);
  1521.  
  1522. createStyle([
  1523. '.l-body-branding *,'+
  1524. '.b-styled__item-central,'+
  1525. '.b-styled__content-right,'+
  1526. '.b-styled__section-central,'+
  1527. 'div[id^="adsProxy-"]'+
  1528. '{display:none!important}',
  1529. 'body {background-image:url(data:image/png;base64,'+
  1530. 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAACX'+
  1531. 'BIWXMAAC4jAAAuIwF4pT92AAAADUlEQVR42mOQUdL5DwACMgFq'+
  1532. 'BC3ttwAAAABJRU5ErkJggg==)!important}'
  1533. ]);
  1534.  
  1535. if (/\/(view_iframe|iframeplayer)\//i.test(document.location.pathname)) {
  1536. var p = document.querySelector('#player:not([preload="auto"])'),
  1537. m = document.querySelector('.main'),
  1538. adStepper = function(p) {
  1539. if (p.currentTime < p.duration) {
  1540. p.currentTime += 1;
  1541. }
  1542. },
  1543. adSkipper = function(f, p) {
  1544. f.click();
  1545. p.waitAfterSkip = false;
  1546. p.longerSkipper = false;
  1547. console.log('Пропустили.');
  1548. },
  1549. cl = function(p) {
  1550. var faster = document.querySelector('.b-aplayer__html5-desktop-skip'),
  1551. series = document.querySelector('.b-aplayer__actions-series');
  1552.  
  1553. function clickSelected() {
  1554. var s = document.querySelector('.b-aplayer__popup-series-episodes .selected a');
  1555. if (s) {
  1556. s.click();
  1557. }
  1558. }
  1559.  
  1560. if ((!faster || faster.style.display !== 'block') && series && !p.seriesClicked) {
  1561. series.click();
  1562. p.seriesClicked = true;
  1563. p.longerSkipper = true;
  1564. setTimeout(clickSelected, 1000);
  1565. p.pause();
  1566. }
  1567.  
  1568. function skipListener() {
  1569. if (p.waitAfterSkip) {
  1570. console.log('В процессе пропуска…');
  1571. return;
  1572. }
  1573. p.pause();
  1574. if (!p.classList.contains('m-hidden')) {
  1575. p.classList.add('m-hidden');
  1576. }
  1577. if (faster && p.currentTime &&
  1578. win.getComputedStyle(faster).display === 'block' &&
  1579. !faster.querySelector('.b-aplayer__html5-desktop-skip-timer')) {
  1580. p.waitAfterSkip = true;
  1581. setTimeout(adSkipper, (p.longerSkipper?3:1)*1000, faster, p);
  1582. console.log('Доступен быстрый пропуск…');
  1583. } else {
  1584. setTimeout(adStepper, 1000, p);
  1585. }
  1586. }
  1587.  
  1588. p.addEventListener('timeupdate', skipListener, false);
  1589. },
  1590. o = new MutationObserver(function (ms) {
  1591. var m, node;
  1592. for (m of ms) {
  1593. for (node of m.addedNodes) {
  1594. if (node.id === 'player' &&
  1595. node.nodeName === 'VIDEO' &&
  1596. _getAttribute.call(node, 'preload') !== 'auto') {
  1597. cl(node);
  1598. }
  1599. }
  1600. }
  1601. });
  1602. if (p.nodeName === 'VIDEO') {
  1603. cl(p);
  1604. } else {
  1605. o.observe(m, {childList: true});
  1606. }
  1607. }
  1608. };
  1609. scripts['brb.to'] = scripts['fs.to'];
  1610. scripts['cxz.to'] = scripts['fs.to'];
  1611.  
  1612. scripts['drive2.ru'] = function() {
  1613. gardener('.c-block:not([data-metrika="recomm"]),.o-grid__item', />Реклама<\//i);
  1614. };
  1615.  
  1616. scripts['fishki.net'] = function() {
  1617. gardener('.drag_list > .drag_element, .list-view > .paddingtop15, .post-wrap', /543769|Новости партнеров/);
  1618. };
  1619.  
  1620. scripts['gidonline.club'] = {
  1621. 'now': function() {
  1622. createStyle('.tray > div[style] {display: none!important}');
  1623. }
  1624. };
  1625. scripts['gidonlinekino.com'] = scripts['gidonline.club'];
  1626.  
  1627. scripts['hdgo.cc'] = {
  1628. 'now': function(){
  1629. var o = new MutationObserver(function(ms) {
  1630. var m, node;
  1631. for (m of ms) {
  1632. for (node of m.addedNodes) {
  1633. if (node.tagName === 'SCRIPT' && _getAttribute(node, 'onerror') !== null) {
  1634. node.removeAttribute('onerror');
  1635. }
  1636. }
  1637. }
  1638. });
  1639. o.observe(document, {childList:true, subtree: true});
  1640. }
  1641. };
  1642. scripts['couber.be'] = scripts['hdgo.cc'];
  1643. scripts['46.30.43.38'] = scripts['hdgo.cc'];
  1644.  
  1645. scripts['gismeteo.ru'] = {
  1646. 'DOMContentLoaded': function() {
  1647. gardener('div > a[target^="_"]', /Яндекс\.Директ/i, { root: 'body', observe: true, parent: 'div[class*="frame"]' });
  1648. }
  1649. };
  1650.  
  1651. scripts['hdrezka.me'] = {
  1652. 'now': function() {
  1653. Object.defineProperty(win, 'fuckAdBlock', {
  1654. value: {
  1655. onDetected: function() {
  1656. console.log('Pretending to be an ABP detector.');
  1657. }
  1658. }
  1659. });
  1660. Object.defineProperty(win, 'ab', {
  1661. value: false,
  1662. enumerable: true
  1663. });
  1664. },
  1665. 'DOMContentLoaded': function() {
  1666. gardener('div[id][onclick][onmouseup][onmousedown]', /onmouseout/i);
  1667. }
  1668. };
  1669.  
  1670. scripts['imageban.ru'] = {
  1671. 'now': preventBackgroundRedirect,
  1672. 'DOMContentLoaded': function() {
  1673. win.addEventListener('unload', function() {
  1674. if (!window.location.hash) {
  1675. window.location.replace(window.location+'#');
  1676. } else {
  1677. window.location.hash = '';
  1678. }
  1679. }, true);
  1680. }
  1681. };
  1682.  
  1683. scripts['e.mail.ru'] = function() {
  1684. /*gardener('#LEGO :not([data-mnemo])>.js-href[data-id]',
  1685. /data:image.*>Реклама<|>Реклама<.*\/\/favicon\./i,
  1686. {root:'#LEGO', observe: true, parent:'div[id][class]'});*/
  1687. };
  1688.  
  1689. scripts['mail.ru'] = {
  1690. 'now': function() {
  1691. // Trick to prevent mail.ru from removing 3rd-party styles
  1692. scriptLander(function(){
  1693. Object.defineProperty(Object.prototype, 'restoreVisibility', {
  1694. get: function() { return function(){}; },
  1695. set: function() {}
  1696. });
  1697. });
  1698. }
  1699. };
  1700.  
  1701. scripts['megogo.net'] = {
  1702. 'now': function() {
  1703. Object.defineProperty(win, "adBlock", {
  1704. value : false,
  1705. enumerable : true
  1706. });
  1707. Object.defineProperty(win, "showAdBlockMessage", {
  1708. value : function () {},
  1709. enumerable : true
  1710. });
  1711. }
  1712. };
  1713.  
  1714. scripts['naruto-base.su'] = function() {
  1715. gardener('div[id^="entryID"],.block', /href="http.*?target="_blank"/i);
  1716. };
  1717.  
  1718. scripts['overclockers.ru'] = {
  1719. 'now': function() {
  1720. createStyle('.fixoldhtml {display:block!important}');
  1721. if (!isChrome && !isOpera) {
  1722. return; // Looks like my code works only in Chrome-like browsers
  1723. }
  1724. var noContentYet = true;
  1725. function jWrap() {
  1726. var _$ = win.$, _e = _$.extend;
  1727. win.$ = function() {
  1728. var _ret = _$.apply(window, arguments);
  1729. if (_ret[0] === document.body) {
  1730. _ret.html = function() {
  1731. console.log('Anti-adblock prevented.');
  1732. };
  1733. }
  1734. return _ret;
  1735. };
  1736. win.$.extend = function() {
  1737. return _e.apply(_$, arguments);
  1738. };
  1739. win.jQuery = win.$;
  1740. }
  1741. (function jReady() {
  1742. if (!win.$ && noContentYet) {
  1743. setTimeout(jReady, 0);
  1744. } else {
  1745. jWrap();
  1746. }
  1747. })();
  1748. document.addEventListener ('DOMContentLoaded', function(){
  1749. noContentYet = false;
  1750. }, false);
  1751. }
  1752. };
  1753. scripts['forums.overclockers.ru'] = {
  1754. 'now': function() {
  1755. createStyle('.needblock {position: fixed; left: -10000px}');
  1756. Object.defineProperty(win, 'adblck', {
  1757. value: 'no',
  1758. enumerable: true
  1759. });
  1760. }
  1761. };
  1762.  
  1763. scripts['pb.wtf'] = function() {
  1764. createStyle('.reques,#result,tbody.row1:not([id]) {display: none !important}');
  1765. // image in the slider in the header
  1766. gardener('a[href$="=="]', /img/i, {root:'.release-navbar', observe:true, parent:'div'});
  1767. // ads in blocks on the page
  1768. gardener('a[href^="/"]', /<img\s.*<br>/i, {root:'#main_content', observe:true, parent:'div[class]'});
  1769. // line above topic content
  1770. gardener('.re_top1', /./, {root:'#main_content', parent:'.hidden-sm'});
  1771. };
  1772. scripts['piratbit.org'] = scripts['pb.wtf'];
  1773. scripts['piratbit.ru'] = scripts['pb.wtf'];
  1774.  
  1775. scripts['pikabu.ru'] = function() {
  1776. gardener('.story', /story__sponsor|story__gag|profile\/ads"/i, {root: '.inner_wrap', observe: true});
  1777. };
  1778.  
  1779. scripts['rp5.ru'] = function() {
  1780. createStyle('#bannerBottom {display: none!important}');
  1781. var co = document.querySelector('#content'), i, nodes;
  1782. if (!co) {
  1783. return;
  1784. }
  1785. nodes = co.parentNode.childNodes;
  1786. i = nodes.length;
  1787. while (i--) {
  1788. if (nodes[i] !== co) {
  1789. nodes[i].parentNode.removeChild(nodes[i]);
  1790. }
  1791. }
  1792. };
  1793. scripts['rp5.by'] = scripts['rp5.ru'];
  1794. scripts['rp5.ua'] = scripts['rp5.ru'];
  1795.  
  1796. scripts['rustorka.com'] = {
  1797. 'now': function() {
  1798. createStyle('.header > div:not(.head-block) a, #sidebar1 img, #logo img {opacity:0!important}', {
  1799. id: 'tempHidingStyles'
  1800. }, true);
  1801. preventPopups();
  1802. },
  1803. 'DOMContentLoaded': function() {
  1804. for (var o of document.querySelectorAll('IMG, A')) {
  1805. if ((o.clientWidth === 728 && o.clientHeight === 90) ||
  1806. (o.clientWidth === 300 && o.clientHeight === 250)) {
  1807. while (o && o.tagName !== 'A') {
  1808. o = o.parentNode;
  1809. }
  1810. if (o) {
  1811. _setAttribute.call(o, 'style', 'display: none !important');
  1812. }
  1813. }
  1814. }
  1815. var s = document.querySelector('#tempHidingStyles');
  1816. s.parentNode.removeChild(s);
  1817. }
  1818. };
  1819. scripts['rumedia.ws'] = scripts['rustorka.com'];
  1820.  
  1821. scripts['sport-express.ru'] = function() {
  1822. gardener('.js-relap__item',/>Реклама\s+<\//, {root:'.container', observe: true});
  1823. };
  1824.  
  1825. scripts['sports.ru'] = function() {
  1826. gardener('.aside-news-list__item', /aside-news-list__advert/i, {root:'.columns-layout__left', observe: true});
  1827. gardener('.material-list__item', /Реклама/i, {root:'.columns-layout', observe: true});
  1828. // extra functionality: shows/hides panel at the top depending on scroll direction
  1829. createStyle([
  1830. '.user-panel__fixed { transition: top 0.2s ease-in-out!important; }',
  1831. '.user-panel-up { top: -40px!important }'
  1832. ], {id: 'userPanelSlide'}, false);
  1833. (function lookForPanel() {
  1834. var panel = document.querySelector('.user-panel__fixed');
  1835. if (!panel) {
  1836. setTimeout(lookForPanel, 100);
  1837. } else {
  1838. window.addEventListener('wheel', function(e){
  1839. if (e.deltaY > 0 && !panel.classList.contains('user-panel-up')) {
  1840. panel.classList.add('user-panel-up');
  1841. } else
  1842. if (e.deltaY < 0 && panel.classList.contains('user-panel-up')) {
  1843. panel.classList.remove('user-panel-up');
  1844. }
  1845. }, false);
  1846. }
  1847. })();
  1848. };
  1849.  
  1850. scripts['www.ukr.net'] = scripts['sinoptik.com.ru'];
  1851.  
  1852. scripts['vk.com'] = function() {
  1853. gardener('div[data-post-id]', /wall_marked_as_ads/, {root: '#page_wall_posts', observe: true});
  1854. };
  1855.  
  1856. scripts['yap.ru'] = function() {
  1857. var words = /member1438|Administration|\/go\/?.*yplkl\.php/;
  1858. gardener('form > table[id^="p_row_"]:nth-of-type(2)', words);
  1859. gardener('tr > .holder.newsbottom', words, {parent:'tr', siblings:-2});
  1860. };
  1861. scripts['yaplakal.com'] = scripts['yap.ru'];
  1862.  
  1863. scripts['rambler.ru'] = {
  1864. 'now': function() {
  1865. scriptLander(function() {
  1866. var _createElement = Document.prototype.createElement,
  1867. loadMap = new WeakMap();
  1868. Document.prototype.createElement = function createElement(name) {
  1869. /*jshint validthis:true */
  1870. var el = _createElement.apply(this, arguments);
  1871. if (el.tagName === 'LINK') {
  1872. Object.defineProperty(el, 'onload', {
  1873. get: function() {
  1874. return loadMap.get(loadMap.get(this));
  1875. },
  1876. set: function(func) {
  1877. var wrap = loadMap.get(this);
  1878. if (wrap) {
  1879. this.removeEventListener('load', wrap, false);
  1880. loadMap.remove(wrap);
  1881. loadMap.remove(this);
  1882. }
  1883. wrap = function(e) {
  1884. if (e.target && e.target.sheet && e.target.sheet.cssRules &&
  1885. e.target.sheet.cssRules[0] && e.target.sheet.cssRules[0].cssText &&
  1886. /\{\s*content\s*:\s*"[^"]+"/i.test(e.target.sheet.cssRules[0].cssText)) {
  1887. console.log('Blocked "onload" for', e.target.href);
  1888. return false;
  1889. }
  1890. return func.apply(this, arguments);
  1891. };
  1892. loadMap.set(this, wrap);
  1893. loadMap.set(wrap, func);
  1894. this.addEventListener('load', wrap, false);
  1895. },
  1896. enumberable: true
  1897. });
  1898. }
  1899. return el;
  1900. };
  1901. });
  1902. }
  1903. };
  1904.  
  1905. scripts['reactor.cc'] = {
  1906. 'now': function() {
  1907. win.open = (function(){ throw new Error('Redirect prevention.'); }).bind(window);
  1908. },
  1909. 'click': function(e) {
  1910. var node = e.target;
  1911. if (node.nodeType === Node.ELEMENT_NODE &&
  1912. node.style.position === 'absolute' &&
  1913. node.style.zIndex > 0)
  1914. node.parentNode.removeChild(node);
  1915. },
  1916. 'DOMContentLoaded': function() {
  1917. var words = new RegExp(
  1918. 'блокировщика рекламы'
  1919. .split('')
  1920. .map(function(e){return e+'[\u200b\u200c\u200d]*';})
  1921. .join('')
  1922. .replace(' ', '\\s*')
  1923. .replace(/[аоре]/g, function(e){return ['[аa]','[оo]','[рp]','[еe]']['аоре'.indexOf(e)];}),
  1924. 'i'),
  1925. can;
  1926. function deeper(spider) {
  1927. var c, l, n;
  1928. if (words.test(spider.innerText)) {
  1929. if (spider.nodeType === Node.TEXT_NODE) {
  1930. return true;
  1931. }
  1932. c = spider.childNodes;
  1933. l = c.length;
  1934. n = 0;
  1935. while(l--) {
  1936. if (deeper(c[l]), can) {
  1937. n++;
  1938. }
  1939. }
  1940. if (n > 0 && n === c.length && spider.offsetHeight < 750) {
  1941. can.push(spider);
  1942. }
  1943. return false;
  1944. }
  1945. return true;
  1946. }
  1947. function probe(){
  1948. if (words.test(document.body.innerText)) {
  1949. can = [];
  1950. deeper(document.body);
  1951. var i = can.length, j, spider;
  1952. while(i--) {
  1953. spider = can[i];
  1954. if (spider.offsetHeight > 10 && spider.offsetHeight < 750) {
  1955. _setAttribute.call(spider, 'style', 'background:none!important');
  1956. }
  1957. }
  1958. }
  1959. }
  1960. var o = new MutationObserver(probe);
  1961. o.observe(document,{childList:true, subtree:true});
  1962. }
  1963. };
  1964. scripts['joyreactor.cc'] = scripts['reactor.cc'];
  1965. scripts['pornreactor.cc'] = scripts['reactor.cc'];
  1966.  
  1967. scripts['auto.ru'] = function() {
  1968. var words = /Реклама|Яндекс.Директ|yandex_ad_/;
  1969. var userAdsListAds = [
  1970. '.listing-list > .listing-item',
  1971. '.listing-item_type_fixed.listing-item'
  1972. ];
  1973. var catalogAds = [
  1974. 'div[class*="layout_catalog-inline"]',
  1975. 'div[class$="layout_horizontal"]'
  1976. ];
  1977. var otherAds = [
  1978. '.advt_auto',
  1979. '.sidebar-block',
  1980. '.pager-listing + div[class]',
  1981. '.card > div[class][style]',
  1982. '.sidebar > div[class]',
  1983. '.main-page__section + div[class]',
  1984. '.listing > tbody'];
  1985. gardener(userAdsListAds.join(','), words, {root:'.listing-wrap', observe:true});
  1986. gardener(catalogAds.join(','), words, {root:'.catalog__page,.content__wrapper', observe:true});
  1987. gardener(otherAds.join(','), words);
  1988. };
  1989.  
  1990. scripts['rsload.net'] = {
  1991. 'load': function() {
  1992. var dis = document.querySelector('label[class*="cb-disable"]');
  1993. if (dis) {
  1994. dis.click();
  1995. }
  1996. },
  1997. 'click': function(e) {
  1998. var t = e.target;
  1999. if (t && t.href && (/:\/\/\d+\.\d+\.\d+\.\d+\//.test(t.href))) {
  2000. t.href = t.href.replace('://','://rsload.net:rsload.net@');
  2001. }
  2002. }
  2003. };
  2004.  
  2005. var domain = document.domain, name;
  2006. while (domain.indexOf('.') !== -1) {
  2007. if (scripts.hasOwnProperty(domain)) {
  2008. if (typeof scripts[domain] === 'function') {
  2009. document.addEventListener ('DOMContentLoaded', scripts[domain], false);
  2010. }
  2011. for (name in scripts[domain]) {
  2012. if (name !== 'now') {
  2013. (name === 'load' ? window : document)
  2014. .addEventListener (name, scripts[domain][name], false);
  2015. } else {
  2016. scripts[domain][name]();
  2017. }
  2018. }
  2019. }
  2020. domain = domain.slice(domain.indexOf('.') + 1);
  2021. }
  2022. })();

QingJ © 2025

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