RU AdList JS Fixes

try to take over the world!

目前為 2016-11-11 提交的版本,檢視 最新版本

  1. // ==UserScript==
  2. // @name RU AdList JS Fixes
  3. // @namespace ruadlist_js_fixes
  4. // @version 20161112.1
  5. // @description try to take over the world!
  6. // @author lainverse & dimisa
  7. // @match *://*/*
  8. // @grant unsafeWindow
  9. // @grant window.close
  10. // @run-at document-start
  11. // ==/UserScript==
  12.  
  13. (function() {
  14. 'use strict';
  15. var win = (unsafeWindow || window),
  16. isFirefox = /firefox/i.test(navigator.userAgent);
  17.  
  18. // NodeList iterator polyfill (mostly for Safari)
  19. // https://jakearchibald.com/2014/iterators-gonna-iterate/
  20. if (!NodeList.prototype[Symbol.iterator]) {
  21. NodeList.prototype[Symbol.iterator] = Array.prototype[Symbol.iterator];
  22. }
  23.  
  24. // Create fake shadow root and style element as a bait for those who want to break ABP functionality
  25. (function() {
  26. // skip Firefox since ABP doesn't use shadowRoot there
  27. // also, skip browsers which doesn't support createShadowRoot (Safari)
  28. if (isFirefox || !document.documentElement.createShadowRoot) {
  29. return;
  30. }
  31. function createShadowTrap() {
  32. var sr = document.documentElement.createShadowRoot();
  33. // create 'shadow' element similar to ABP
  34. sr.appendChild(document.createElement('shadow'));
  35. // create empty 'style' bait
  36. var st = document.createElement('style');
  37. sr.appendChild(st);
  38. var o = new MutationObserver(function(ms){
  39. var m, node;
  40. for (m of ms) {
  41. for (node of m.removedNodes) {
  42. if (node === st) {
  43. st = document.createElement('style');
  44. sr.appendChild(st);
  45. console.log('Site took the bait and attempted to remove it.');
  46. }
  47. }
  48. }
  49. });
  50. o.observe(sr, {childList: true});
  51. }
  52. var tooLate = false;
  53. document.addEventListener('DOMContentLoaded', function(){
  54. tooLate = true;
  55. });
  56. (function checker(){
  57. if (document.documentElement.shadowRoot === null && !tooLate) {
  58. setTimeout(checker, 1);
  59. } else {
  60. createShadowTrap();
  61. }
  62. })();
  63. })();
  64.  
  65. // Creates and return protected style (unless protection is manually disabled).
  66. // Protected style will re-add itself on removal and remaind enabled on attempt to disable it.
  67. function createStyle(rules, props, skip_protect) {
  68. var root = document.documentElement;
  69.  
  70. function _protect(style) {
  71. Object.defineProperty(style, 'sheet', {
  72. value: style.sheet,
  73. enumerable: true
  74. });
  75. Object.defineProperty(style, 'disabled', {
  76. get: function() {return true;}, //pretend to be disabled
  77. set: function() {},
  78. enumerable: true
  79. });
  80. }
  81.  
  82. function _create() {
  83. var style = root.appendChild(document.createElement('style')),
  84. prop, rule;
  85. style.type = 'text/css';
  86. for (prop in props) {
  87. if (style[prop] !== undefined) {
  88. style[prop] = props[prop];
  89. }
  90. }
  91. for (rule of rules) {
  92. try {
  93. style.sheet.insertRule(rule, 0);
  94. } catch (e) {
  95. console.error(e);
  96. }
  97. }
  98. if (!skip_protect) {
  99. _protect(style);
  100. }
  101. return style;
  102. }
  103.  
  104. var style = _create();
  105. if (skip_protect) {
  106. return style;
  107. }
  108.  
  109. var o = new MutationObserver(function(ms){
  110. var m, node, rule;
  111. for (m of ms) {
  112. for (node of m.removedNodes) {
  113. if (node === style) {
  114. (new Promise(function(resolve){
  115. setTimeout(function(resolve){
  116. resolve(_create());
  117. }, 0, resolve);
  118. })).then(function(st){
  119. style = st;
  120. });
  121. }
  122. }
  123. }
  124. });
  125. o.observe(root, {childList:true});
  126.  
  127. return style;
  128. }
  129.  
  130. // https://greasyfork.org/scripts/19144-websuckit/
  131. (function() {
  132. // check does browser support Proxy and WebSocket
  133. if (typeof Proxy !== 'function' ||
  134. typeof WebSocket !== 'function') {
  135. return;
  136. }
  137.  
  138. function getWrappedCode(removeSelf) {
  139. var text = getWrappedCode.toString()+WSI.toString();
  140. text = (
  141. '(function(){"use strict";'+
  142. text.replace(/\/\/[^\r\n]*/g,'').replace(/[\s\r\n]+/g,' ')+
  143. '(new WSI(self||window)).init();'+
  144. '})();\n'+
  145. (removeSelf?'var s = document.currentScript; if (s) {s.parentNode.removeChild(s);}':'')
  146. );
  147. return text;
  148. }
  149.  
  150. function WSI(win, safeWin) {
  151. safeWin = safeWin || win;
  152. var masks = [], filter;
  153. for (filter of [// blacklist
  154. '||10root25.website^', '||24video.xxx^',
  155. '||adlabs.ru^', '||adspayformymortgage.win^', '||aviabay.ru^',
  156. '||bgrndi.com^', '||brokeloy.com^',
  157. '||cnamerutor.ru^',
  158. '||docfilms.info^', '||dreadfula.ru^',
  159. '||et-code.ru^',
  160. '||film-doma.ru^',
  161. '||free-torrent.org^', '||free-torrent.pw^',
  162. '||free-torrents.org^', '||free-torrents.pw^',
  163. '||game-torrent.info^', '||gocdn.ru^',
  164. '||hdkinoshka.com^', '||hghit.com^', '||hindcine.net^',
  165. '||kiev.ua^', '||kinotochka.net^',
  166. '||kinott.com^', '||kinott.ru^', '||kuveres.com^',
  167. '||lepubs.com^', '||luxadv.com^', '||luxup.ru^', '||luxupcdna.com^',
  168. '||mail.ru^', '||marketgid.com^', '||mxtads.com^',
  169. '||nickhel.com^',
  170. '||oconner.biz^',
  171. '||pkpojhc.com^',
  172. '||psma01.com^', '||psma02.com^', '||psma03.com^',
  173. '||recreativ.ru^', '||regpole.com^', '||ruttwind.com^',
  174. '||skidl.ru^',
  175. '||torvind.com^', '||trafmag.com^',
  176. '||webadvert-gid.ru^', '||webadvertgid.ru^',
  177. '||xxuhter.ru^',
  178. '||yuiout.online^',
  179. '||zoom-film.ru^'
  180. ]) {
  181. masks.push(new RegExp(
  182. filter.replace(/([\\\/\[\].*+?(){}$])/g, '\\$1')
  183. .replace(/\^(?!$)/g,'\\.?[^\\w%._-]')
  184. .replace(/\^$/,'\\.?([^\\w%._-]|$)')
  185. .replace(/^\|\|/,'^wss?:\\/+([^\/.]+\\.)*'),
  186. 'i'));
  187. }
  188.  
  189. function isBlocked(url) {
  190. for (var mask of masks) {
  191. if (mask.test(url)) {
  192. return true;
  193. }
  194. }
  195. return false;
  196. }
  197.  
  198. var realWebSocket = win.WebSocket;
  199. function wsGetter (target, name) {
  200. try {
  201. if (typeof realWebSocket.prototype[name] === 'function') {
  202. if (name === 'close' || name === 'send') { // send also closes connection
  203. target.readyState = realWebSocket.CLOSED;
  204. }
  205. return (
  206. function fake() {
  207. console.log('[WSI] Invoked function "'+name+'"', '| Tracing', (new Error()));
  208. return;
  209. }
  210. );
  211. }
  212. if (typeof realWebSocket.prototype[name] === 'number') {
  213. return realWebSocket[name];
  214. }
  215. } catch(ignore) {}
  216. return target[name];
  217. }
  218.  
  219. function createWebSocketWrapper(target) {
  220. return new Proxy(realWebSocket, {
  221. construct: function (target, args) {
  222. var url = args[0];
  223. console.log('[WSI] Opening socket on ' + url + ' \u2026');
  224. if (isBlocked(url)) {
  225. console.log("[WSI] Blocked.");
  226. return new Proxy({
  227. url: url,
  228. readyState: realWebSocket.OPEN
  229. }, {
  230. get: wsGetter
  231. });
  232. }
  233. return new target(args[0], args[1]);
  234. }
  235. });
  236. }
  237.  
  238. function WorkerWrapper() {
  239. var realWorker = win.Worker;
  240. function wrappedWorker(resourceURI) {
  241. var isBlobURL = /^blob:/i,
  242. xhr = null,
  243. _callbacks = new WeakMap(),
  244. _worker = null,
  245. _terminate = false,
  246. _onerror = null,
  247. _onmessage = null,
  248. _messages = [],
  249. _events = [],
  250. /*jshint validthis:true */
  251. _self = this;
  252.  
  253. function callbackWrapper(func) {
  254. if (typeof func !== 'function') {
  255. return undefined;
  256. }
  257. return (
  258. function callback() {
  259. func.apply(_self, arguments);
  260. }
  261. );
  262. }
  263.  
  264. _self.terminate = function(){
  265. _terminate = true;
  266. if (_worker) {
  267. _worker.terminate();
  268. }
  269. };
  270. Object.defineProperty(_self, 'onmessage', {
  271. get: function() {
  272. return _onmessage;
  273. },
  274. set: function(val) {
  275. _onmessage = val;
  276. if (_worker) {
  277. _worker.onmessage = callbackWrapper(val);
  278. }
  279. }
  280. });
  281. Object.defineProperty(_self, 'onerror', {
  282. get: function() {
  283. return _onerror;
  284. },
  285. set: function(val) {
  286. _onerror = val;
  287. if (_worker) {
  288. _worker.onerror = callbackWrapper(val);
  289. }
  290. }
  291. });
  292. _self.postMessage = function(message){
  293. if (_worker) {
  294. _worker.postMessage(message);
  295. } else {
  296. _messages.push(message);
  297. }
  298. };
  299. _self.terminate = function() {
  300. _terminate = true;
  301. if (_worker) {
  302. _worker.terminate();
  303. }
  304. };
  305. _self.addEventListener = function(){
  306. if (typeof arguments[1] !== 'function') {
  307. return;
  308. }
  309. if (!_callbacks.has(arguments[1])) {
  310. _callbacks.set(arguments[1], callbackWrapper(arguments[1]));
  311. }
  312. arguments[1] = _callbacks.get(arguments[1]);
  313. if (_worker) {
  314. _worker.addEventListener.apply(_worker, arguments);
  315. } else {
  316. _events.push(['addEventListener', arguments]);
  317. }
  318. };
  319. _self.removeEventListener = function(){
  320. if (typeof arguments[1] !== 'function' || !_callbacks.has(arguments[1])) {
  321. return;
  322. }
  323. arguments[1] = _callbacks.get(arguments[1]);
  324. _callbacks.delete(arguments[1]);
  325. if (_worker) {
  326. _worker.removeEventListener.apply(_worker, arguments);
  327. } else {
  328. _events.push(['removeEventListener', arguments]);
  329. }
  330. };
  331.  
  332. if (!isBlobURL.test(resourceURI)) {
  333. _worker = new realWorker(resourceURI);
  334. return; // not a blob, no need to wrap
  335. }
  336.  
  337. xhr = new XMLHttpRequest();
  338. xhr.responseType = 'blob';
  339. try {
  340. xhr.open('GET', resourceURI, true);
  341. } catch(ignore) {
  342. _worker = new realWorker(resourceURI);
  343. return; // failed to open connection, unable to continue wrapping procedure
  344. }
  345. (new Promise(function(resolve, reject){
  346. if (xhr.readyState !== XMLHttpRequest.OPENED) {
  347. // connection wasn't opened, unable to continue wrapping procedure
  348. return reject();
  349. }
  350. xhr.onload = function(){
  351. if (this.status === 200) {
  352. var reader = new FileReader();
  353. reader.addEventListener("loadend", function() {
  354. resolve(new realWorker(URL.createObjectURL(
  355. new Blob([getWrappedCode(false)+this.result])
  356. )));
  357. });
  358. reader.readAsText(this.response);
  359. }
  360. };
  361. xhr.send();
  362. })).then(function(val) {
  363. _worker = val;
  364. _worker.onerror = callbackWrapper(_onerror);
  365. _worker.onmessage = callbackWrapper(_onmessage);
  366. var _e;
  367. while(_events.length) {
  368. _e = _events.shift();
  369. _worker[_e[0]].apply(_worker, _e[1]);
  370. }
  371. while(_messages.length) {
  372. _worker.postMessage(_messages.shift());
  373. }
  374. if (_terminate) {
  375. _worker.terminate();
  376. }
  377. }).catch(function(){});
  378.  
  379. }
  380. win.Worker = wrappedWorker.bind(safeWin);
  381. }
  382.  
  383. function CreateElementWrapper() {
  384. var realCreateElement = Document.prototype.createElement,
  385. code = encodeURIComponent('<scr'+'ipt>'+getWrappedCode(true)+'</scr'+'ipt>\n'),
  386. isDataURL = /^data:/i,
  387. isBlobURL = /^blob:/i;
  388.  
  389. function frameRewrite(e) {
  390. var f = e.target,
  391. w = f.contentWindow;
  392. if (!f.src || (w && isBlobURL.test(f.src))) {
  393. w.WebSocket = createWebSocketWrapper();
  394. }
  395. if (isDataURL.test(f.src) && f.src.indexOf(code) < 0) {
  396. f.src = f.src.replace(',',',' + code);
  397. }
  398. }
  399.  
  400. function wrappedCreateElement(name) {
  401. var el = realCreateElement.apply(this, arguments);
  402. if (el.tagName === 'IFRAME') {
  403. el.addEventListener('load', frameRewrite, false);
  404. }
  405. return el;
  406. }
  407. Document.prototype.createElement = wrappedCreateElement;
  408.  
  409. document.addEventListener('DOMContentLoaded', function(){
  410. for (var ifr of document.querySelectorAll('IFRAME')) {
  411. ifr.addEventListener('load', frameRewrite, false);
  412. }
  413. }, false);
  414. }
  415.  
  416. this.init = function() {
  417. win.WebSocket = createWebSocketWrapper();
  418. WorkerWrapper();
  419. if (typeof document !== 'undefined') {
  420. CreateElementWrapper();
  421. }
  422. };
  423. }
  424.  
  425. if (isFirefox) {
  426. var script = document.createElement('script');
  427. script.appendChild(document.createTextNode(getWrappedCode()));
  428. document.head.insertBefore(script, document.head.firstChild);
  429. return; //we don't want to call functions on page from here in Fx, so exit
  430. }
  431.  
  432. (new WSI((unsafeWindow||self||window),(self||window))).init();
  433. })();
  434.  
  435. if (!isFirefox) { // scripts for non-Firefox browsers
  436.  
  437. // https://greasyfork.org/scripts/14720-it-s-not-important
  438. (function(){
  439. var imptt = /((display|(margin|padding)(-top|-bottom)?)\s*:[^;!]*)!\s*important/ig;
  440.  
  441. function unimportanter(el, si) {
  442. if (!imptt.test(si) || el.style.display === 'none') {
  443. return 0; // get out if we have nothing to do here
  444. }
  445. if (el.nodeName === 'IFRAME' && el.src &&
  446. el.src.slice(0,17) === 'chrome-extension:') {
  447. return 0; // Web of Trust uses this method to add their frame
  448. }
  449. var so = si.replace(imptt, function(){return arguments[1];}), ret = 0;
  450. if (si !== so) {
  451. ret = 1;
  452. el.setAttribute('style', so);
  453. }
  454. return ret;
  455. }
  456.  
  457. function logger(c) {
  458. if (c) {
  459. console.log('Some page elements became a bit less important.');
  460. }
  461. }
  462.  
  463. function checkTarget(node, cnt) {
  464. if (!(node && node.getAttribute)) {
  465. return 0;
  466. }
  467. var si = node.getAttribute('style');
  468. if (si && si.indexOf('!') > -1) {
  469. cnt += unimportanter(node, si);
  470. }
  471. return cnt;
  472. }
  473.  
  474. var observer = new MutationObserver(function(mutations) {
  475. setTimeout(function(ms) {
  476. var cnt = 0, m, node;
  477. for (m of ms) {
  478. cnt = checkTarget(m.target, cnt);
  479. for (node of m.addedNodes) {
  480. cnt += checkTarget(node, cnt);
  481. }
  482. }
  483. logger(cnt);
  484. }, 0, mutations);
  485. });
  486.  
  487. observer.observe(document, { childList : true, attributes : true, attributeFilter : ['style'], subtree : true });
  488.  
  489. win.addEventListener ("load", function(){
  490. var c = 0, imp;
  491. for (imp of document.querySelectorAll('[style*="!"]')) {
  492. c+= checkTarget(imp, c);
  493. }
  494. logger(c);
  495. }, false);
  496. })();
  497.  
  498. }
  499.  
  500. if (/^https?:\/\/(mail\.yandex\.|music\.yandex\.|news\.yandex\.|(www\.)?yandex\.[^\/]+\/(yand)?search[\/?])/i.test(win.location.href)) {
  501. // https://greasyfork.org/en/scripts/809-no-yandex-ads
  502. (function(){
  503. var adWords = ['Яндекс.Директ','Реклама','Ad'];
  504. function remove(node) {
  505. node.parentNode.removeChild(node);
  506. }
  507. // Generic ads removal and fixes
  508. function removeGenericAds() {
  509. var s, i;
  510. s = document.querySelector('.serp-header');
  511. if (s) {
  512. s.style.marginTop='0';
  513. }
  514. for (s of document.querySelectorAll('.serp-adv__head + .serp-item, #adbanner, .serp-adv, .b-spec-adv, div[class*="serp-adv__"]')) {
  515. remove(s);
  516. }
  517. }
  518. // Search ads
  519. function removeSearchAds() {
  520. var s, item;
  521. for (s of document.querySelectorAll('.serp-block, .serp-item, .search-item')) {
  522. item = s.querySelector('.label, .serp-item__label, .document__provider-name');
  523. if (item && adWords.indexOf(item.textContent) > -1) {
  524. remove(s);
  525. console.log('Ads removed.');
  526. }
  527. }
  528. }
  529. // News ads
  530. function removeNewsAds() {
  531. for (var s of document.querySelectorAll(
  532. '.page-content__left > *,'+
  533. '.page-content__right > *:not(.page-content__col),'+
  534. '.page-content__right > .page-content__col > *'
  535. )) {
  536. if (s.textContent.indexOf(adWords[0]) > -1 ||
  537. (s.clientHeight < 15 && s.classList.contains('rubric'))) {
  538. remove(s);
  539. console.log('Ads removed.');
  540. }
  541. }
  542. }
  543. // Music ads
  544. function removeMusicAds() {
  545. for (var s of document.querySelectorAll('.ads-block')) {
  546. remove(s);
  547. }
  548. }
  549. // Mail ads
  550. function removeMailAds() {
  551. var slice = Array.prototype.slice,
  552. nodes = slice.call(document.querySelectorAll('.ns-view-folders')),
  553. node, len, classes, cls;
  554. for (node of nodes) {
  555. if (!len || len > node.classList.length) {
  556. len = node.classList.length;
  557. }
  558. }
  559. node = nodes.pop();
  560. while (node) {
  561. if (node.classList.length > len) {
  562. for (cls of slice.call(node.classList)) {
  563. if (cls.indexOf('-') === -1) {
  564. remove(node);
  565. break;
  566. }
  567. }
  568. }
  569. node = nodes.pop();
  570. }
  571. }
  572. // News fixes
  573. function removePageAdsClass() {
  574. if (document.body.classList.contains("b-page_ads_yes")){
  575. document.body.classList.remove("b-page_ads_yes");
  576. console.log('Page ads class removed.');
  577. }
  578. }
  579. // Function to attach an observer to monitor dynamic changes on the page
  580. function pageUpdateObserver(func, obj, params) {
  581. if (obj) {
  582. var o = new MutationObserver(func);
  583. o.observe(obj,(params || {childList:true, subtree:true}));
  584. }
  585. }
  586. // Cleaner
  587. document.addEventListener ('DOMContentLoaded', function() {
  588. removeGenericAds();
  589. if (win.location.hostname.search(/^mail\./i) === 0) {
  590. pageUpdateObserver(function(ms, o){
  591. var aside = document.querySelector('.mail-Layout-Aside');
  592. if (aside) {
  593. o.disconnect();
  594. pageUpdateObserver(removeMailAds, aside);
  595. }
  596. }, document.querySelector('BODY'));
  597. removeMailAds();
  598. } else if (win.location.hostname.search(/^music\./i) === 0) {
  599. pageUpdateObserver(removeMusicAds, document.querySelector('.sidebar'));
  600. removeMusicAds();
  601. } else if (win.location.hostname.search(/^news\./i) === 0) {
  602. pageUpdateObserver(removeNewsAds, document.querySelector('BODY'));
  603. pageUpdateObserver(removePageAdsClass, document.body, {attributes:true, attributesFilter:['class']});
  604. removeNewsAds();
  605. removePageAdsClass();
  606. } else {
  607. pageUpdateObserver(removeSearchAds, document.querySelector('.main__content'));
  608. removeSearchAds();
  609. }
  610. });
  611. })();
  612. return; //skip fixes for other sites
  613. }
  614.  
  615. // https://greasyfork.org/en/scripts/14470-4pda-unbrender
  616. if (/(^|\.)4pda\.ru$/i.test(window.location.hostname)) {
  617. (function() {
  618. var isForum = document.location.href.search('/forum/') !== -1,
  619. hStyle;
  620.  
  621. function remove(n) {
  622. if (n) {
  623. n.parentNode.removeChild(n);
  624. }
  625. }
  626.  
  627. function afterClean() {
  628. hStyle.disabled = true;
  629. remove(hStyle);
  630. }
  631.  
  632. function beforeClean() {
  633. // attach styles before document displayed
  634. hStyle = createStyle([
  635. 'html { overflow-y: scroll }',
  636. 'article + aside * { display: none !important }',
  637. '#header + div:after {'+(
  638. 'content: "";'+
  639. 'position: fixed;'+
  640. 'top: 0;'+
  641. 'left: 0;'+
  642. 'width: 100%;'+
  643. 'height: 100%;'+
  644. 'background-color: #E6E7E9'
  645. )+'}',
  646. // http://codepen.io/Beaugust/pen/DByiE
  647. '@keyframes spin { 100% { transform: rotate(360deg) } }',
  648. 'article + aside:after {'+(
  649. 'content: "";'+
  650. 'position: absolute;'+
  651. 'width: 150px;'+
  652. 'height: 150px;'+
  653. 'top: 150px;'+
  654. 'left: 50%;'+
  655. 'margin-top: -75px;'+
  656. 'margin-left: -75px;'+
  657. 'box-sizing: border-box;'+
  658. 'border-radius: 100%;'+
  659. 'border: 10px solid rgba(0, 0, 0, 0.2);'+
  660. 'border-top-color: rgba(0, 0, 0, 0.6);'+
  661. 'animation: spin 2s infinite linear'
  662. )+'}'
  663. ], {id:'ubrHider'}, true);
  664.  
  665. // display content of a page if time to load a page is more than 2 seconds to avoid
  666. // blocking access to a page if it is loading for too long or stuck in a loading state
  667. setTimeout(2000, afterClean);
  668. }
  669.  
  670. createStyle([
  671. '#nav .use-ad { display: block !important }',
  672. 'article:not(.post) + article:not(#id), a[target="_blank"] img[height="90"] { display: none !important }'
  673. ]);
  674.  
  675. if (!isForum) {
  676. beforeClean();
  677. }
  678.  
  679. // save links to non-overridden functions to use later
  680. var oGA = Element.prototype.getAttribute,
  681. oSA = Element.prototype.setAttribute,
  682. protectedElems;
  683. // protect/hide changed attributes in case site attempt to restore them
  684. function styleProtector(eventMode) {
  685. var oRAN = Element.prototype.removeAttributeNode,
  686. isStyleText = function(t){ return t === 'style'; },
  687. isStyleAttr = function(a){ return a instanceof Attr && a.nodeName === 'style'; },
  688. returnUndefined = function(){},
  689. protectedElems = new WeakMap();
  690. function protoOverride(element, functionName, isStyleCheck, returnIfProtected) {
  691. var oF = element.prototype[functionName];
  692. element.prototype[functionName] = function(){
  693. if (protectedElems.get(this) !== undefined && isStyleCheck(arguments[0])) {
  694. return returnIfProtected(protectedElems.get(this), arguments, this);
  695. }
  696. return oF.apply(this, arguments);
  697. };
  698. }
  699. protoOverride(Element, 'removeAttribute', isStyleText, returnUndefined);
  700. protoOverride(Element, 'removeAttributeNS', isStyleText, returnUndefined);
  701. protoOverride(Element, 'removeAttributeNode', isStyleAttr, function(o, args, node) {
  702. if (args[0] instanceof Attr && args[0].ownerElement !== node) {
  703. // throw 'attribute of another element' error
  704. oRAN.call(node, document.createAttribute('style'));
  705. }
  706. if (o.oldStyle === null) {
  707. // throw 'not an Attr' error
  708. oRAN.call(node, null);
  709. }
  710. o.oldStyle = null;
  711. return args[0];
  712. });
  713. protoOverride(Element, 'hasAttribute', isStyleText, function(o) {
  714. return o.oldStyle !== null;
  715. });
  716. protoOverride(Element, 'hasAttributeNS', isStyleText, function(o) {
  717. return o.oldStyle !== null;
  718. });
  719. protoOverride(Element, 'setAttribute', isStyleText, function(o, args) {
  720. o.oldStyle = args[1];
  721. });
  722. protoOverride(Element, 'setAttributeNS', isStyleText, returnUndefined);
  723. protoOverride(Element, 'setAttributeNode', isStyleAttr, returnUndefined);
  724. protoOverride(Element, 'getAttribute', isStyleText, function(o) {
  725. return o.oldStyle;
  726. });
  727. protoOverride(Element, 'getAttributeNS', isStyleText, returnUndefined);
  728. protoOverride(Element, 'getAttributeNode', isStyleText, function(o){
  729. if (o.oldStyle === null) {
  730. return null;
  731. }
  732. var at = document.createAttribute('style');
  733. at.value = o.oldStyle;
  734. Object.defineProperty(at, 'ownerElement', {
  735. value: this,
  736. enumerable: true
  737. });
  738. return at;
  739. });
  740. if (eventMode) {
  741. var e = document.createEvent('Event');
  742. e.initEvent('protoOverride', false, false);
  743. window.protectedElems = protectedElems;
  744. window.dispatchEvent(e);
  745. } else {
  746. return protectedElems;
  747. }
  748. }
  749. if (isFirefox) {
  750. var s = document.createElement('script');
  751. s.textContent = '(' + styleProtector.toString() + ')(true);' +
  752. 'var s = document.currentScript; if (s) {s.parentNode.removeChild(s);}';
  753. window.addEventListener('protoOverride', function protoOverrideCallback(e){
  754. if (win.protectedElems) {
  755. protectedElems = win.protectedElems;
  756. delete win.protectedElems;
  757. }
  758. document.removeEventListener('protoOverride', protoOverrideCallback, true);
  759. }, true);
  760. document.documentElement.appendChild(s);
  761. } else {
  762. protectedElems = styleProtector(false);
  763. }
  764.  
  765. // clean a page
  766. window.addEventListener('DOMContentLoaded', function(){
  767. var rem, si, itm;
  768. function width(){ return window.innerWidth||document.documentElement.clientWidth||document.body.clientWidth||0; }
  769. function height(){ return window.innerHeight||document.documentElement.clientHeight||document.body.clientHeight||0; }
  770.  
  771.  
  772. if (isForum) {
  773. si = document.querySelector('#logostrip');
  774. if (si) {
  775. remove(si.parentNode.nextSibling);
  776. }
  777. }
  778.  
  779. if (document.location.href.search('/forum/dl/') !== -1) {
  780. document.body.setAttribute('style', (document.body.getAttribute('style')||'')+
  781. ';background-color:black!important');
  782. for (itm of document.querySelectorAll('body>div')) {
  783. if (!itm.querySelector('.dw-fdwlink')) {
  784. remove(itm);
  785. }
  786. }
  787. }
  788.  
  789. if (isForum) { // Do not continue if it's a forum
  790. return;
  791. }
  792.  
  793. si = document.querySelector('#header');
  794. if (si) {
  795. rem = si.previousSibling;
  796. while (rem) {
  797. si = rem.previousSibling;
  798. remove(rem);
  799. rem = si;
  800. }
  801. }
  802.  
  803. for (itm of document.querySelectorAll('#nav li[class]')) {
  804. if (itm && itm.querySelector('a[href^="/tag/"]')) {
  805. remove(itm);
  806. }
  807. }
  808.  
  809. var style, result;
  810. for (itm of document.querySelectorAll('DIV')) {
  811. if (itm.offsetWidth > 0.95 * width() && itm.offsetHeight > 0.8 * height()) {
  812. style = window.getComputedStyle(itm, null);
  813. result = [];
  814. if (style.backgroundImage !== 'none') {
  815. result.push('background-image:none!important');
  816. }
  817. if (style.backgroundColor !== 'transparent' &&
  818. style.backgroundColor !== 'rgba(0, 0, 0, 0)') {
  819. result.push('background-color:transparent!important');
  820. }
  821. if (result.length) {
  822. if (itm.getAttribute('style')) {
  823. result.unshift(itm.getAttribute('style'));
  824. }
  825. (function(){
  826. var fakeStyle = {
  827. 'backgroundImage': itm.style.backgroundImage,
  828. 'backgroundColor': itm.style.backgroundColor
  829. };
  830. try {
  831. Object.defineProperty(itm, 'style', {
  832. value: new Proxy(itm.style, {
  833. get: function(target, prop){
  834. if (fakeStyle.hasOwnProperty(prop)) {
  835. return fakeStyle[prop];
  836. } else {
  837. return target[prop];
  838. }
  839. },
  840. set: function(target, prop, value){
  841. if (fakeStyle.hasOwnProperty(prop)) {
  842. fakeStyle[prop] = value;
  843. } else {
  844. target[prop] = value;
  845. }
  846. return value;
  847. }
  848. }),
  849. enumerable: true
  850. });
  851. } catch (e) {
  852. console.log('Unable to protect style property.', e);
  853. }
  854. })();
  855. if (protectedElems) {
  856. protectedElems.set(itm, {oldStyle: oGA.call(itm, 'style')});
  857. }
  858. oSA.call(itm, 'style', result.join(';'));
  859. }
  860. }
  861. }
  862.  
  863. for (itm of document.querySelectorAll('ASIDE>DIV')) {
  864. if ( ((itm.querySelector('script, iframe, a[href*="/ad/www/"]') ||
  865. itm.querySelector('img[src$=".gif"]:not([height="0"]), img[height="400"]')) &&
  866. !itm.classList.contains('post') ) || !itm.childNodes.length ) {
  867. remove(itm);
  868. }
  869. }
  870.  
  871. document.body.setAttribute('style', (document.body.getAttribute('style')||'')+';background-color:#E6E7E9!important');
  872.  
  873. // display content of the page
  874. afterClean();
  875. });
  876. })();
  877. return;
  878. }
  879.  
  880. // https://greasyfork.org/en/scripts/21937-moonwalk-hdgo-kodik-fix v0.7+ (adapted & fixed)
  881. document.addEventListener ('DOMContentLoaded', function() {
  882. var tmp, t;
  883. function log (e) {
  884. console.log('Moonwalk&HDGo&Kodik FIX: ' + e + ' player in ' + win.location.href);
  885. }
  886. if (win.adv_enabled !== undefined && win.condition_detected !== undefined) { // moonwalk
  887. log('Moonwalk');
  888. if (win.adv_enabled) {
  889. win.adv_enabled = false;
  890. }
  891. win.condition_detected = false;
  892. if (win.MXoverrollCallback) {
  893. document.addEventListener('click', function catcher(e){
  894. e.stopPropagation();
  895. win.MXoverrollCallback.call(window);
  896. document.removeEventListener('click', catcher, true);
  897. }, true);
  898. }
  899. } else if (win.banner_second !== undefined && win.$banner_ads !== undefined) { // hdgo
  900. log('HDGo');
  901. tmp = document.querySelector('#swtf');
  902. if (tmp) {
  903. tmp.style.display = 'none';
  904. }
  905. win.banner_second = 0;
  906. win.$banner_ads = false;
  907. if (win.$new_ads !== undefined) {
  908. win.$new_ads = false;
  909. }
  910. if (win.canRunAds !== undefined && win.canRunAds !== true) {
  911. win.canRunAds = true;
  912. }
  913. } else if (win.MXoverrollCallback && win.iframeSearch !== undefined) { // kodik
  914. log('Kodik');
  915. tmp = document.querySelector('.play_button');
  916. if (tmp) {
  917. tmp.onclick = win.MXoverrollCallback.bind(window);
  918. }
  919. win.IsAdBlock = false;
  920. }
  921. }, false);
  922.  
  923. // function to search and remove nodes by content
  924. // selector - standard CSS selector to define set of nodes to check
  925. // words - regular expression to check content of the suspicious nodes
  926. // params - object with multiple extra parameters:
  927. // .hide - set display to none instead of removing from the page
  928. // .parent - parent node to remove if content is found in the child node
  929. // .siblings - number of simling nodes to remove (excluding text nodes)
  930. function scRemove(e) {e.parentNode.removeChild(e);}
  931. function scHide(e) {
  932. var s = e.getAttribute('style')||'',
  933. h = ';display:none!important;';
  934. if (s.indexOf(h) < 0) {
  935. e.setAttribute('style', s+h);
  936. }
  937. }
  938. function scissors (selector, words, scope, params) {
  939. var remFunc = (params.hide ? scHide : scRemove),
  940. iterFunc = (params.siblings > 0 ?
  941. 'nextSibling' :
  942. 'previousSibling'),
  943. toRemove = [],
  944. siblings,
  945. node;
  946. for (node of scope.querySelectorAll(selector)) {
  947. if (words.test(node.innerHTML) || !node.childNodes.length) {
  948. // drill up to the specified parent node if required
  949. if (params.parent) {
  950. while(node !== scope && !(node.matches(params.parent))) {
  951. node = node.parentNode;
  952. }
  953. }
  954. if (node === scope) {
  955. break;
  956. }
  957. toRemove.push(node);
  958. // add multiple nodes if defined more than one sibling
  959. siblings = Math.abs(params.siblings) || 0;
  960. while (siblings) {
  961. node = node[iterFunc];
  962. toRemove.push(node);
  963. if (node.nodeType === Node.ELEMENT_NODE) {
  964. siblings -= 1; //count only element nodes
  965. }
  966. }
  967. }
  968. }
  969. for (node of toRemove) {
  970. remFunc(node);
  971. }
  972. return toRemove.length;
  973. }
  974.  
  975. // function to perform multiple checks if ads inserted with a delay
  976. // by default does 30 checks withing a 3 seconds unless nonstop mode specified
  977. // also does 1 extra check when a page completely loads
  978. // selector and words - passed dow to scissors
  979. // params - object with multiple extra parameters:
  980. // .root - selector to narrow down scope to scan;
  981. // .observe - if true then check will be performed continuously;
  982. // Other parameters passed down to scissors.
  983. function gardener(selector, words, params) {
  984. params = params || {};
  985. var scope = document.body,
  986. nonstop = false;
  987. // narrow down scope to a specific element
  988. if (params.root) {
  989. scope = scope.querySelector(params.root);
  990. if (!scope) {// exit if the root element is not present on the page
  991. return 0;
  992. }
  993. }
  994. // add observe mode if required
  995. if (params.observe) {
  996. if (typeof MutationObserver === 'function') {
  997. var o = new MutationObserver(function(ms){
  998. for (var m of ms) {
  999. if (m.addedNodes.length) {
  1000. scissors(selector, words, scope, params);
  1001. }
  1002. }
  1003. });
  1004. o.observe(scope, {childList:true, subtree: true});
  1005. } else {
  1006. nonstop = true;
  1007. }
  1008. }
  1009. // wait for a full page load to do one extra cut
  1010. win.addEventListener('load',function(){
  1011. scissors(selector, words, scope, params);
  1012. });
  1013. // do multiple cuts until ads removed
  1014. function cut(sci, s, w, sc, p, i) {
  1015. if (i > 0) {
  1016. i -= 1;
  1017. }
  1018. if (i && !sci(s, w, sc, p)) {
  1019. setTimeout(cut, 100, sci, s, w, sc, p, i);
  1020. }
  1021. }
  1022. cut(scissors, selector, words, scope, params, (nonstop ? -1 : 30));
  1023. }
  1024.  
  1025. function preventBackgroundRedirect() {
  1026. // create "cose_me" event to call high-level window.close()
  1027. var key = Math.random().toString(36).substr(2);
  1028. window.addEventListener('close_me_'+key, function(e) {
  1029. window.close();
  1030. });
  1031.  
  1032. // window.open wrapper
  1033. function pbrLander() {
  1034. var orgOpen = window.open.bind(window);
  1035. function closeWindow(){
  1036. // site went to a new tab and attempts to unload
  1037. // call for high-level close through event
  1038. var event = new CustomEvent("close_me_%key%", {});
  1039. window.dispatchEvent(event);
  1040. }
  1041. function open(){
  1042. var idx = String.prototype.indexOf;
  1043. if (arguments[0] &&
  1044. (idx.call(arguments[0], window.location.host) > -1 ||
  1045. idx.call(arguments[0], '://') === -1)) {
  1046. window.addEventListener('unload', closeWindow, true);
  1047. }
  1048. orgOpen.apply(window, arguments);
  1049. }
  1050. window.open = open.bind(window);
  1051. var s = document.currentScript;
  1052. if (s) {s.parentNode.removeChild(s);}
  1053. }
  1054.  
  1055. // land wrapper on the page
  1056. var script = document.createElement('script');
  1057. script.appendChild(document.createTextNode('('+pbrLander.toString().replace(/%key%/g,key)+')();'));
  1058. document.head.insertBefore(script,document.head.firstChild);
  1059. console.log("Background redirect prevention enabled.");
  1060. }
  1061.  
  1062. function forbidServiceWorker() {
  1063. if (!("serviceWorker" in navigator)) {
  1064. return;
  1065. }
  1066. var svr = navigator.serviceWorker.ready;
  1067. Object.defineProperty(navigator, 'serviceWorker', {
  1068. value: {
  1069. register: function(){
  1070. console.log('Registration of serviceWorker ' + arguments[0] + ' blocked.');
  1071. return new Promise(function(){});
  1072. },
  1073. ready: new Promise(function(){}),
  1074. addEventListener:function(){}
  1075. }
  1076. });
  1077. document.addEventListener('DOMContentLoaded', function() {
  1078. if (!svr) {
  1079. return;
  1080. }
  1081. svr.then(function(sw) {
  1082. console.log('Found existing serviceWorker:', sw);
  1083. console.log('Attempting to unregister...');
  1084. sw.unregister().then(function() {
  1085. console.log('Unregistered! :)');
  1086. }).catch(function(err) {
  1087. console.log('Unregistration failed. :(', err);
  1088. console.log('Try to remove it manually:');
  1089. console.log(' 1. Open: chrome://serviceworker-internals/ (Google Chrome and alike) or about:serviceworkers (Mozilla Firefox) in a new tab.');
  1090. console.log(' 2. Search there for one with "'+document.domain+'" in the name.');
  1091. console.log(' 3. Use buttons in the same block with service you found to stop it and uninstall/unregister.');
  1092. });
  1093. }).catch(function(err) {
  1094. console.log("Lol, it failed on it's own. -_-", err);
  1095. });
  1096. }, false);
  1097. }
  1098.  
  1099. var scripts = {};
  1100. scripts['anidub-online.ru'] = function() {
  1101. var script = document.createElement('script');
  1102. script.type = "text/javascript";
  1103. script.innerHTML = "function ogonekstart1() {}";
  1104. document.getElementsByTagName('head')[0].appendChild(script);
  1105.  
  1106. var style = document.createElement('style');
  1107. style.type = 'text/css';
  1108. style.appendChild(document.createTextNode('.background {background: none!important;}'));
  1109. style.appendChild(document.createTextNode('.background > script + div, .background > script ~ div:not([id]):not([class]) + div[id][class] {display:none!important}'));
  1110. document.head.appendChild(style);
  1111. };
  1112. scripts['online.anidub.com'] = scripts['anidub-online.ru'];
  1113.  
  1114. scripts['fs.to'] = function() {
  1115. function skipClicker(i) {
  1116. if (!i) {
  1117. return;
  1118. }
  1119. var skip = document.querySelector('.b-aplayer-banners__close');
  1120. if (skip) {
  1121. skip.click();
  1122. } else {
  1123. setTimeout(skipClicker, 100, i-1);
  1124. }
  1125. }
  1126. setTimeout(skipClicker, 100, 30);
  1127.  
  1128. createStyle([
  1129. '.l-body-branding *,'+
  1130. '.b-styled__item-central,'+
  1131. '.b-styled__content-right,'+
  1132. '.b-styled__section-central,'+
  1133. 'div[id^="adsProxy-"]'+
  1134. '{display:none!important}',
  1135. 'body {background-image:url(data:image/png;base64,'+
  1136. 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAACX'+
  1137. 'BIWXMAAC4jAAAuIwF4pT92AAAADUlEQVR42mOQUdL5DwACMgFq'+
  1138. 'BC3ttwAAAABJRU5ErkJggg==)!important}'
  1139. ]);
  1140.  
  1141. if (/\/(view_iframe|iframeplayer)\//i.test(document.location.pathname)) {
  1142. var p = document.querySelector('#player:not([preload="auto"])'),
  1143. m = document.querySelector('.main'),
  1144. adStepper = function(p) {
  1145. if (p.currentTime < p.duration) {
  1146. p.currentTime += 1;
  1147. }
  1148. },
  1149. adSkipper = function(f, p) {
  1150. f.click();
  1151. p.waitAfterSkip = false;
  1152. p.longerSkipper = false;
  1153. console.log('Пропустили.');
  1154. },
  1155. cl = function(p) {
  1156. var faster = document.querySelector('.b-aplayer__html5-desktop-skip'),
  1157. series = document.querySelector('.b-aplayer__actions-series');
  1158.  
  1159. function clickSelected() {
  1160. var s = document.querySelector('.b-aplayer__popup-series-episodes .selected a');
  1161. if (s) {
  1162. s.click();
  1163. }
  1164. }
  1165.  
  1166. if ((!faster || faster.style.display !== 'block') && series && !p.seriesClicked) {
  1167. series.click();
  1168. p.seriesClicked = true;
  1169. p.longerSkipper = true;
  1170. setTimeout(clickSelected, 1000);
  1171. p.pause();
  1172. }
  1173.  
  1174. function skipListener() {
  1175. if (p.waitAfterSkip) {
  1176. console.log('В процессе пропуска…');
  1177. return;
  1178. }
  1179. p.pause();
  1180. if (!p.classList.contains('m-hidden')) {
  1181. p.classList.add('m-hidden');
  1182. }
  1183. if (faster && p.currentTime &&
  1184. win.getComputedStyle(faster).display === 'block' &&
  1185. !faster.querySelector('.b-aplayer__html5-desktop-skip-timer')) {
  1186. p.waitAfterSkip = true;
  1187. setTimeout(adSkipper, (p.longerSkipper?3:1)*1000, faster, p);
  1188. console.log('Доступен быстрый пропуск…');
  1189. } else {
  1190. setTimeout(adStepper, 1000, p);
  1191. }
  1192. }
  1193.  
  1194. p.addEventListener('timeupdate', skipListener, false);
  1195. },
  1196. o = new MutationObserver(function (ms) {
  1197. var m, node;
  1198. for (m of ms) {
  1199. for (node of m.addedNodes) {
  1200. if (node.id === 'player' &&
  1201. node.nodeName === 'VIDEO' &&
  1202. node.getAttribute('preload') !== 'auto') {
  1203. cl(node);
  1204. }
  1205. }
  1206. }
  1207. });
  1208. if (p.nodeName === 'VIDEO') {
  1209. cl(p);
  1210. } else {
  1211. o.observe(m, {childList: true});
  1212. }
  1213. }
  1214. };
  1215. scripts['brb.to'] = scripts['fs.to'];
  1216. scripts['cxz.to'] = scripts['fs.to'];
  1217.  
  1218. scripts['drive2.ru'] = function() {
  1219. gardener('.c-block:not([data-metrika="recomm"]),.o-grid__item', />Реклама<\//i);
  1220. };
  1221.  
  1222. scripts['fishki.net'] = function() {
  1223. gardener('.main-post', /543769|Реклама/);
  1224. };
  1225.  
  1226. scripts['gidonline.club'] = {
  1227. 'now': function() {
  1228. createStyle('.tray > div[style] {display: none!important}');
  1229. }
  1230. };
  1231. scripts['gidonlinekino.com'] = scripts['gidonline.club'];
  1232.  
  1233. scripts['hdgo.cc'] = {
  1234. 'now': function(){
  1235. var o = new MutationObserver(function(ms) {
  1236. var m, node;
  1237. for (m of ms) {
  1238. for (node of m.addedNodes) {
  1239. if (node.tagName === 'SCRIPT' && node.getAttribute('onerror') !== null) {
  1240. node.removeAttribute('onerror');
  1241. }
  1242. }
  1243. }
  1244. });
  1245. o.observe(document, {childList:true, subtree: true});
  1246. }
  1247. };
  1248. scripts['couber.be'] = scripts['hdgo.cc'];
  1249. scripts['46.30.43.38'] = scripts['hdgo.cc'];
  1250.  
  1251. scripts['hdrezka.me'] = {
  1252. 'now': function() {
  1253. Object.defineProperty(win, 'fuckAdBlock', {
  1254. value: {
  1255. onDetected: function() {
  1256. console.log('Pretending to be an ABP detector.');
  1257. }
  1258. }
  1259. });
  1260. Object.defineProperty(win, 'ab', {
  1261. value: false,
  1262. enumerable: true
  1263. });
  1264. },
  1265. 'DOMContentLoaded': function() {
  1266. gardener('div[id][onclick][onmouseup][onmousedown]', /onmouseout/i);
  1267. }
  1268. };
  1269.  
  1270. scripts['megogo.net'] = {
  1271. 'now': function() {
  1272. Object.defineProperty(win, "adBlock", {
  1273. value : false,
  1274. enumerable : true
  1275. });
  1276. Object.defineProperty(win, "showAdBlockMessage", {
  1277. value : function () {},
  1278. enumerable : true
  1279. });
  1280. }
  1281. };
  1282.  
  1283. scripts['naruto-base.su'] = function() {
  1284. gardener('div[id^="entryID"],.block', /href="http.*?target="_blank"/i);
  1285. };
  1286.  
  1287. scripts['overclockers.ru'] = {
  1288. 'now': function() {
  1289. // Following code inspired by:
  1290. // https://greasyfork.org/en/scripts/23922-anti-adblock-killer-for-overclockers-ru
  1291. function antiAntiABP() {
  1292. var o = new MutationObserver(function(ms) {
  1293. var m, node;
  1294. for (m of ms) {
  1295. for (node of m.addedNodes) {
  1296. if (node.nodeType === Node.ELEMENT_NODE && node.onerror) {
  1297. node.onerror = null;
  1298. if (!/^https:\/\/an\.yandex\.ru\//.test(node.src)) {
  1299. console.log("Disabled 'onerror' on", node);
  1300. }
  1301. }
  1302. }
  1303. }
  1304. });
  1305. o.observe(document, {childList: true, subtree: true});
  1306. var s = document.currentScript;
  1307. s.parentNode.removeChild(s);
  1308. var log = window.console.log;
  1309. window.console.log = function() {
  1310. log.apply(this, arguments);
  1311. if (arguments[0] === 'blocked') {
  1312. throw new Error('or not, it\'s the question');
  1313. }
  1314. }
  1315. }
  1316. var s = document.createElement('script');
  1317. s.textContent = '(' + antiAntiABP.toString() + ')();';
  1318. document.documentElement.appendChild(s);
  1319. }
  1320. };
  1321. scripts['forums.overclockers.ru'] = {
  1322. 'now': function() {
  1323. createStyle(['.needblock {position: fixed; left: -10000px}']);
  1324. Object.defineProperty(win, 'adblck', {
  1325. value: 'no',
  1326. enumerable: true
  1327. });
  1328. }
  1329. };
  1330.  
  1331. scripts['pb.wtf'] = function() {
  1332. createStyle(['.reques,#result,tbody.row1:not([id]) {display: none !important}']);
  1333. // image in the slider in the header
  1334. gardener('a[href$="=="]', /img/i, {root:'.release-navbar', observe:true, parent:'div'});
  1335. // ads in blocks on the page
  1336. gardener('a[href^="/"]', /<img\s.*<br>/i, {root:'#main_content', observe:true, parent:'div[class]'});
  1337. // line above topic content
  1338. gardener('.re_top1', /./, {root:'#main_content', parent:'.hidden-sm'});
  1339. };
  1340. scripts['piratbit.org'] = scripts['pb.wtf'];
  1341. scripts['piratbit.ru'] = scripts['pb.wtf'];
  1342.  
  1343. scripts['pikabu.ru'] = function() {
  1344. gardener('.story', /story__sponsor|story__gag|profile\/ads"/i, {root: '.inner_wrap', observe: true});
  1345. };
  1346.  
  1347. scripts['rp5.ru'] = function() {
  1348. var co = document.querySelector('#content'), i, nodes;
  1349. if (!co) {
  1350. return;
  1351. }
  1352. nodes = co.parentNode.childNodes;
  1353. i = nodes.length;
  1354. while (i--) {
  1355. if (nodes[i] !== co) {
  1356. nodes[i].parentNode.removeChild(nodes[i]);
  1357. }
  1358. }
  1359. };
  1360.  
  1361. scripts['rustorka.com'] = {
  1362. 'now': function() {
  1363. createStyle([
  1364. '.header > div:not(.head-block) a, #sidebar1 img, #logo img {opacity:0!important}'
  1365. ], {
  1366. id: 'tempHidingStyles'
  1367. }, true);
  1368. win.open = function(){
  1369. console.log('Site attempted to open a new window', arguments);
  1370. };
  1371. window.open = win.open;
  1372. var realCreateElement = Document.prototype.createElement;
  1373. function wrappedCreateElement(name) {
  1374. var el = realCreateElement.apply(this, arguments);
  1375. if (el.tagName === 'A') {
  1376. el.addEventListener('click', function(e){
  1377. if (!e.target.parentNode || !e.isTrusted) {
  1378. e.preventDefault();
  1379. console.log('Blocked suspicious click event', e, 'on', e.target);
  1380. }
  1381. }, false);
  1382. }
  1383. return el;
  1384. }
  1385. Document.prototype.createElement = wrappedCreateElement;
  1386. },
  1387. 'DOMContentLoaded': function() {
  1388. for (var o of document.querySelectorAll('IMG, A')) {
  1389. if ((o.clientWidth === 728 && o.clientHeight === 90) ||
  1390. (o.clientWidth === 300 && o.clientHeight === 250)) {
  1391. while (o && o.tagName !== 'A') {
  1392. o = o.parentNode;
  1393. }
  1394. if (o) {
  1395. o.setAttribute('style', 'display: none !important');
  1396. }
  1397. }
  1398. }
  1399. var s = document.querySelector('#tempHidingStyles');
  1400. s.parentNode.removeChild(s);
  1401. }
  1402. };
  1403. scripts['rumedia.ws'] = scripts['rustorka.com'];
  1404.  
  1405. scripts['sport-express.ru'] = function() {
  1406. gardener('.js-relap__item',/>Реклама\s+<\//, {root:'.container', observe: true});
  1407. };
  1408.  
  1409. scripts['sports.ru'] = function() {
  1410. gardener('.aside-news-list__item', /aside-news-list__advert/i, {root:'.aside-news-block'});
  1411. };
  1412.  
  1413. scripts['turbobit.net'] = {'now': preventBackgroundRedirect};
  1414.  
  1415. scripts['yap.ru'] = function() {
  1416. var words = /member1438|Administration/;
  1417. gardener('form > table[id^="p_row_"]', words);
  1418. gardener('tr > .holder.newsbottom', words, {parent:'tr', siblings:-2});
  1419. };
  1420. scripts['yaplakal.com'] = scripts['yap.ru'];
  1421.  
  1422. scripts['reactor.cc'] = {
  1423. 'now': function() {
  1424. win.open = (function(){ throw new Error('Redirect prevention.'); }).bind(window);
  1425. },
  1426. 'click': function(e) {
  1427. var node = e.target;
  1428. if (node.nodeType === Node.ELEMENT_NODE &&
  1429. node.style.position === 'absolute' &&
  1430. node.style.zIndex > 0)
  1431. node.parentNode.removeChild(node);
  1432. },
  1433. 'DOMContentLoaded': function() {
  1434. var words = new RegExp(
  1435. 'блокировщика рекламы'
  1436. .split('')
  1437. .map(function(e){return e+'[\u200b\u200c\u200d]*';})
  1438. .join('')
  1439. .replace(' ', '\\s*')
  1440. .replace(/[аоре]/g, function(e){return ['[аa]','[оo]','[рp]','[еe]']['аоре'.indexOf(e)];}),
  1441. 'i'),
  1442. can;
  1443. function deeper(spider) {
  1444. var c, l, n;
  1445. if (words.test(spider.innerText)) {
  1446. if (spider.nodeType === Node.TEXT_NODE) {
  1447. return true;
  1448. }
  1449. c = spider.childNodes;
  1450. l = c.length;
  1451. n = 0;
  1452. while(l--) {
  1453. if (deeper(c[l]), can) {
  1454. n++;
  1455. }
  1456. }
  1457. if (n > 0 && n === c.length && spider.offsetHeight < 750) {
  1458. can.push(spider);
  1459. }
  1460. return false;
  1461. }
  1462. return true;
  1463. }
  1464. function probe(){
  1465. if (words.test(document.body.innerText)) {
  1466. can = [];
  1467. deeper(document.body);
  1468. var i = can.length, j, spider;
  1469. while(i--) {
  1470. spider = can[i];
  1471. if (spider.offsetHeight > 10 && spider.offsetHeight < 750) {
  1472. spider.setAttribute('style', 'background:none!important');
  1473. }
  1474. }
  1475. }
  1476. }
  1477. var o = new MutationObserver(probe);
  1478. o.observe(document,{childList:true, subtree:true});
  1479. }
  1480. };
  1481. scripts['joyreactor.cc'] = scripts['reactor.cc'];
  1482. scripts['pornreactor.cc'] = scripts['reactor.cc'];
  1483.  
  1484. scripts['auto.ru'] = function() {
  1485. var words = /Реклама|Яндекс.Директ|yandex_ad_/;
  1486. var userAdsListAds = [
  1487. '.listing-list > .listing-item',
  1488. '.listing-item_type_fixed.listing-item'
  1489. ];
  1490. var catalogAds = [
  1491. 'div[class*="layout_catalog-inline"]',
  1492. 'div[class$="layout_horizontal"]'
  1493. ];
  1494. var otherAds = [
  1495. '.advt_auto',
  1496. '.sidebar-block',
  1497. '.pager-listing + div[class]',
  1498. '.card > div[class][style]',
  1499. '.sidebar > div[class]',
  1500. '.main-page__section + div[class]',
  1501. '.listing > tbody'];
  1502. gardener(userAdsListAds.join(','), words, {root:'.listing-wrap', observe:true});
  1503. gardener(catalogAds.join(','), words, {root:'.catalog__page,.content__wrapper', observe:true});
  1504. gardener(otherAds.join(','), words);
  1505. };
  1506.  
  1507. scripts['rsload.net'] = {
  1508. 'load': function() {
  1509. var dis = document.querySelector('.cb-disable');
  1510. if (dis) {
  1511. dis.click();
  1512. }
  1513. },
  1514. 'click': function(e) {
  1515. var t = e.target;
  1516. if (t && t.href && (/:\/\/\d+\.\d+\.\d+\.\d+\//.test(t.href))) {
  1517. t.href = t.href.replace('://','://rsload.net:rsload.net@');
  1518. }
  1519. }
  1520. };
  1521.  
  1522. scripts['imageban.ru'] = {
  1523. 'now': preventBackgroundRedirect,
  1524. 'DOMContentLoaded': function() {
  1525. win.addEventListener('unload', function() {
  1526. if (!window.location.hash) {
  1527. window.location.replace(window.location+'#');
  1528. } else {
  1529. window.location.hash = '';
  1530. }
  1531. }, true);
  1532. }
  1533. };
  1534.  
  1535. var domain = document.domain, name;
  1536. while (domain.indexOf('.') !== -1) {
  1537. if (scripts.hasOwnProperty(domain)) {
  1538. if (typeof scripts[domain] === 'function') {
  1539. document.addEventListener ('DOMContentLoaded', scripts[domain], false);
  1540. }
  1541. for (name in scripts[domain]) {
  1542. if (name !== 'now') {
  1543. (name === 'load' ? window : document)
  1544. .addEventListener (name, scripts[domain][name], false);
  1545. } else {
  1546. scripts[domain][name]();
  1547. }
  1548. }
  1549. }
  1550. domain = domain.slice(domain.indexOf('.') + 1);
  1551. }
  1552. })();