Greasy Fork 还支持 简体中文。

RU AdList JS Fixes

try to take over the world!

目前為 2017-05-10 提交的版本,檢視 最新版本

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