RU AdList JS Fixes

try to take over the world!

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

  1. // ==UserScript==
  2. // @name RU AdList JS Fixes
  3. // @namespace ruadlist_js_fixes
  4. // @version 20170522.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. (new MutationObserver(function() {
  186. root.removeChild(style);
  187. })).observe(style, {childList: true});
  188. }
  189.  
  190. function _create() {
  191. var style = root.appendChild(document.createElement('style'));
  192. style.type = 'text/css';
  193. for (var prop in props) {
  194. if (style[prop] !== undefined) {
  195. style[prop] = props[prop];
  196. }
  197. }
  198. function insertRule(rule) {
  199. try {
  200. style.sheet.insertRule(rule, 0);
  201. } catch (e) {
  202. console.error(e);
  203. }
  204. }
  205. if (typeof rules === 'string') {
  206. insertRule(rules);
  207. } else {
  208. rules.forEach(insertRule);
  209. }
  210. if (!skip_protect) {
  211. _protect(style);
  212. }
  213. return style;
  214. }
  215.  
  216. var style = _create();
  217. if (skip_protect) {
  218. return style;
  219. }
  220.  
  221. (new MutationObserver(function(ms){
  222. var m, node,
  223. resolveInANewContext = function(resolve){
  224. setTimeout(function(resolve){
  225. resolve(_create());
  226. }, 0, resolve);
  227. },
  228. setStyle = function(st){
  229. style = st;
  230. };
  231. for (m of ms) {
  232. for (node of m.removedNodes) {
  233. if (node === style) {
  234. (new Promise(resolveInANewContext))
  235. .then(setStyle);
  236. }
  237. }
  238. }
  239. })).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^', '||octozoon.org^',
  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. (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. })).observe(document, {
  636. childList : true,
  637. attributes : true,
  638. attributeFilter : ['style'],
  639. subtree : true
  640. });
  641.  
  642. win.addEventListener ("load", function(){
  643. var c = 0, imp;
  644. for (imp of document.querySelectorAll('[style*="!"]')) {
  645. c+= checkTarget(imp, c);
  646. }
  647. logger(c);
  648. }, false);
  649. })();
  650.  
  651. }
  652.  
  653. if (/^https?:\/\/(mail\.yandex\.|music\.yandex\.|news\.yandex\.|(www\.)?yandex\.[^\/]+\/(yand)?search[\/?])/i.test(win.location.href)) {
  654. // https://gf.qytechs.cn/en/scripts/809-no-yandex-ads
  655. (function(){
  656. var adWords = ['Яндекс.Директ','Реклама','Ad'],
  657. genericAdSelectors = (
  658. '.serp-adv__head + .serp-item,'+
  659. '#adbanner,'+
  660. '.serp-adv,'+
  661. '.b-spec-adv,'+
  662. 'div[class*="serp-adv__"]:not(.serp-adv__found):not(.serp-adv__displayed)'
  663. );
  664. function remove(node) {
  665. node.parentNode.removeChild(node);
  666. }
  667. // Generic ads removal and fixes
  668. function removeGenericAds() {
  669. var s = document.querySelector('.serp-header');
  670. if (s) {
  671. s.style.marginTop='0';
  672. }
  673. for (s of document.querySelectorAll(genericAdSelectors)) {
  674. remove(s);
  675. }
  676. }
  677. // Search ads
  678. function removeSearchAds() {
  679. var s, item, l;
  680. for (s of document.querySelectorAll('.t-construct-adapter__legacy')) {
  681. item = s.querySelector('.organic__subtitle');
  682. l = window.getComputedStyle(item, ':after').content;
  683. if (item && adWords.indexOf(l.replace(/"/g,'')) > -1) {
  684. remove(s);
  685. console.log('Ads removed.');
  686. }
  687. }
  688. }
  689. // News ads
  690. function removeNewsAds() {
  691. for (var s of document.querySelectorAll(
  692. '.page-content__left > *,'+
  693. '.page-content__right > *:not(.page-content__col),'+
  694. '.page-content__right > .page-content__col > *'
  695. )) {
  696. if (s.textContent.indexOf(adWords[0]) > -1 ||
  697. (s.clientHeight < 15 && s.classList.contains('rubric'))) {
  698. remove(s);
  699. console.log('Ads removed.');
  700. }
  701. }
  702. }
  703. // Music ads
  704. function removeMusicAds() {
  705. for (var s of document.querySelectorAll('.ads-block')) {
  706. remove(s);
  707. }
  708. }
  709. // Mail ads
  710. function removeMailAds() {
  711. var slice = Array.prototype.slice,
  712. nodes = slice.call(document.querySelectorAll('.ns-view-folders')),
  713. node, len, cls;
  714. for (node of nodes) {
  715. if (!len || len > node.classList.length) {
  716. len = node.classList.length;
  717. }
  718. }
  719. node = nodes.pop();
  720. while (node) {
  721. if (node.classList.length > len) {
  722. for (cls of slice.call(node.classList)) {
  723. if (cls.indexOf('-') === -1) {
  724. remove(node);
  725. break;
  726. }
  727. }
  728. }
  729. node = nodes.pop();
  730. }
  731. }
  732. // News fixes
  733. function removePageAdsClass() {
  734. if (document.body.classList.contains("b-page_ads_yes")){
  735. document.body.classList.remove("b-page_ads_yes");
  736. console.log('Page ads class removed.');
  737. }
  738. }
  739. // Function to attach an observer to monitor dynamic changes on the page
  740. function pageUpdateObserver(func, obj, params) {
  741. if (obj) {
  742. (new MutationObserver(func)).observe(obj,(params || {childList:true, subtree:true}));
  743. }
  744. }
  745. // Cleaner
  746. document.addEventListener ('DOMContentLoaded', function() {
  747. removeGenericAds();
  748. if (win.location.hostname.search(/^mail\./i) === 0) {
  749. pageUpdateObserver(function(ms, o){
  750. var aside = document.querySelector('.mail-Layout-Aside');
  751. if (aside) {
  752. o.disconnect();
  753. pageUpdateObserver(removeMailAds, aside);
  754. }
  755. }, document.querySelector('BODY'));
  756. removeMailAds();
  757. } else if (win.location.hostname.search(/^music\./i) === 0) {
  758. pageUpdateObserver(removeMusicAds, document.querySelector('.sidebar'));
  759. removeMusicAds();
  760. } else if (win.location.hostname.search(/^news\./i) === 0) {
  761. pageUpdateObserver(removeNewsAds, document.querySelector('BODY'));
  762. pageUpdateObserver(removePageAdsClass, document.body, {attributes:true, attributesFilter:['class']});
  763. removeNewsAds();
  764. removePageAdsClass();
  765. } else {
  766. pageUpdateObserver(removeSearchAds, document.querySelector('.main__content'));
  767. removeSearchAds();
  768. }
  769. });
  770. })();
  771. }
  772. // Yandex Link Tracking
  773. if (/^https?:\/\/([^.]+\.)*yandex\.[^\/]+/i.test(win.location.href)) {
  774. // Partially based on https://gf.qytechs.cn/en/scripts/22737-remove-yandex-redirect
  775. (function(){
  776. var link, selectors = (
  777. 'A[onmousedown*="/jsredir"],'+
  778. 'A[data-vdir-href],'+
  779. 'A[data-counter]'
  780. );
  781. function removeTrackingAttributes(link) {
  782. link.removeAttribute('onmousedown');
  783. if (link.hasAttribute('data-vdir-href')) {
  784. link.removeAttribute('data-vdir-href');
  785. link.removeAttribute('data-orig-href');
  786. }
  787. if (link.hasAttribute('data-counter')) {
  788. link.removeAttribute('data-counter');
  789. link.removeAttribute('data-bem');
  790. }
  791. }
  792. function removeTracking(scope) {
  793. for (link of scope.querySelectorAll(selectors)) {
  794. removeTrackingAttributes(link);
  795. }
  796. }
  797. document.addEventListener('DOMContentLoaded', function(e) {
  798. removeTracking(e.target);
  799. });
  800. (new MutationObserver(function(ms) {
  801. var m, node;
  802. for (m of ms) {
  803. for (node of m.addedNodes) {
  804. if (node.nodeType === Node.ELEMENT_NODE) {
  805. if (node.tagName === 'A' && node.matches(selectors)) {
  806. removeTrackingAttributes(node);
  807. } else {
  808. removeTracking(node);
  809. }
  810. }
  811. }
  812. }
  813. })).observe(_de, {childList: true, subtree: true});
  814. })();
  815. return; //skip fixes for other sites
  816. }
  817.  
  818. // https://gf.qytechs.cn/en/scripts/21937-moonwalk-hdgo-kodik-fix v0.8 (adapted)
  819. document.addEventListener ('DOMContentLoaded', function() {
  820. var tmp;
  821. function log (e) {
  822. console.log('Moonwalk&HDGo&Kodik FIX: ' + e + ' player in ' + win.location.href);
  823. }
  824. if (win.adv_enabled !== undefined && win.condition_detected !== undefined) { // moonwalk
  825. log('Moonwalk');
  826. if (win.adv_enabled) {
  827. win.adv_enabled = false;
  828. }
  829. win.condition_detected = false;
  830. if (win.MXoverrollCallback) {
  831. document.addEventListener('click', function catcher(e){
  832. e.stopPropagation();
  833. win.MXoverrollCallback.call(window);
  834. document.removeEventListener('click', catcher, true);
  835. }, true);
  836. }
  837. } else if (win.stat_url !== undefined && win.is_html5 !== undefined && win.is_wp8 !== undefined) { // hdgo
  838. log('HDGo');
  839. document.body.onclick = null;
  840. tmp = document.querySelector('#swtf');
  841. if (tmp) {
  842. tmp.style.display = 'none';
  843. }
  844. if (win.banner_second !== undefined) {
  845. win.banner_second = 0;
  846. }
  847. if (win.$banner_ads !== undefined) {
  848. win.$banner_ads = false;
  849. }
  850. if (win.$new_ads !== undefined) {
  851. win.$new_ads = false;
  852. }
  853. if (win.createCookie !== undefined) {
  854. win.createCookie('popup','true','999');
  855. }
  856. if (win.canRunAds !== undefined && win.canRunAds !== true) {
  857. win.canRunAds = true;
  858. }
  859. } else if (win.MXoverrollCallback && win.iframeSearch !== undefined) { // kodik
  860. log('Kodik');
  861. tmp = document.querySelector('.play_button');
  862. if (tmp) {
  863. tmp.onclick = win.MXoverrollCallback.bind(window);
  864. }
  865. win.IsAdBlock = false;
  866. }
  867. }, false);
  868.  
  869. // Automated protection against specific circumvention method based on unwrapping various functions,
  870. // hiding ads in the Shadow DOM and injecting iFrames with ads. Previously this code were known as
  871. // apiBreaker since it were breaking Shadow DOM and onerror/onload API on specific domains. This
  872. // version should be safe enough to run on majority of sites without actually breaking them.
  873. scriptLander(function() {
  874. var blacklist = new WeakMap(),
  875. replacer, func;
  876. /* Wrap functions used to attach shadow root to a node */
  877. replacer = function (func) {
  878. return function() {
  879. blacklist.set(this, true);
  880. return func.apply(this, arguments);
  881. };
  882. };
  883. for (func of ['createShadowRoot', 'attachShadow']) {
  884. if (func in Element.prototype) {
  885. Element.prototype[func] = replacer(Element.prototype[func]);
  886. }
  887. }
  888. /* Wrap functions used to insert/append elements to check for IFRAME objects */
  889. replacer = function (func) {
  890. return function(el, par) {
  891. if (el.tagName === 'IFRAME' &&
  892. ((typeof par === 'object' && blacklist.get(par))/* ||
  893. el.style.display === 'none'*/)) {
  894. console.log('Blocked suspicious', func.name, arguments);
  895. return null;
  896. }
  897. return func.apply(this, arguments);
  898. };
  899. };
  900. for (func of [/*'appendChild', */'insertBefore']) {
  901. Object.defineProperty(Element.prototype, func, {
  902. value: replacer(Element.prototype[func]), enumerable: true
  903. });
  904. }
  905. });
  906.  
  907. // === Helper functions ===
  908.  
  909. // function to search and remove nodes by content
  910. // selector - standard CSS selector to define set of nodes to check
  911. // words - regular expression to check content of the suspicious nodes
  912. // params - object with multiple extra parameters:
  913. // .log - display log in the console
  914. // .hide - set display to none instead of removing from the page
  915. // .parent - parent node to remove if content is found in the child node
  916. // .siblings - number of simling nodes to remove (excluding text nodes)
  917. function scRemove(e) {
  918. e.parentNode.removeChild(e);
  919. }
  920. function scHide(e) {
  921. var s = _getAttribute.call(e, 'style') || '',
  922. h = ';display:none!important;';
  923. if (s.indexOf(h) < 0) {
  924. _setAttribute.call(e, 'style', s+h);
  925. }
  926. }
  927. function scissors (selector, words, scope, params) {
  928. if (params.log) console.log('[s] starting with', selector, words, scope, JSON.stringify(params));
  929. var remFunc = (params.hide ? scHide : scRemove),
  930. iterFunc = (params.siblings > 0 ?
  931. 'nextSibling' :
  932. 'previousSibling'),
  933. toRemove = [],
  934. siblings,
  935. node;
  936. for (node of scope.querySelectorAll(selector)) {
  937. if (params.log) console.log('[s] found node', node);
  938. if (params.parent) {
  939. while(node !== scope && !(node.matches(params.parent))) {
  940. node = node.parentNode;
  941. }
  942. if (params.log) console.log('[s] moving to parent node', node);
  943. }
  944. if (words.test(node.innerHTML) || !node.childNodes.length) {
  945. // drill up to the specified parent node if required
  946. if (node === scope) {
  947. if (params.log) console.log('[s] oops, we don\'t want to remove our scope!');
  948. break;
  949. }
  950. if (toRemove.indexOf(node) === -1) {
  951. if (params.log) console.log('[s] adding node into list for removal');
  952. toRemove.push(node);
  953. // add multiple nodes if defined more than one sibling
  954. siblings = Math.abs(params.siblings) || 0;
  955. while (siblings) {
  956. node = node[iterFunc];
  957. if (node.nodeType === Node.ELEMENT_NODE) {
  958. if (params.log) console.log('[s] adding sibling node', node);
  959. toRemove.push(node);
  960. siblings -= 1; //count only element nodes
  961. } else if (!params.hide) {
  962. if (params.log) console.log('[s] adding sibling node', node);
  963. toRemove.push(node);
  964. }
  965. }
  966. } else {
  967. if (params.log) console.log('[s] node already marked for removal');
  968. }
  969. } else {
  970. if (params.log) console.log('[s] word test failed, proceed to the next node');
  971. }
  972. }
  973. if (params.log) console.log('[s] proceed with', (params.hide?'hide':'removal'), 'of', toRemove);
  974. for (node of toRemove) {
  975. remFunc(node);
  976. }
  977. return toRemove.length;
  978. }
  979.  
  980. // function to perform multiple checks if ads inserted with a delay
  981. // by default does 30 checks withing a 3 seconds unless nonstop mode specified
  982. // also does 1 extra check when a page completely loads
  983. // selector and words - passed dow to scissors
  984. // params - object with multiple extra parameters:
  985. // .log - display log in the console
  986. // .root - selector to narrow down scope to scan;
  987. // .observe - if true then check will be performed continuously;
  988. // Other parameters passed down to scissors.
  989. function gardener(selector, words, params) {
  990. params = params || {};
  991. if (params.log) console.log('[g] starting with', selector, words, JSON.stringify(params));
  992. var scope = document,
  993. nonstop = false;
  994. // narrow down scope to a specific element
  995. if (params.root) {
  996. scope = scope.querySelector(params.root);
  997. if (!scope) {// exit if the root element is not present on the page
  998. return 0;
  999. }
  1000. if (params.log) console.log('[g] scope', scope);
  1001. }
  1002. // add observe mode if required
  1003. if (params.observe) {
  1004. if (typeof MutationObserver === 'function') {
  1005. (new MutationObserver(function(ms){
  1006. for (var m of ms) {
  1007. if (m.addedNodes.length) {
  1008. scissors(selector, words, scope, params);
  1009. }
  1010. }
  1011. })).observe(scope, {childList:true, subtree: true});
  1012. if (params.log) console.log('[g] observer enabled');
  1013. } else {
  1014. nonstop = true;
  1015. if (params.log) console.log('[g] nonstop mode enabled');
  1016. }
  1017. }
  1018. // wait for a full page load to do one extra cut
  1019. win.addEventListener('load',function(){
  1020. if (params.log) console.log('[g] onload cleanup');
  1021. scissors(selector, words, scope, params);
  1022. });
  1023. // do multiple cuts until ads removed
  1024. function cut(sci, s, w, sc, p, i) {
  1025. if (i > 0) {
  1026. i -= 1;
  1027. }
  1028. if (i && !sci(s, w, sc, p)) {
  1029. setTimeout(cut, 100, sci, s, w, sc, p, i);
  1030. }
  1031. }
  1032. cut(scissors, selector, words, scope, params, (nonstop ? -1 : 30));
  1033. }
  1034.  
  1035. // Helper function to close background tab if site opens itself in a new tab and then
  1036. // loads a 3rd-party page in the background one (thus performing background redirect).
  1037. function preventBackgroundRedirect() {
  1038. // create "cose_me" event to call high-level window.close()
  1039. var key = Math.random().toString(36).substr(2);
  1040. window.addEventListener('close_me_'+key, function(e) {
  1041. window.close();
  1042. });
  1043.  
  1044. // window.open wrapper
  1045. function pbrLander() {
  1046. var orgOpen = window.open.bind(window),
  1047. idx = String.prototype.indexOf,
  1048. event = new CustomEvent("close_me_%key%", {});
  1049. function closeWindow(){
  1050. // site went to a new tab and attempts to unload
  1051. // call for high-level close through event
  1052. window.dispatchEvent(event);
  1053. }
  1054. // window.open wrapper
  1055. function open(){
  1056. console.log(arguments, window.location.host);
  1057. if (arguments[0] &&
  1058. (idx.call(arguments[0], window.location.host) > -1 ||
  1059. idx.call(arguments[0], '://') === -1)) {
  1060. window.addEventListener('unload', closeWindow, true);
  1061. }
  1062. orgOpen.apply(window, arguments);
  1063. }
  1064. window.open = open.bind(window);
  1065. // Node.createElement wrapper to prevent click-dispatch in Google Chrome and similar browsers
  1066. var realCreateElement = Document.prototype.createElement;
  1067. function wrappedCreateElement(name) {
  1068. /*jshint validthis:true */
  1069. var el = realCreateElement.apply(this, arguments);
  1070. if (el.tagName === 'A') {
  1071. el.addEventListener('click', function(e){
  1072. if (!e.target.parentNode || !e.isTrusted) {
  1073. window.addEventListener('unload', closeWindow, true);
  1074. }
  1075. }, false);
  1076. }
  1077. return el;
  1078. }
  1079. Document.prototype.createElement = wrappedCreateElement;
  1080. }
  1081.  
  1082. // land wrapper on the page
  1083. var script = document.createElement('script');
  1084. script.appendChild(document.createTextNode('('+pbrLander.toString().replace(/%key%/g,key)+')();'));
  1085. document.head.insertBefore(script, document.head.firstChild);
  1086. script.parentNode.removeChild(script);
  1087. console.log("Background redirect prevention enabled.");
  1088. }
  1089.  
  1090. // Function to catch and block various methods to open a new window with 3rd-party content.
  1091. // Some advertisement networks went way past simple window.open call to circumvent default popup protection.
  1092. // This funciton blocks window.open, ability to restore original window.open from an IFRAME object,
  1093. // ability to perform an untrusted (not initiated by user) click on a link, click on a link without a parent
  1094. // node or simply a link with piece of javascript code in the HREF attribute.
  1095. function preventPopups() {
  1096. function open(){
  1097. console.log('Site attempted to open a new window', arguments);
  1098. function nil(){}
  1099. return {
  1100. document: {
  1101. write: nil,
  1102. writeln: nil
  1103. }
  1104. };
  1105. }
  1106. win.open = exportFunction(open, win);
  1107.  
  1108. function wrapFunctions() {
  1109. var realCreateElement = Document.prototype.createElement,
  1110. realAppendChild = Element.prototype.appendChild;
  1111. Document.prototype.createElement = function createElement(name) {
  1112. /*jshint validthis:true */
  1113. var el = realCreateElement.apply(this, arguments);
  1114. if (el.tagName === 'A') {
  1115. el.addEventListener('click', function(e) {
  1116. if (!e.target.parentNode || !e.isTrusted ||
  1117. (e.target.href && e.target.href.toLowerCase().indexOf('javascript') > -1)) {
  1118. e.preventDefault();
  1119. console.log('Blocked suspicious click event', e, 'on', e.target);
  1120. }
  1121. }, false);
  1122. }
  1123. if (el.tagName === 'IFRAME') {
  1124. el.addEventListener('load', function(){
  1125. try {
  1126. this.contentWindow.open = open;
  1127. } catch(ignore) {}
  1128. }, false);
  1129. }
  1130. return el;
  1131. };
  1132. Element.prototype.appendChild = function appendChild() {
  1133. var child = realAppendChild.apply(this, arguments);
  1134. if (child && child.nodeType === Node.ELEMENT_NODE && child.tagName === 'IFRAME') {
  1135. try {
  1136. child.contentWindow.open = open;
  1137. } catch(ignore) {}
  1138. }
  1139. return child;
  1140. };
  1141. }
  1142.  
  1143. scriptLander(wrapFunctions, [open]);
  1144. }
  1145.  
  1146. // Currently unused piece of code developed to prevent site from registering serviceWorker
  1147. // and uninstall any existing instances of serivceWorker in case there is one already.
  1148. /* Commented out since not used
  1149. function forbidServiceWorker() {
  1150. if (!("serviceWorker" in navigator)) {
  1151. return;
  1152. }
  1153. var svr = navigator.serviceWorker.ready;
  1154. Object.defineProperty(navigator, 'serviceWorker', {
  1155. value: {
  1156. register: function(){
  1157. console.log('Registration of serviceWorker ' + arguments[0] + ' blocked.');
  1158. return new Promise(function(){});
  1159. },
  1160. ready: new Promise(function(){}),
  1161. addEventListener:function(){}
  1162. }
  1163. });
  1164. document.addEventListener('DOMContentLoaded', function() {
  1165. if (!svr) {
  1166. return;
  1167. }
  1168. svr.then(function(sw) {
  1169. console.log('Found existing serviceWorker:', sw);
  1170. console.log('Attempting to unregister...');
  1171. sw.unregister().then(function() {
  1172. console.log('Unregistered! :)');
  1173. }).catch(function(err) {
  1174. console.log('Unregistration failed. :(', err);
  1175. console.log('Try to remove it manually:');
  1176. console.log(' 1. Open: chrome://serviceworker-internals/ (Google Chrome and alike) or about:serviceworkers (Mozilla Firefox) in a new tab.');
  1177. console.log(' 2. Search there for one with "'+document.domain+'" in the name.');
  1178. console.log(' 3. Use buttons in the same block with service you found to stop it and uninstall/unregister.');
  1179. });
  1180. }).catch(function(err) {
  1181. console.log("Lol, it failed on it's own. -_-", err);
  1182. });
  1183. }, false);
  1184. }
  1185. /**/
  1186.  
  1187. // Currently obsolete code developed to prevent error and load calls on objects supposed to load resources
  1188. // from the internet like IMG or IFRAME, but missing SRC/HREF attribute. Usually tricks like this are used
  1189. // to unwrap wrapped functions to be able to load ads.
  1190. /* Commented out since not used
  1191. function errorAndLoadEventsFilter() {
  1192. var toString = Function.prototype.toString,
  1193. addEventListener = Element.prototype.addEventListener,
  1194. removeEventListener = Element.prototype.removeEventListener,
  1195. hasAttribute = Element.prototype.hasAttribute,
  1196. evtMap = new WeakMap();
  1197. Element.prototype.addEventListener = function(evt, func, capt) {
  1198. if (evt === 'error' || evt === 'load') {
  1199. if (!evtMap.get(func)) {
  1200. evtMap.set(func, function() {
  1201. if (hasAttribute.call(this, 'src') ||
  1202. hasAttribute.call(this, 'href')) {
  1203. func.apply(this, arguments);
  1204. } else {
  1205. console.log('Blocked', evt, 'handler', toString.call(func), 'on', this);
  1206. }
  1207. });
  1208. }
  1209. }
  1210. addEventListener.call(this, evt, (evtMap.get(func) || func), capt);
  1211. };
  1212. Element.prototype.removeEventListener = function(evt, func, capt) {
  1213. removeEventListener.call(this, evt, (evtMap.get(func) || func), capt);
  1214. };
  1215. Object.defineProperty(HTMLElement.prototype, 'onload', {
  1216. set: function(func) {
  1217. if(evtMap.has(this)) {
  1218. if (evtMap.get(this).onload) {
  1219. Element.prototype.removeEventListener.call(this, 'load', evtMap.get(this).onload, false);
  1220. }
  1221. evtMap.get(this).onload = func;
  1222. } else {
  1223. evtMap.set(this, { onload: func });
  1224. }
  1225. if (func) {
  1226. Element.prototype.addEventListener.call(this, 'load', func, false);
  1227. }
  1228. return func;
  1229. },
  1230. get: function() {
  1231. return evtMap.has(this) ? evtMap.get(this).onload : null;
  1232. }
  1233. });
  1234. Object.defineProperty(HTMLElement.prototype, 'onerror', {
  1235. set: function(func) {
  1236. if (evtMap.has(this)) {
  1237. evtMap.get(this).onerror = func;
  1238. } else {
  1239. evtMap.set(this, { onerror: func });
  1240. }
  1241. if (func) {
  1242. console.log('Blocked error handler', toString.call(func), 'on', this);
  1243. }
  1244. return func;
  1245. },
  1246. get: function() {
  1247. return evtMap.has(this) ? evtMap.get(this).onerror : null;
  1248. }
  1249. });
  1250. }
  1251. /**/
  1252.  
  1253. // === Scripts for specific domains ===
  1254.  
  1255. var scripts = {};
  1256. // prevent popups and redirects block
  1257. var preventPopupsNow = { 'now': preventPopups },
  1258. preventBackgroundRedirectNow = { 'now': preventBackgroundRedirect };
  1259. // Popups
  1260. scripts['biqle.ru'] = preventPopupsNow;
  1261. scripts['chaturbate.com'] = preventPopupsNow;
  1262. scripts['dfiles.ru'] = preventPopupsNow;
  1263. scripts['hentaiz.org'] = preventPopupsNow;
  1264. scripts['mirrorcreator.com'] = preventPopupsNow;
  1265. scripts['online-multy.ru'] = preventPopupsNow;
  1266. scripts['openload.co'] = preventPopupsNow;
  1267. scripts['radikal.ru'] = preventPopupsNow;
  1268. scripts['seedoff.cc'] = preventPopupsNow;
  1269. scripts['tapochek.net'] = preventPopupsNow;
  1270. scripts['thepiratebay.org'] = preventPopupsNow;
  1271. scripts['torseed.net'] = preventPopupsNow;
  1272. scripts['zippyshare.com'] = preventPopupsNow;
  1273. // Background redirects
  1274. scripts['mediafire.com'] = preventBackgroundRedirectNow;
  1275. scripts['megapeer.org'] = preventBackgroundRedirectNow;
  1276. scripts['megapeer.ru'] = preventBackgroundRedirectNow;
  1277. scripts['perfectgirls.net'] = preventBackgroundRedirectNow;
  1278. scripts['turbobit.net'] = preventBackgroundRedirectNow;
  1279.  
  1280. // other
  1281. scripts['4pda.ru'] = {
  1282. 'now': function() {
  1283. // https://gf.qytechs.cn/en/scripts/14470-4pda-unbrender
  1284. var isForum = document.location.href.search('/forum/') !== -1,
  1285. hStyle;
  1286.  
  1287. function remove(n) {
  1288. if (n) {
  1289. n.parentNode.removeChild(n);
  1290. }
  1291. }
  1292.  
  1293. function afterClean() {
  1294. hStyle.disabled = true;
  1295. remove(hStyle);
  1296. }
  1297.  
  1298. function beforeClean() {
  1299. // attach styles before document displayed
  1300. hStyle = createStyle([
  1301. 'html { overflow-y: scroll }',
  1302. 'section[id] {'+(
  1303. 'position: absolute;'+
  1304. 'width: 100%'
  1305. )+'}',
  1306. 'article + aside * { display: none !important }',
  1307. '#header + div:after {'+(
  1308. 'content: "";'+
  1309. 'position: fixed;'+
  1310. 'top: 0;'+
  1311. 'left: 0;'+
  1312. 'width: 100%;'+
  1313. 'height: 100%;'+
  1314. 'background-color: #E6E7E9'
  1315. )+'}',
  1316. // http://codepen.io/Beaugust/pen/DByiE
  1317. '@keyframes spin { 100% { transform: rotate(360deg) } }',
  1318. 'article + aside:after {'+(
  1319. 'content: "";'+
  1320. 'position: absolute;'+
  1321. 'width: 150px;'+
  1322. 'height: 150px;'+
  1323. 'top: 150px;'+
  1324. 'left: 50%;'+
  1325. 'margin-top: -75px;'+
  1326. 'margin-left: -75px;'+
  1327. 'box-sizing: border-box;'+
  1328. 'border-radius: 100%;'+
  1329. 'border: 10px solid rgba(0, 0, 0, 0.2);'+
  1330. 'border-top-color: rgba(0, 0, 0, 0.6);'+
  1331. 'animation: spin 2s infinite linear'
  1332. )+'}'
  1333. ], {id:'ubrHider'}, true);
  1334.  
  1335. // display content of a page if time to load a page is more than 2 seconds to avoid
  1336. // blocking access to a page if it is loading for too long or stuck in a loading state
  1337. setTimeout(2000, afterClean);
  1338. }
  1339.  
  1340. createStyle([
  1341. '#nav .use-ad { display: block !important }',
  1342. 'article:not(.post) + article:not(#id), a[target="_blank"] img[height="90"] { display: none !important }'
  1343. ]);
  1344.  
  1345. if (!isForum) {
  1346. beforeClean();
  1347. }
  1348.  
  1349. // save links to non-overridden functions to use later
  1350. var protectedElems;
  1351. // protect/hide changed attributes in case site attempt to restore them
  1352. function styleProtector(eventMode) {
  1353. var isStyleText = function(t){ return t === 'style'; },
  1354. returnUndefined = function(){},
  1355. protectedElems = new WeakMap();
  1356. function protoOverride(element, functionName, isStyleCheck, returnIfProtected) {
  1357. var oF = element.prototype[functionName], r;
  1358. element.prototype[functionName] = function() {
  1359. if (protectedElems.has(this) && isStyleCheck(arguments[0])) {
  1360. return returnIfProtected(this, arguments);
  1361. }
  1362. r = oF.apply(this, arguments);
  1363. return r;
  1364. };
  1365. }
  1366. protoOverride(Element, 'removeAttribute', isStyleText, returnUndefined);
  1367. protoOverride(Element, 'hasAttribute', isStyleText, function(_this) {
  1368. return protectedElems.get(_this) !== null;
  1369. });
  1370. protoOverride(Element, 'setAttribute', isStyleText, function(_this, args) {
  1371. protectedElems.set(_this, args[1]);
  1372. });
  1373. protoOverride(Element, 'getAttribute', isStyleText, function(_this) {
  1374. return protectedElems.get(_this);
  1375. });
  1376. if (eventMode) {
  1377. var e = document.createEvent('Event');
  1378. e.initEvent('protoOverride', false, false);
  1379. window.protectedElems = protectedElems;
  1380. window.dispatchEvent(e);
  1381. } else {
  1382. return protectedElems;
  1383. }
  1384. }
  1385. if (isFirefox) {
  1386. var s = document.createElement('script');
  1387. s.textContent = '(' + styleProtector.toString() + ')(true);';
  1388. window.addEventListener('protoOverride', function protoOverrideCallback(e){
  1389. if (win.protectedElems) {
  1390. protectedElems = win.protectedElems;
  1391. delete win.protectedElems;
  1392. }
  1393. document.removeEventListener('protoOverride', protoOverrideCallback, true);
  1394. }, true);
  1395. _appendChild(s);
  1396. _removeChild(s);
  1397. } else {
  1398. protectedElems = styleProtector(false);
  1399. }
  1400.  
  1401. // clean a page
  1402. window.addEventListener('DOMContentLoaded', function(){
  1403. var rem, si, itm;
  1404. function width(){ return window.innerWidth||_de.clientWidth||document.body.clientWidth||0; }
  1405. function height(){ return window.innerHeight||_de.clientHeight||document.body.clientHeight||0; }
  1406.  
  1407.  
  1408. if (isForum) {
  1409. si = document.querySelector('#logostrip');
  1410. if (si) {
  1411. remove(si.parentNode.nextSibling);
  1412. }
  1413. }
  1414.  
  1415. if (document.location.href.search('/forum/dl/') !== -1) {
  1416. document.body.setAttribute('style', (document.body.getAttribute('style')||'')+
  1417. ';background-color:black!important');
  1418. for (itm of document.querySelectorAll('body>div')) {
  1419. if (!itm.querySelector('.dw-fdwlink')) {
  1420. remove(itm);
  1421. }
  1422. }
  1423. }
  1424.  
  1425. if (isForum) { // Do not continue if it's a forum
  1426. return;
  1427. }
  1428.  
  1429. si = document.querySelector('#header');
  1430. if (si) {
  1431. rem = si.previousSibling;
  1432. while (rem) {
  1433. si = rem.previousSibling;
  1434. remove(rem);
  1435. rem = si;
  1436. }
  1437. }
  1438.  
  1439. for (itm of document.querySelectorAll('#nav li[class]')) {
  1440. if (itm && itm.querySelector('a[href^="/tag/"]')) {
  1441. remove(itm);
  1442. }
  1443. }
  1444.  
  1445. var style, result, fakeStyle,
  1446. fakeStyles = new WeakMap(),
  1447. styleProxy = {
  1448. get: function(target, prop) {
  1449. fakeStyle = fakeStyles.get(target);
  1450. if (fakeStyle.hasOwnProperty(prop)) {
  1451. return fakeStyle[prop];
  1452. } else {
  1453. return target[prop];
  1454. }
  1455. },
  1456. set: function(target, prop, value) {
  1457. fakeStyle = fakeStyles.get(target);
  1458. if (fakeStyle.hasOwnProperty(prop)) {
  1459. fakeStyle[prop] = value;
  1460. } else {
  1461. target[prop] = value;
  1462. }
  1463. return value;
  1464. }
  1465. };
  1466. for (itm of document.querySelectorAll('DIV, A')) {
  1467. if (itm.tagName ==='DIV' && itm.offsetWidth > 0.95 * width() && itm.offsetHeight > 0.85 * height()) {
  1468. style = window.getComputedStyle(itm, null);
  1469. result = [];
  1470. if (style.backgroundImage !== 'none') {
  1471. result.push('background-image:none!important');
  1472. }
  1473. if (style.backgroundColor !== 'transparent' &&
  1474. style.backgroundColor !== 'rgba(0, 0, 0, 0)') {
  1475. result.push('background-color:transparent!important');
  1476. }
  1477. if (result.length) {
  1478. if (itm.getAttribute('style')) {
  1479. result.unshift(itm.getAttribute('style'));
  1480. }
  1481. fakeStyles.set(itm.style, {
  1482. 'backgroundImage': itm.style.backgroundImage,
  1483. 'backgroundColor': itm.style.backgroundColor
  1484. });
  1485. try {
  1486. Object.defineProperty(itm, 'style', {
  1487. value: new Proxy(itm.style, styleProxy),
  1488. enumerable: true
  1489. });
  1490. } catch (e) {
  1491. console.log('Unable to protect style property.', e);
  1492. }
  1493. if (protectedElems) {
  1494. protectedElems.set(itm, _getAttribute.call(itm, 'style'));
  1495. }
  1496. _setAttribute.call(itm, 'style', result.join(';'));
  1497. }
  1498. }
  1499. if (itm.tagName ==='A' && (itm.offsetWidth > 0.95 * width() || itm.offsetHeight > 0.85 * height())) {
  1500. if (protectedElems) {
  1501. protectedElems.set(itm, _getAttribute.call(itm, 'style'));
  1502. }
  1503. _setAttribute.call(itm, 'style', 'display:none!important');
  1504. }
  1505. }
  1506.  
  1507. for (itm of document.querySelectorAll('ASIDE>DIV')) {
  1508. if ( ((itm.querySelector('script, iframe, a[href*="/ad/www/"]') ||
  1509. itm.querySelector('img[src$=".gif"]:not([height="0"]), img[height="400"]')) &&
  1510. !itm.classList.contains('post') ) || !itm.childNodes.length ) {
  1511. remove(itm);
  1512. }
  1513. }
  1514.  
  1515. document.body.setAttribute('style', (document.body.getAttribute('style')||'')+';background-color:#E6E7E9!important');
  1516.  
  1517. // display content of the page
  1518. afterClean();
  1519. });
  1520. }
  1521. };
  1522.  
  1523. scripts['allmovie.pro'] = function() {
  1524. // pretend to be Android to make site use different played for ads
  1525. if (isSafari) {
  1526. return;
  1527. }
  1528. Object.defineProperty(navigator, 'userAgent', {
  1529. 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'; },
  1530. enumerable: true
  1531. });
  1532. };
  1533. scripts['rufilmtv.org'] = scripts['allmovie.pro'];
  1534.  
  1535. scripts['anidub-online.ru'] = function() {
  1536. var script = document.createElement('script');
  1537. script.type = "text/javascript";
  1538. script.innerHTML = "function ogonekstart1() {}";
  1539. document.getElementsByTagName('head')[0].appendChild(script);
  1540.  
  1541. var style = document.createElement('style');
  1542. style.type = 'text/css';
  1543. style.appendChild(document.createTextNode('.background {background: none!important;}'));
  1544. style.appendChild(document.createTextNode('.background > script + div, .background > script ~ div:not([id]):not([class]) + div[id][class] {display:none!important}'));
  1545. document.head.appendChild(style);
  1546. };
  1547. scripts['online.anidub.com'] = scripts['anidub-online.ru'];
  1548.  
  1549. scripts['fs.to'] = function() {
  1550. function skipClicker(i) {
  1551. if (!i) {
  1552. return;
  1553. }
  1554. var skip = document.querySelector('.b-aplayer-banners__close');
  1555. if (skip) {
  1556. skip.click();
  1557. } else {
  1558. setTimeout(skipClicker, 100, i-1);
  1559. }
  1560. }
  1561. setTimeout(skipClicker, 100, 30);
  1562.  
  1563. createStyle([
  1564. '.l-body-branding *,'+
  1565. '.b-styled__item-central,'+
  1566. '.b-styled__content-right,'+
  1567. '.b-styled__section-central,'+
  1568. 'div[id^="adsProxy-"]'+
  1569. '{display:none!important}',
  1570. 'body {background-image:url(data:image/png;base64,'+
  1571. 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAACX'+
  1572. 'BIWXMAAC4jAAAuIwF4pT92AAAADUlEQVR42mOQUdL5DwACMgFq'+
  1573. 'BC3ttwAAAABJRU5ErkJggg==)!important}'
  1574. ]);
  1575.  
  1576. if (/\/(view_iframe|iframeplayer)\//i.test(document.location.pathname)) {
  1577. var p = document.querySelector('#player:not([preload="auto"])'),
  1578. m = document.querySelector('.main'),
  1579. adStepper = function(p) {
  1580. if (p.currentTime < p.duration) {
  1581. p.currentTime += 1;
  1582. }
  1583. },
  1584. adSkipper = function(f, p) {
  1585. f.click();
  1586. p.waitAfterSkip = false;
  1587. p.longerSkipper = false;
  1588. console.log('Пропустили.');
  1589. },
  1590. cl = function(p) {
  1591. var faster = document.querySelector('.b-aplayer__html5-desktop-skip'),
  1592. series = document.querySelector('.b-aplayer__actions-series');
  1593.  
  1594. function clickSelected() {
  1595. var s = document.querySelector('.b-aplayer__popup-series-episodes .selected a');
  1596. if (s) {
  1597. s.click();
  1598. }
  1599. }
  1600.  
  1601. if ((!faster || faster.style.display !== 'block') && series && !p.seriesClicked) {
  1602. series.click();
  1603. p.seriesClicked = true;
  1604. p.longerSkipper = true;
  1605. setTimeout(clickSelected, 1000);
  1606. p.pause();
  1607. }
  1608.  
  1609. function skipListener() {
  1610. if (p.waitAfterSkip) {
  1611. console.log('В процессе пропуска…');
  1612. return;
  1613. }
  1614. p.pause();
  1615. if (!p.classList.contains('m-hidden')) {
  1616. p.classList.add('m-hidden');
  1617. }
  1618. if (faster && p.currentTime &&
  1619. win.getComputedStyle(faster).display === 'block' &&
  1620. !faster.querySelector('.b-aplayer__html5-desktop-skip-timer')) {
  1621. p.waitAfterSkip = true;
  1622. setTimeout(adSkipper, (p.longerSkipper?3:1)*1000, faster, p);
  1623. console.log('Доступен быстрый пропуск…');
  1624. } else {
  1625. setTimeout(adStepper, 1000, p);
  1626. }
  1627. }
  1628.  
  1629. p.addEventListener('timeupdate', skipListener, false);
  1630. };
  1631. if (p.nodeName === 'VIDEO') {
  1632. cl(p);
  1633. } else {
  1634. (new MutationObserver(function (ms) {
  1635. var m, node;
  1636. for (m of ms) {
  1637. for (node of m.addedNodes) {
  1638. if (node.id === 'player' &&
  1639. node.nodeName === 'VIDEO' &&
  1640. _getAttribute.call(node, 'preload') !== 'auto') {
  1641. cl(node);
  1642. }
  1643. }
  1644. }
  1645. })).observe(m, {childList: true});
  1646. }
  1647. }
  1648. };
  1649. scripts['brb.to'] = scripts['fs.to'];
  1650. scripts['cxz.to'] = scripts['fs.to'];
  1651.  
  1652. scripts['drive2.ru'] = function() {
  1653. gardener('.c-block:not([data-metrika="recomm"]),.o-grid__item', />Реклама<\//i);
  1654. };
  1655.  
  1656. scripts['fishki.net'] = function() {
  1657. gardener('.drag_list > .drag_element, .list-view > .paddingtop15, .post-wrap', /543769|Новости\sпартнеров/);
  1658. };
  1659.  
  1660. scripts['gidonline.club'] = {
  1661. 'now': function() {
  1662. createStyle('.tray > div[style] {display: none!important}');
  1663. }
  1664. };
  1665. scripts['gidonlinekino.com'] = scripts['gidonline.club'];
  1666.  
  1667. scripts['hdgo.cc'] = {
  1668. 'now': function(){
  1669. (new MutationObserver(function(ms) {
  1670. var m, node;
  1671. for (m of ms) {
  1672. for (node of m.addedNodes) {
  1673. if (node.tagName === 'SCRIPT' && _getAttribute(node, 'onerror') !== null) {
  1674. node.removeAttribute('onerror');
  1675. }
  1676. }
  1677. }
  1678. })).observe(document, {childList:true, subtree: true});
  1679. }
  1680. };
  1681. scripts['couber.be'] = scripts['hdgo.cc'];
  1682. scripts['46.30.43.38'] = scripts['hdgo.cc'];
  1683.  
  1684. scripts['gismeteo.ru'] = {
  1685. 'DOMContentLoaded': function() {
  1686. gardener('div > a[target^="_"]', /Яндекс\.Директ/i, { root: 'body', observe: true, parent: 'div[class*="frame"]' });
  1687. }
  1688. };
  1689.  
  1690. scripts['hdrezka.me'] = {
  1691. 'now': function() {
  1692. Object.defineProperty(win, 'fuckAdBlock', {
  1693. value: {
  1694. onDetected: function() {
  1695. console.log('Pretending to be an ABP detector.');
  1696. }
  1697. }
  1698. });
  1699. Object.defineProperty(win, 'ab', {
  1700. value: false,
  1701. enumerable: true
  1702. });
  1703. },
  1704. 'DOMContentLoaded': function() {
  1705. gardener('div[id][onclick][onmouseup][onmousedown]', /onmouseout/i);
  1706. }
  1707. };
  1708.  
  1709. scripts['imageban.ru'] = {
  1710. 'now': preventBackgroundRedirect,
  1711. 'DOMContentLoaded': function() {
  1712. win.addEventListener('unload', function() {
  1713. if (!window.location.hash) {
  1714. window.location.replace(window.location+'#');
  1715. } else {
  1716. window.location.hash = '';
  1717. }
  1718. }, true);
  1719. }
  1720. };
  1721.  
  1722. scripts['e.mail.ru'] = function() {
  1723. /*gardener('#LEGO :not([data-mnemo])>.js-href[data-id]',
  1724. /data:image.*>Реклама<|>Реклама<.*\/\/favicon\./i,
  1725. {root:'#LEGO', observe: true, parent:'div[id][class]'});*/
  1726. };
  1727.  
  1728. scripts['mail.ru'] = {
  1729. 'now': function() {
  1730. // Trick to prevent mail.ru from removing 3rd-party styles
  1731. scriptLander(function(){
  1732. Object.defineProperty(Object.prototype, 'restoreVisibility', {
  1733. get: function() { return function(){}; },
  1734. set: function() {}
  1735. });
  1736. });
  1737. }
  1738. };
  1739.  
  1740. scripts['megogo.net'] = {
  1741. 'now': function() {
  1742. Object.defineProperty(win, "adBlock", {
  1743. value : false,
  1744. enumerable : true
  1745. });
  1746. Object.defineProperty(win, "showAdBlockMessage", {
  1747. value : function () {},
  1748. enumerable : true
  1749. });
  1750. }
  1751. };
  1752.  
  1753. scripts['naruto-base.su'] = function() {
  1754. gardener('div[id^="entryID"],.block', /href="http.*?target="_blank"/i);
  1755. };
  1756.  
  1757. scripts['overclockers.ru'] = {
  1758. 'now': function() {
  1759. createStyle('.fixoldhtml {display:block!important}');
  1760. if (!isChrome && !isOpera) {
  1761. return; // Looks like my code works only in Chrome-like browsers
  1762. }
  1763. var noContentYet = true;
  1764. function jWrap() {
  1765. var _$ = win.$, _e = _$.extend;
  1766. win.$ = function() {
  1767. var _ret = _$.apply(window, arguments);
  1768. if (_ret[0] === document.body) {
  1769. _ret.html = function() {
  1770. console.log('Anti-adblock prevented.');
  1771. };
  1772. }
  1773. return _ret;
  1774. };
  1775. win.$.extend = function() {
  1776. return _e.apply(_$, arguments);
  1777. };
  1778. win.jQuery = win.$;
  1779. }
  1780. (function jReady() {
  1781. if (!win.$ && noContentYet) {
  1782. setTimeout(jReady, 0);
  1783. } else {
  1784. jWrap();
  1785. }
  1786. })();
  1787. document.addEventListener ('DOMContentLoaded', function(){
  1788. noContentYet = false;
  1789. }, false);
  1790. }
  1791. };
  1792. scripts['forums.overclockers.ru'] = {
  1793. 'now': function() {
  1794. createStyle('.needblock {position: fixed; left: -10000px}');
  1795. Object.defineProperty(win, 'adblck', {
  1796. value: 'no',
  1797. enumerable: true
  1798. });
  1799. }
  1800. };
  1801.  
  1802. scripts['pb.wtf'] = function() {
  1803. createStyle('.reques,#result,tbody.row1:not([id]) {display: none !important}');
  1804. // image in the slider in the header
  1805. gardener('a[href^="/ex"],a[href$="=="]', /img/i, {root:'.release-navbar', observe:true, parent:'div'});
  1806. // ads in blocks on the page
  1807. gardener('a[href^="/topic/234257"]', /Как\sразместить/i, {siblings:-1, root:'#main_content', observe:true, parent:'span[style]'});
  1808. // line above topic content
  1809. gardener('.re_top1', /./, {root:'#main_content', parent:'.hidden-sm'});
  1810. };
  1811. scripts['piratbit.org'] = scripts['pb.wtf'];
  1812. scripts['piratbit.ru'] = scripts['pb.wtf'];
  1813.  
  1814. scripts['pikabu.ru'] = function() {
  1815. gardener('.story', /story__sponsor|story__gag|profile\/ads"/i, {root: '.inner_wrap', observe: true});
  1816. };
  1817.  
  1818. scripts['rp5.ru'] = function() {
  1819. createStyle('#bannerBottom {display: none!important}');
  1820. var co = document.querySelector('#content'), i, nodes;
  1821. if (!co) {
  1822. return;
  1823. }
  1824. nodes = co.parentNode.childNodes;
  1825. i = nodes.length;
  1826. while (i--) {
  1827. if (nodes[i] !== co) {
  1828. nodes[i].parentNode.removeChild(nodes[i]);
  1829. }
  1830. }
  1831. };
  1832. scripts['rp5.by'] = scripts['rp5.ru'];
  1833. scripts['rp5.ua'] = scripts['rp5.ru'];
  1834.  
  1835. scripts['rustorka.com'] = {
  1836. 'now': function() {
  1837. createStyle('.header > div:not(.head-block) a, #sidebar1 img, #logo img {opacity:0!important}', {
  1838. id: 'tempHidingStyles'
  1839. }, true);
  1840. preventPopups();
  1841. },
  1842. 'DOMContentLoaded': function() {
  1843. for (var o of document.querySelectorAll('IMG, A')) {
  1844. if ((o.clientWidth === 728 && o.clientHeight === 90) ||
  1845. (o.clientWidth === 300 && o.clientHeight === 250)) {
  1846. while (o && o.tagName !== 'A') {
  1847. o = o.parentNode;
  1848. }
  1849. if (o) {
  1850. _setAttribute.call(o, 'style', 'display: none !important');
  1851. }
  1852. }
  1853. }
  1854. var s = document.querySelector('#tempHidingStyles');
  1855. s.parentNode.removeChild(s);
  1856. }
  1857. };
  1858. scripts['rumedia.ws'] = scripts['rustorka.com'];
  1859.  
  1860. scripts['sport-express.ru'] = function() {
  1861. gardener('.js-relap__item',/>Реклама\s+<\//, {root:'.container', observe: true});
  1862. };
  1863.  
  1864. scripts['sports.ru'] = function() {
  1865. gardener('.aside-news-list__item', /aside-news-list__advert/i, {root:'.columns-layout__left', observe: true});
  1866. gardener('.material-list__item', /Реклама/i, {root:'.columns-layout', observe: true});
  1867. // extra functionality: shows/hides panel at the top depending on scroll direction
  1868. createStyle([
  1869. '.user-panel__fixed { transition: top 0.2s ease-in-out!important; }',
  1870. '.user-panel-up { top: -40px!important }'
  1871. ], {id: 'userPanelSlide'}, false);
  1872. (function lookForPanel() {
  1873. var panel = document.querySelector('.user-panel__fixed');
  1874. if (!panel) {
  1875. setTimeout(lookForPanel, 100);
  1876. } else {
  1877. window.addEventListener('wheel', function(e){
  1878. if (e.deltaY > 0 && !panel.classList.contains('user-panel-up')) {
  1879. panel.classList.add('user-panel-up');
  1880. } else
  1881. if (e.deltaY < 0 && panel.classList.contains('user-panel-up')) {
  1882. panel.classList.remove('user-panel-up');
  1883. }
  1884. }, false);
  1885. }
  1886. })();
  1887. };
  1888.  
  1889. scripts['www.ukr.net'] = scripts['sinoptik.com.ru'];
  1890.  
  1891. scripts['vk.com'] = function() {
  1892. gardener('div[data-post-id]', /wall_marked_as_ads/, {root: '#page_wall_posts', observe: true});
  1893. };
  1894.  
  1895. scripts['yap.ru'] = function() {
  1896. gardener('form > table[id^="p_row_"]:nth-of-type(2)', /member1438|Administration/);
  1897. gardener('.icon-comments', /\/go\/\?http/, {parent:'tr', siblings:-2});
  1898. };
  1899. scripts['yaplakal.com'] = scripts['yap.ru'];
  1900.  
  1901. scripts['rambler.ru'] = {
  1902. 'now': function() {
  1903. scriptLander(function() {
  1904. var _createElement = Document.prototype.createElement,
  1905. loadMap = new WeakMap();
  1906. Document.prototype.createElement = function createElement(name) {
  1907. /*jshint validthis:true */
  1908. var el = _createElement.apply(this, arguments);
  1909. if (el.tagName === 'LINK') {
  1910. Object.defineProperty(el, 'onload', {
  1911. get: function() {
  1912. return loadMap.get(loadMap.get(this));
  1913. },
  1914. set: function(func) {
  1915. var wrap = loadMap.get(this),
  1916. isContent = /\{\s*content\s*:\s*"[^"]+"/i;
  1917. if (wrap) {
  1918. this.removeEventListener('load', wrap, false);
  1919. loadMap.remove(wrap);
  1920. loadMap.remove(this);
  1921. }
  1922. wrap = function(e) {
  1923. if (e.target && e.target.sheet && e.target.sheet.cssRules &&
  1924. e.target.sheet.cssRules[0] && e.target.sheet.cssRules[0].cssText &&
  1925. isContent.test(e.target.sheet.cssRules[0].cssText)) {
  1926. console.log('Blocked "onload" for', e.target.href);
  1927. return false;
  1928. }
  1929. return func.apply(this, arguments);
  1930. };
  1931. loadMap.set(this, wrap);
  1932. loadMap.set(wrap, func);
  1933. this.addEventListener('load', wrap, false);
  1934. },
  1935. enumberable: true
  1936. });
  1937. }
  1938. return el;
  1939. };
  1940. });
  1941. }
  1942. };
  1943.  
  1944. scripts['reactor.cc'] = {
  1945. 'now': function() {
  1946. win.open = (function(){ throw new Error('Redirect prevention.'); }).bind(window);
  1947. },
  1948. 'click': function(e) {
  1949. var node = e.target;
  1950. if (node.nodeType === Node.ELEMENT_NODE &&
  1951. node.style.position === 'absolute' &&
  1952. node.style.zIndex > 0)
  1953. node.parentNode.removeChild(node);
  1954. },
  1955. 'DOMContentLoaded': function() {
  1956. var words = new RegExp(
  1957. 'блокировщика рекламы'
  1958. .split('')
  1959. .map(function(e){return e+'[\u200b\u200c\u200d]*';})
  1960. .join('')
  1961. .replace(' ', '\\s*')
  1962. .replace(/[аоре]/g, function(e){return ['[аa]','[оo]','[рp]','[еe]']['аоре'.indexOf(e)];}),
  1963. 'i'),
  1964. can;
  1965. function deeper(spider) {
  1966. var c, l, n;
  1967. if (words.test(spider.innerText)) {
  1968. if (spider.nodeType === Node.TEXT_NODE) {
  1969. return true;
  1970. }
  1971. c = spider.childNodes;
  1972. l = c.length;
  1973. n = 0;
  1974. while(l--) {
  1975. if (deeper(c[l]), can) {
  1976. n++;
  1977. }
  1978. }
  1979. if (n > 0 && n === c.length && spider.offsetHeight < 750) {
  1980. can.push(spider);
  1981. }
  1982. return false;
  1983. }
  1984. return true;
  1985. }
  1986. function probe(){
  1987. if (words.test(document.body.innerText)) {
  1988. can = [];
  1989. deeper(document.body);
  1990. var i = can.length, spider;
  1991. while(i--) {
  1992. spider = can[i];
  1993. if (spider.offsetHeight > 10 && spider.offsetHeight < 750) {
  1994. _setAttribute.call(spider, 'style', 'background:none!important');
  1995. }
  1996. }
  1997. }
  1998. }
  1999. (new MutationObserver(probe)).observe(document,{childList:true, subtree:true});
  2000. }
  2001. };
  2002. scripts['joyreactor.cc'] = scripts['reactor.cc'];
  2003. scripts['pornreactor.cc'] = scripts['reactor.cc'];
  2004.  
  2005. scripts['auto.ru'] = function() {
  2006. var words = /Реклама|Яндекс.Директ|yandex_ad_/;
  2007. var userAdsListAds = [
  2008. '.listing-list > .listing-item',
  2009. '.listing-item_type_fixed.listing-item'
  2010. ];
  2011. var catalogAds = [
  2012. 'div[class*="layout_catalog-inline"]',
  2013. 'div[class$="layout_horizontal"]'
  2014. ];
  2015. var otherAds = [
  2016. '.advt_auto',
  2017. '.sidebar-block',
  2018. '.pager-listing + div[class]',
  2019. '.card > div[class][style]',
  2020. '.sidebar > div[class]',
  2021. '.main-page__section + div[class]',
  2022. '.listing > tbody'];
  2023. gardener(userAdsListAds.join(','), words, {root:'.listing-wrap', observe:true});
  2024. gardener(catalogAds.join(','), words, {root:'.catalog__page,.content__wrapper', observe:true});
  2025. gardener(otherAds.join(','), words);
  2026. };
  2027.  
  2028. scripts['rsload.net'] = {
  2029. 'load': function() {
  2030. var dis = document.querySelector('label[class*="cb-disable"]');
  2031. if (dis) {
  2032. dis.click();
  2033. }
  2034. },
  2035. 'click': function(e) {
  2036. var t = e.target;
  2037. if (t && t.href && (/:\/\/\d+\.\d+\.\d+\.\d+\//.test(t.href))) {
  2038. t.href = t.href.replace('://','://rsload.net:rsload.net@');
  2039. }
  2040. }
  2041. };
  2042.  
  2043. var domain = document.domain, name;
  2044. while (domain.indexOf('.') !== -1) {
  2045. if (scripts.hasOwnProperty(domain)) {
  2046. if (typeof scripts[domain] === 'function') {
  2047. document.addEventListener ('DOMContentLoaded', scripts[domain], false);
  2048. }
  2049. for (name in scripts[domain]) {
  2050. if (name !== 'now') {
  2051. (name === 'load' ? window : document)
  2052. .addEventListener (name, scripts[domain][name], false);
  2053. } else {
  2054. scripts[domain][name]();
  2055. }
  2056. }
  2057. }
  2058. domain = domain.slice(domain.indexOf('.') + 1);
  2059. }
  2060. })();

QingJ © 2025

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