RU AdList JS Fixes

try to take over the world!

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

  1. // ==UserScript==
  2. // @name RU AdList JS Fixes
  3. // @namespace ruadlist_js_fixes
  4. // @version 20161126.3
  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. if (!(/firefox/i.test(navigator.userAgent))) {
  419. WorkerWrapper(); // skip WorkerWrapper in Firefox
  420. }
  421. if (typeof document !== 'undefined') {
  422. CreateElementWrapper();
  423. }
  424. };
  425. }
  426.  
  427. if (isFirefox) {
  428. var script = document.createElement('script');
  429. script.appendChild(document.createTextNode(getWrappedCode(true)));
  430. document.head.insertBefore(script, document.head.firstChild);
  431. return; //we don't want to call functions on page from here in Fx, so exit
  432. }
  433.  
  434. (new WSI((unsafeWindow||self||window),(self||window))).init();
  435. })();
  436.  
  437. if (!isFirefox) { // scripts for non-Firefox browsers
  438.  
  439. // https://greasyfork.org/scripts/14720-it-s-not-important
  440. (function(){
  441. var imptt = /((display|(margin|padding)(-top|-bottom)?)\s*:[^;!]*)!\s*important/ig;
  442.  
  443. function unimportanter(el, si) {
  444. if (!imptt.test(si) || el.style.display === 'none') {
  445. return 0; // get out if we have nothing to do here
  446. }
  447. if (el.nodeName === 'IFRAME' && el.src &&
  448. el.src.slice(0,17) === 'chrome-extension:') {
  449. return 0; // Web of Trust uses this method to add their frame
  450. }
  451. var so = si.replace(imptt, function(){return arguments[1];}), ret = 0;
  452. if (si !== so) {
  453. ret = 1;
  454. el.setAttribute('style', so);
  455. }
  456. return ret;
  457. }
  458.  
  459. function logger(c) {
  460. if (c) {
  461. console.log('Some page elements became a bit less important.');
  462. }
  463. }
  464.  
  465. function checkTarget(node, cnt) {
  466. if (!(node && node.getAttribute)) {
  467. return 0;
  468. }
  469. var si = node.getAttribute('style');
  470. if (si && si.indexOf('!') > -1) {
  471. cnt += unimportanter(node, si);
  472. }
  473. return cnt;
  474. }
  475.  
  476. var observer = new MutationObserver(function(mutations) {
  477. setTimeout(function(ms) {
  478. var cnt = 0, m, node;
  479. for (m of ms) {
  480. cnt = checkTarget(m.target, cnt);
  481. for (node of m.addedNodes) {
  482. cnt += checkTarget(node, cnt);
  483. }
  484. }
  485. logger(cnt);
  486. }, 0, mutations);
  487. });
  488.  
  489. observer.observe(document, { childList : true, attributes : true, attributeFilter : ['style'], subtree : true });
  490.  
  491. win.addEventListener ("load", function(){
  492. var c = 0, imp;
  493. for (imp of document.querySelectorAll('[style*="!"]')) {
  494. c+= checkTarget(imp, c);
  495. }
  496. logger(c);
  497. }, false);
  498. })();
  499.  
  500. }
  501.  
  502. if (/^https?:\/\/(mail\.yandex\.|music\.yandex\.|news\.yandex\.|(www\.)?yandex\.[^\/]+\/(yand)?search[\/?])/i.test(win.location.href)) {
  503. // https://greasyfork.org/en/scripts/809-no-yandex-ads
  504. (function(){
  505. var adWords = ['Яндекс.Директ','Реклама','Ad'];
  506. function remove(node) {
  507. node.parentNode.removeChild(node);
  508. }
  509. // Generic ads removal and fixes
  510. function removeGenericAds() {
  511. var s, i;
  512. s = document.querySelector('.serp-header');
  513. if (s) {
  514. s.style.marginTop='0';
  515. }
  516. for (s of document.querySelectorAll('.serp-adv__head + .serp-item, #adbanner, .serp-adv, .b-spec-adv, div[class*="serp-adv__"]')) {
  517. remove(s);
  518. }
  519. }
  520. // Search ads
  521. function removeSearchAds() {
  522. var s, item;
  523. for (s of document.querySelectorAll('.serp-block, .serp-item, .search-item')) {
  524. item = s.querySelector('.label, .serp-item__label, .document__provider-name');
  525. if (item && adWords.indexOf(item.textContent) > -1) {
  526. remove(s);
  527. console.log('Ads removed.');
  528. }
  529. }
  530. }
  531. // News ads
  532. function removeNewsAds() {
  533. for (var s of document.querySelectorAll(
  534. '.page-content__left > *,'+
  535. '.page-content__right > *:not(.page-content__col),'+
  536. '.page-content__right > .page-content__col > *'
  537. )) {
  538. if (s.textContent.indexOf(adWords[0]) > -1 ||
  539. (s.clientHeight < 15 && s.classList.contains('rubric'))) {
  540. remove(s);
  541. console.log('Ads removed.');
  542. }
  543. }
  544. }
  545. // Music ads
  546. function removeMusicAds() {
  547. for (var s of document.querySelectorAll('.ads-block')) {
  548. remove(s);
  549. }
  550. }
  551. // Mail ads
  552. function removeMailAds() {
  553. var slice = Array.prototype.slice,
  554. nodes = slice.call(document.querySelectorAll('.ns-view-folders')),
  555. node, len, classes, cls;
  556. for (node of nodes) {
  557. if (!len || len > node.classList.length) {
  558. len = node.classList.length;
  559. }
  560. }
  561. node = nodes.pop();
  562. while (node) {
  563. if (node.classList.length > len) {
  564. for (cls of slice.call(node.classList)) {
  565. if (cls.indexOf('-') === -1) {
  566. remove(node);
  567. break;
  568. }
  569. }
  570. }
  571. node = nodes.pop();
  572. }
  573. }
  574. // News fixes
  575. function removePageAdsClass() {
  576. if (document.body.classList.contains("b-page_ads_yes")){
  577. document.body.classList.remove("b-page_ads_yes");
  578. console.log('Page ads class removed.');
  579. }
  580. }
  581. // Function to attach an observer to monitor dynamic changes on the page
  582. function pageUpdateObserver(func, obj, params) {
  583. if (obj) {
  584. var o = new MutationObserver(func);
  585. o.observe(obj,(params || {childList:true, subtree:true}));
  586. }
  587. }
  588. // Cleaner
  589. document.addEventListener ('DOMContentLoaded', function() {
  590. removeGenericAds();
  591. if (win.location.hostname.search(/^mail\./i) === 0) {
  592. pageUpdateObserver(function(ms, o){
  593. var aside = document.querySelector('.mail-Layout-Aside');
  594. if (aside) {
  595. o.disconnect();
  596. pageUpdateObserver(removeMailAds, aside);
  597. }
  598. }, document.querySelector('BODY'));
  599. removeMailAds();
  600. } else if (win.location.hostname.search(/^music\./i) === 0) {
  601. pageUpdateObserver(removeMusicAds, document.querySelector('.sidebar'));
  602. removeMusicAds();
  603. } else if (win.location.hostname.search(/^news\./i) === 0) {
  604. pageUpdateObserver(removeNewsAds, document.querySelector('BODY'));
  605. pageUpdateObserver(removePageAdsClass, document.body, {attributes:true, attributesFilter:['class']});
  606. removeNewsAds();
  607. removePageAdsClass();
  608. } else {
  609. pageUpdateObserver(removeSearchAds, document.querySelector('.main__content'));
  610. removeSearchAds();
  611. }
  612. });
  613. })();
  614. return; //skip fixes for other sites
  615. }
  616.  
  617. // https://greasyfork.org/en/scripts/21937-moonwalk-hdgo-kodik-fix v0.8 (adapted)
  618. document.addEventListener ('DOMContentLoaded', function() {
  619. var tmp;
  620. function log (e) {
  621. console.log('Moonwalk&HDGo&Kodik FIX: ' + e + ' player in ' + win.location.href);
  622. }
  623. if (win.adv_enabled !== undefined && win.condition_detected !== undefined) { // moonwalk
  624. log('Moonwalk');
  625. if (win.adv_enabled) {
  626. win.adv_enabled = false;
  627. }
  628. win.condition_detected = false;
  629. if (win.MXoverrollCallback) {
  630. document.addEventListener('click', function catcher(e){
  631. e.stopPropagation();
  632. win.MXoverrollCallback.call(window);
  633. document.removeEventListener('click', catcher, true);
  634. }, true);
  635. }
  636. } else if (win.stat_url !== undefined && win.is_html5 !== undefined && win.is_wp8 !== undefined) { // hdgo
  637. log('HDGo');
  638. document.body.onclick = null;
  639. tmp = document.querySelector('#swtf');
  640. if (tmp) {
  641. tmp.style.display = 'none';
  642. }
  643. if (win.banner_second !== undefined) {
  644. win.banner_second = 0;
  645. }
  646. if (win.$banner_ads !== undefined) {
  647. win.$banner_ads = false;
  648. }
  649. if (win.$new_ads !== undefined) {
  650. win.$new_ads = false;
  651. }
  652. if (win.createCookie !== undefined) {
  653. win.createCookie('popup','true','999');
  654. }
  655. if (win.canRunAds !== undefined && win.canRunAds !== true) {
  656. win.canRunAds = true;
  657. }
  658. } else if (win.MXoverrollCallback && win.iframeSearch !== undefined) { // kodik
  659. log('Kodik');
  660. tmp = document.querySelector('.play_button');
  661. if (tmp) {
  662. tmp.onclick = win.MXoverrollCallback.bind(window);
  663. }
  664. win.IsAdBlock = false;
  665. }
  666. }, false);
  667.  
  668. // function to search and remove nodes by content
  669. // selector - standard CSS selector to define set of nodes to check
  670. // words - regular expression to check content of the suspicious nodes
  671. // params - object with multiple extra parameters:
  672. // .hide - set display to none instead of removing from the page
  673. // .parent - parent node to remove if content is found in the child node
  674. // .siblings - number of simling nodes to remove (excluding text nodes)
  675. function scRemove(e) {e.parentNode.removeChild(e);}
  676. function scHide(e) {
  677. var s = e.getAttribute('style')||'',
  678. h = ';display:none!important;';
  679. if (s.indexOf(h) < 0) {
  680. e.setAttribute('style', s+h);
  681. }
  682. }
  683. function scissors (selector, words, scope, params) {
  684. var remFunc = (params.hide ? scHide : scRemove),
  685. iterFunc = (params.siblings > 0 ?
  686. 'nextSibling' :
  687. 'previousSibling'),
  688. toRemove = [],
  689. siblings,
  690. node;
  691. for (node of scope.querySelectorAll(selector)) {
  692. if (words.test(node.innerHTML) || !node.childNodes.length) {
  693. // drill up to the specified parent node if required
  694. if (params.parent) {
  695. while(node !== scope && !(node.matches(params.parent))) {
  696. node = node.parentNode;
  697. }
  698. }
  699. if (node === scope) {
  700. break;
  701. }
  702. toRemove.push(node);
  703. // add multiple nodes if defined more than one sibling
  704. siblings = Math.abs(params.siblings) || 0;
  705. while (siblings) {
  706. node = node[iterFunc];
  707. toRemove.push(node);
  708. if (node.nodeType === Node.ELEMENT_NODE) {
  709. siblings -= 1; //count only element nodes
  710. }
  711. }
  712. }
  713. }
  714. for (node of toRemove) {
  715. remFunc(node);
  716. }
  717. return toRemove.length;
  718. }
  719.  
  720. // function to perform multiple checks if ads inserted with a delay
  721. // by default does 30 checks withing a 3 seconds unless nonstop mode specified
  722. // also does 1 extra check when a page completely loads
  723. // selector and words - passed dow to scissors
  724. // params - object with multiple extra parameters:
  725. // .root - selector to narrow down scope to scan;
  726. // .observe - if true then check will be performed continuously;
  727. // Other parameters passed down to scissors.
  728. function gardener(selector, words, params) {
  729. params = params || {};
  730. var scope = document.body,
  731. nonstop = false;
  732. // narrow down scope to a specific element
  733. if (params.root) {
  734. scope = scope.querySelector(params.root);
  735. if (!scope) {// exit if the root element is not present on the page
  736. return 0;
  737. }
  738. }
  739. // add observe mode if required
  740. if (params.observe) {
  741. if (typeof MutationObserver === 'function') {
  742. var o = new MutationObserver(function(ms){
  743. for (var m of ms) {
  744. if (m.addedNodes.length) {
  745. scissors(selector, words, scope, params);
  746. }
  747. }
  748. });
  749. o.observe(scope, {childList:true, subtree: true});
  750. } else {
  751. nonstop = true;
  752. }
  753. }
  754. // wait for a full page load to do one extra cut
  755. win.addEventListener('load',function(){
  756. scissors(selector, words, scope, params);
  757. });
  758. // do multiple cuts until ads removed
  759. function cut(sci, s, w, sc, p, i) {
  760. if (i > 0) {
  761. i -= 1;
  762. }
  763. if (i && !sci(s, w, sc, p)) {
  764. setTimeout(cut, 100, sci, s, w, sc, p, i);
  765. }
  766. }
  767. cut(scissors, selector, words, scope, params, (nonstop ? -1 : 30));
  768. }
  769.  
  770. function preventBackgroundRedirect() {
  771. // create "cose_me" event to call high-level window.close()
  772. var key = Math.random().toString(36).substr(2);
  773. window.addEventListener('close_me_'+key, function(e) {
  774. window.close();
  775. });
  776.  
  777. // window.open wrapper
  778. function pbrLander() {
  779. var orgOpen = window.open.bind(window);
  780. function closeWindow(){
  781. // site went to a new tab and attempts to unload
  782. // call for high-level close through event
  783. var event = new CustomEvent("close_me_%key%", {});
  784. window.dispatchEvent(event);
  785. }
  786. function open(){
  787. var idx = String.prototype.indexOf;
  788. if (arguments[0] &&
  789. (idx.call(arguments[0], window.location.host) > -1 ||
  790. idx.call(arguments[0], '://') === -1)) {
  791. window.addEventListener('unload', closeWindow, true);
  792. }
  793. orgOpen.apply(window, arguments);
  794. }
  795. window.open = open.bind(window);
  796. var s = document.currentScript;
  797. if (s) {s.parentNode.removeChild(s);}
  798. }
  799.  
  800. // land wrapper on the page
  801. var script = document.createElement('script');
  802. script.appendChild(document.createTextNode('('+pbrLander.toString().replace(/%key%/g,key)+')();'));
  803. document.head.insertBefore(script,document.head.firstChild);
  804. console.log("Background redirect prevention enabled.");
  805. }
  806.  
  807. function preventPopups() {
  808. win.open = function(){
  809. console.log('Site attempted to open a new window', arguments);
  810. };
  811. window.open = win.open;
  812. var realCreateElement = Document.prototype.createElement;
  813. function wrappedCreateElement(name) {
  814. var el = realCreateElement.apply(this, arguments);
  815. if (el.tagName === 'A') {
  816. el.addEventListener('click', function(e){
  817. if (!e.target.parentNode || !e.isTrusted) {
  818. e.preventDefault();
  819. console.log('Blocked suspicious click event', e, 'on', e.target);
  820. }
  821. }, false);
  822. }
  823. return el;
  824. }
  825. Document.prototype.createElement = wrappedCreateElement;
  826. }
  827.  
  828. function forbidServiceWorker() {
  829. if (!("serviceWorker" in navigator)) {
  830. return;
  831. }
  832. var svr = navigator.serviceWorker.ready;
  833. Object.defineProperty(navigator, 'serviceWorker', {
  834. value: {
  835. register: function(){
  836. console.log('Registration of serviceWorker ' + arguments[0] + ' blocked.');
  837. return new Promise(function(){});
  838. },
  839. ready: new Promise(function(){}),
  840. addEventListener:function(){}
  841. }
  842. });
  843. document.addEventListener('DOMContentLoaded', function() {
  844. if (!svr) {
  845. return;
  846. }
  847. svr.then(function(sw) {
  848. console.log('Found existing serviceWorker:', sw);
  849. console.log('Attempting to unregister...');
  850. sw.unregister().then(function() {
  851. console.log('Unregistered! :)');
  852. }).catch(function(err) {
  853. console.log('Unregistration failed. :(', err);
  854. console.log('Try to remove it manually:');
  855. console.log(' 1. Open: chrome://serviceworker-internals/ (Google Chrome and alike) or about:serviceworkers (Mozilla Firefox) in a new tab.');
  856. console.log(' 2. Search there for one with "'+document.domain+'" in the name.');
  857. console.log(' 3. Use buttons in the same block with service you found to stop it and uninstall/unregister.');
  858. });
  859. }).catch(function(err) {
  860. console.log("Lol, it failed on it's own. -_-", err);
  861. });
  862. }, false);
  863. }
  864.  
  865. var scripts = {};
  866. scripts['4pda.ru'] = {
  867. 'now': function() {
  868. // https://greasyfork.org/en/scripts/14470-4pda-unbrender
  869. var isForum = document.location.href.search('/forum/') !== -1,
  870. hStyle;
  871.  
  872. function remove(n) {
  873. if (n) {
  874. n.parentNode.removeChild(n);
  875. }
  876. }
  877.  
  878. function afterClean() {
  879. hStyle.disabled = true;
  880. remove(hStyle);
  881. }
  882.  
  883. function beforeClean() {
  884. // attach styles before document displayed
  885. hStyle = createStyle([
  886. 'html { overflow-y: scroll }',
  887. 'section[id] {'+(
  888. 'position: absolute;'+
  889. 'width: 100%'
  890. )+'}',
  891. 'article + aside * { display: none !important }',
  892. '#header + div:after {'+(
  893. 'content: "";'+
  894. 'position: fixed;'+
  895. 'top: 0;'+
  896. 'left: 0;'+
  897. 'width: 100%;'+
  898. 'height: 100%;'+
  899. 'background-color: #E6E7E9'
  900. )+'}',
  901. // http://codepen.io/Beaugust/pen/DByiE
  902. '@keyframes spin { 100% { transform: rotate(360deg) } }',
  903. 'article + aside:after {'+(
  904. 'content: "";'+
  905. 'position: absolute;'+
  906. 'width: 150px;'+
  907. 'height: 150px;'+
  908. 'top: 150px;'+
  909. 'left: 50%;'+
  910. 'margin-top: -75px;'+
  911. 'margin-left: -75px;'+
  912. 'box-sizing: border-box;'+
  913. 'border-radius: 100%;'+
  914. 'border: 10px solid rgba(0, 0, 0, 0.2);'+
  915. 'border-top-color: rgba(0, 0, 0, 0.6);'+
  916. 'animation: spin 2s infinite linear'
  917. )+'}'
  918. ], {id:'ubrHider'}, true);
  919.  
  920. // display content of a page if time to load a page is more than 2 seconds to avoid
  921. // blocking access to a page if it is loading for too long or stuck in a loading state
  922. setTimeout(2000, afterClean);
  923. }
  924.  
  925. createStyle([
  926. '#nav .use-ad { display: block !important }',
  927. 'article:not(.post) + article:not(#id), a[target="_blank"] img[height="90"] { display: none !important }'
  928. ]);
  929.  
  930. if (!isForum) {
  931. beforeClean();
  932. }
  933.  
  934. // save links to non-overridden functions to use later
  935. var oGA = Element.prototype.getAttribute,
  936. oSA = Element.prototype.setAttribute,
  937. protectedElems;
  938. // protect/hide changed attributes in case site attempt to restore them
  939. function styleProtector(eventMode) {
  940. var oRAN = Element.prototype.removeAttributeNode,
  941. isStyleText = function(t){ return t === 'style'; },
  942. isStyleAttr = function(a){ return a instanceof Attr && a.nodeName === 'style'; },
  943. returnUndefined = function(){},
  944. protectedElems = new WeakMap();
  945. function protoOverride(element, functionName, isStyleCheck, returnIfProtected) {
  946. var oF = element.prototype[functionName];
  947. element.prototype[functionName] = function(){
  948. if (protectedElems.get(this) !== undefined && isStyleCheck(arguments[0])) {
  949. return returnIfProtected(protectedElems.get(this), arguments, this);
  950. }
  951. return oF.apply(this, arguments);
  952. };
  953. }
  954. protoOverride(Element, 'removeAttribute', isStyleText, returnUndefined);
  955. protoOverride(Element, 'hasAttribute', isStyleText, function(o) {
  956. return o.oldStyle !== null;
  957. });
  958. protoOverride(Element, 'setAttribute', isStyleText, function(o, args) {
  959. o.oldStyle = args[1];
  960. });
  961. protoOverride(Element, 'getAttribute', isStyleText, function(o) {
  962. return o.oldStyle;
  963. });
  964. if (eventMode) {
  965. var e = document.createEvent('Event');
  966. e.initEvent('protoOverride', false, false);
  967. window.protectedElems = protectedElems;
  968. window.dispatchEvent(e);
  969. } else {
  970. return protectedElems;
  971. }
  972. }
  973. if (isFirefox) {
  974. var s = document.createElement('script');
  975. s.textContent = '(' + styleProtector.toString() + ')(true);' +
  976. 'var s = document.currentScript; if (s) {s.parentNode.removeChild(s);}';
  977. window.addEventListener('protoOverride', function protoOverrideCallback(e){
  978. if (win.protectedElems) {
  979. protectedElems = win.protectedElems;
  980. delete win.protectedElems;
  981. }
  982. document.removeEventListener('protoOverride', protoOverrideCallback, true);
  983. }, true);
  984. document.documentElement.appendChild(s);
  985. } else {
  986. protectedElems = styleProtector(false);
  987. }
  988.  
  989. // clean a page
  990. window.addEventListener('DOMContentLoaded', function(){
  991. var rem, si, itm;
  992. function width(){ return window.innerWidth||document.documentElement.clientWidth||document.body.clientWidth||0; }
  993. function height(){ return window.innerHeight||document.documentElement.clientHeight||document.body.clientHeight||0; }
  994.  
  995.  
  996. if (isForum) {
  997. si = document.querySelector('#logostrip');
  998. if (si) {
  999. remove(si.parentNode.nextSibling);
  1000. }
  1001. }
  1002.  
  1003. if (document.location.href.search('/forum/dl/') !== -1) {
  1004. document.body.setAttribute('style', (document.body.getAttribute('style')||'')+
  1005. ';background-color:black!important');
  1006. for (itm of document.querySelectorAll('body>div')) {
  1007. if (!itm.querySelector('.dw-fdwlink')) {
  1008. remove(itm);
  1009. }
  1010. }
  1011. }
  1012.  
  1013. if (isForum) { // Do not continue if it's a forum
  1014. return;
  1015. }
  1016.  
  1017. si = document.querySelector('#header');
  1018. if (si) {
  1019. rem = si.previousSibling;
  1020. while (rem) {
  1021. si = rem.previousSibling;
  1022. remove(rem);
  1023. rem = si;
  1024. }
  1025. }
  1026.  
  1027. for (itm of document.querySelectorAll('#nav li[class]')) {
  1028. if (itm && itm.querySelector('a[href^="/tag/"]')) {
  1029. remove(itm);
  1030. }
  1031. }
  1032.  
  1033. var style, result;
  1034. for (itm of document.querySelectorAll('DIV, A')) {
  1035. if (itm.tagName ==='DIV' && itm.offsetWidth > 0.95 * width() && itm.offsetHeight > 0.85 * height()) {
  1036. style = window.getComputedStyle(itm, null);
  1037. result = [];
  1038. if (style.backgroundImage !== 'none') {
  1039. result.push('background-image:none!important');
  1040. }
  1041. if (style.backgroundColor !== 'transparent' &&
  1042. style.backgroundColor !== 'rgba(0, 0, 0, 0)') {
  1043. result.push('background-color:transparent!important');
  1044. }
  1045. if (result.length) {
  1046. if (itm.getAttribute('style')) {
  1047. result.unshift(itm.getAttribute('style'));
  1048. }
  1049. (function(){
  1050. var fakeStyle = {
  1051. 'backgroundImage': itm.style.backgroundImage,
  1052. 'backgroundColor': itm.style.backgroundColor
  1053. };
  1054. try {
  1055. Object.defineProperty(itm, 'style', {
  1056. value: new Proxy(itm.style, {
  1057. get: function(target, prop){
  1058. if (fakeStyle.hasOwnProperty(prop)) {
  1059. return fakeStyle[prop];
  1060. } else {
  1061. return target[prop];
  1062. }
  1063. },
  1064. set: function(target, prop, value){
  1065. if (fakeStyle.hasOwnProperty(prop)) {
  1066. fakeStyle[prop] = value;
  1067. } else {
  1068. target[prop] = value;
  1069. }
  1070. return value;
  1071. }
  1072. }),
  1073. enumerable: true
  1074. });
  1075. } catch (e) {
  1076. console.log('Unable to protect style property.', e);
  1077. }
  1078. })();
  1079. if (protectedElems) {
  1080. protectedElems.set(itm, {oldStyle: oGA.call(itm, 'style')});
  1081. }
  1082. oSA.call(itm, 'style', result.join(';'));
  1083. }
  1084. }
  1085. if (itm.tagName ==='A' && (itm.offsetWidth > 0.95 * width() || itm.offsetHeight > 0.85 * height())) {
  1086. if (protectedElems) {
  1087. protectedElems.set(itm, {oldStyle: oGA.call(itm, 'style')});
  1088. }
  1089. oSA.call(itm, 'style', 'display:none!important');
  1090. }
  1091. }
  1092.  
  1093. for (itm of document.querySelectorAll('ASIDE>DIV')) {
  1094. if ( ((itm.querySelector('script, iframe, a[href*="/ad/www/"]') ||
  1095. itm.querySelector('img[src$=".gif"]:not([height="0"]), img[height="400"]')) &&
  1096. !itm.classList.contains('post') ) || !itm.childNodes.length ) {
  1097. remove(itm);
  1098. }
  1099. }
  1100.  
  1101. document.body.setAttribute('style', (document.body.getAttribute('style')||'')+';background-color:#E6E7E9!important');
  1102.  
  1103. // display content of the page
  1104. afterClean();
  1105. });
  1106. }
  1107. }
  1108.  
  1109. scripts['anidub-online.ru'] = function() {
  1110. var script = document.createElement('script');
  1111. script.type = "text/javascript";
  1112. script.innerHTML = "function ogonekstart1() {}";
  1113. document.getElementsByTagName('head')[0].appendChild(script);
  1114.  
  1115. var style = document.createElement('style');
  1116. style.type = 'text/css';
  1117. style.appendChild(document.createTextNode('.background {background: none!important;}'));
  1118. style.appendChild(document.createTextNode('.background > script + div, .background > script ~ div:not([id]):not([class]) + div[id][class] {display:none!important}'));
  1119. document.head.appendChild(style);
  1120. };
  1121. scripts['online.anidub.com'] = scripts['anidub-online.ru'];
  1122.  
  1123. scripts['fs.to'] = function() {
  1124. function skipClicker(i) {
  1125. if (!i) {
  1126. return;
  1127. }
  1128. var skip = document.querySelector('.b-aplayer-banners__close');
  1129. if (skip) {
  1130. skip.click();
  1131. } else {
  1132. setTimeout(skipClicker, 100, i-1);
  1133. }
  1134. }
  1135. setTimeout(skipClicker, 100, 30);
  1136.  
  1137. createStyle([
  1138. '.l-body-branding *,'+
  1139. '.b-styled__item-central,'+
  1140. '.b-styled__content-right,'+
  1141. '.b-styled__section-central,'+
  1142. 'div[id^="adsProxy-"]'+
  1143. '{display:none!important}',
  1144. 'body {background-image:url(data:image/png;base64,'+
  1145. 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAACX'+
  1146. 'BIWXMAAC4jAAAuIwF4pT92AAAADUlEQVR42mOQUdL5DwACMgFq'+
  1147. 'BC3ttwAAAABJRU5ErkJggg==)!important}'
  1148. ]);
  1149.  
  1150. if (/\/(view_iframe|iframeplayer)\//i.test(document.location.pathname)) {
  1151. var p = document.querySelector('#player:not([preload="auto"])'),
  1152. m = document.querySelector('.main'),
  1153. adStepper = function(p) {
  1154. if (p.currentTime < p.duration) {
  1155. p.currentTime += 1;
  1156. }
  1157. },
  1158. adSkipper = function(f, p) {
  1159. f.click();
  1160. p.waitAfterSkip = false;
  1161. p.longerSkipper = false;
  1162. console.log('Пропустили.');
  1163. },
  1164. cl = function(p) {
  1165. var faster = document.querySelector('.b-aplayer__html5-desktop-skip'),
  1166. series = document.querySelector('.b-aplayer__actions-series');
  1167.  
  1168. function clickSelected() {
  1169. var s = document.querySelector('.b-aplayer__popup-series-episodes .selected a');
  1170. if (s) {
  1171. s.click();
  1172. }
  1173. }
  1174.  
  1175. if ((!faster || faster.style.display !== 'block') && series && !p.seriesClicked) {
  1176. series.click();
  1177. p.seriesClicked = true;
  1178. p.longerSkipper = true;
  1179. setTimeout(clickSelected, 1000);
  1180. p.pause();
  1181. }
  1182.  
  1183. function skipListener() {
  1184. if (p.waitAfterSkip) {
  1185. console.log('В процессе пропуска…');
  1186. return;
  1187. }
  1188. p.pause();
  1189. if (!p.classList.contains('m-hidden')) {
  1190. p.classList.add('m-hidden');
  1191. }
  1192. if (faster && p.currentTime &&
  1193. win.getComputedStyle(faster).display === 'block' &&
  1194. !faster.querySelector('.b-aplayer__html5-desktop-skip-timer')) {
  1195. p.waitAfterSkip = true;
  1196. setTimeout(adSkipper, (p.longerSkipper?3:1)*1000, faster, p);
  1197. console.log('Доступен быстрый пропуск…');
  1198. } else {
  1199. setTimeout(adStepper, 1000, p);
  1200. }
  1201. }
  1202.  
  1203. p.addEventListener('timeupdate', skipListener, false);
  1204. },
  1205. o = new MutationObserver(function (ms) {
  1206. var m, node;
  1207. for (m of ms) {
  1208. for (node of m.addedNodes) {
  1209. if (node.id === 'player' &&
  1210. node.nodeName === 'VIDEO' &&
  1211. node.getAttribute('preload') !== 'auto') {
  1212. cl(node);
  1213. }
  1214. }
  1215. }
  1216. });
  1217. if (p.nodeName === 'VIDEO') {
  1218. cl(p);
  1219. } else {
  1220. o.observe(m, {childList: true});
  1221. }
  1222. }
  1223. };
  1224. scripts['brb.to'] = scripts['fs.to'];
  1225. scripts['cxz.to'] = scripts['fs.to'];
  1226.  
  1227. scripts['drive2.ru'] = function() {
  1228. gardener('.c-block:not([data-metrika="recomm"]),.o-grid__item', />Реклама<\//i);
  1229. };
  1230.  
  1231. scripts['fishki.net'] = function() {
  1232. gardener('.main-post', /543769|Реклама/);
  1233. };
  1234.  
  1235. scripts['gidonline.club'] = {
  1236. 'now': function() {
  1237. createStyle('.tray > div[style] {display: none!important}');
  1238. }
  1239. };
  1240. scripts['gidonlinekino.com'] = scripts['gidonline.club'];
  1241.  
  1242. scripts['hdgo.cc'] = {
  1243. 'now': function(){
  1244. var o = new MutationObserver(function(ms) {
  1245. var m, node;
  1246. for (m of ms) {
  1247. for (node of m.addedNodes) {
  1248. if (node.tagName === 'SCRIPT' && node.getAttribute('onerror') !== null) {
  1249. node.removeAttribute('onerror');
  1250. }
  1251. }
  1252. }
  1253. });
  1254. o.observe(document, {childList:true, subtree: true});
  1255. }
  1256. };
  1257. scripts['couber.be'] = scripts['hdgo.cc'];
  1258. scripts['46.30.43.38'] = scripts['hdgo.cc'];
  1259.  
  1260. scripts['hdrezka.me'] = {
  1261. 'now': function() {
  1262. Object.defineProperty(win, 'fuckAdBlock', {
  1263. value: {
  1264. onDetected: function() {
  1265. console.log('Pretending to be an ABP detector.');
  1266. }
  1267. }
  1268. });
  1269. Object.defineProperty(win, 'ab', {
  1270. value: false,
  1271. enumerable: true
  1272. });
  1273. },
  1274. 'DOMContentLoaded': function() {
  1275. gardener('div[id][onclick][onmouseup][onmousedown]', /onmouseout/i);
  1276. }
  1277. };
  1278.  
  1279. scripts['imageban.ru'] = {
  1280. 'now': preventBackgroundRedirect,
  1281. 'DOMContentLoaded': function() {
  1282. win.addEventListener('unload', function() {
  1283. if (!window.location.hash) {
  1284. window.location.replace(window.location+'#');
  1285. } else {
  1286. window.location.hash = '';
  1287. }
  1288. }, true);
  1289. }
  1290. };
  1291.  
  1292. scripts['megogo.net'] = {
  1293. 'now': function() {
  1294. Object.defineProperty(win, "adBlock", {
  1295. value : false,
  1296. enumerable : true
  1297. });
  1298. Object.defineProperty(win, "showAdBlockMessage", {
  1299. value : function () {},
  1300. enumerable : true
  1301. });
  1302. }
  1303. };
  1304.  
  1305. scripts['naruto-base.su'] = function() {
  1306. gardener('div[id^="entryID"],.block', /href="http.*?target="_blank"/i);
  1307. };
  1308.  
  1309. scripts['overclockers.ru'] = {
  1310. 'now': function() {
  1311. // Following code inspired by:
  1312. // https://greasyfork.org/en/scripts/23922-anti-adblock-killer-for-overclockers-ru
  1313. function antiAntiABP() {
  1314. var o = new MutationObserver(function(ms) {
  1315. var m, node;
  1316. for (m of ms) {
  1317. for (node of m.addedNodes) {
  1318. if (node.nodeType === Node.ELEMENT_NODE && node.onerror) {
  1319. node.onerror = null;
  1320. if (!/^https:\/\/an\.yandex\.ru\//.test(node.src)) {
  1321. console.log("Disabled 'onerror' on", node);
  1322. }
  1323. }
  1324. }
  1325. }
  1326. });
  1327. o.observe(document, {childList: true, subtree: true});
  1328. var s = document.currentScript;
  1329. s.parentNode.removeChild(s);
  1330. var log = window.console.log;
  1331. window.console.log = function() {
  1332. log.apply(this, arguments);
  1333. if (arguments[0] === 'blocked') {
  1334. throw new Error('or not, it\'s the question');
  1335. }
  1336. }
  1337. }
  1338. var s = document.createElement('script');
  1339. s.textContent = '(' + antiAntiABP.toString() + ')();';
  1340. document.documentElement.appendChild(s);
  1341. }
  1342. };
  1343. scripts['forums.overclockers.ru'] = {
  1344. 'now': function() {
  1345. createStyle(['.needblock {position: fixed; left: -10000px}']);
  1346. Object.defineProperty(win, 'adblck', {
  1347. value: 'no',
  1348. enumerable: true
  1349. });
  1350. }
  1351. };
  1352.  
  1353. scripts['pb.wtf'] = function() {
  1354. createStyle(['.reques,#result,tbody.row1:not([id]) {display: none !important}']);
  1355. // image in the slider in the header
  1356. gardener('a[href$="=="]', /img/i, {root:'.release-navbar', observe:true, parent:'div'});
  1357. // ads in blocks on the page
  1358. gardener('a[href^="/"]', /<img\s.*<br>/i, {root:'#main_content', observe:true, parent:'div[class]'});
  1359. // line above topic content
  1360. gardener('.re_top1', /./, {root:'#main_content', parent:'.hidden-sm'});
  1361. };
  1362. scripts['piratbit.org'] = scripts['pb.wtf'];
  1363. scripts['piratbit.ru'] = scripts['pb.wtf'];
  1364.  
  1365. scripts['pikabu.ru'] = function() {
  1366. gardener('.story', /story__sponsor|story__gag|profile\/ads"/i, {root: '.inner_wrap', observe: true});
  1367. };
  1368.  
  1369. scripts['rp5.ru'] = function() {
  1370. createStyle(['#bannerBottom {display: none!important}']);
  1371. var co = document.querySelector('#content'), i, nodes;
  1372. if (!co) {
  1373. return;
  1374. }
  1375. nodes = co.parentNode.childNodes;
  1376. i = nodes.length;
  1377. while (i--) {
  1378. if (nodes[i] !== co) {
  1379. nodes[i].parentNode.removeChild(nodes[i]);
  1380. }
  1381. }
  1382. };
  1383. scripts['rp5.by'] = scripts['rp5.ru'];
  1384. scripts['rp5.ua'] = scripts['rp5.ru'];
  1385.  
  1386. scripts['rustorka.com'] = {
  1387. 'now': function() {
  1388. createStyle([
  1389. '.header > div:not(.head-block) a, #sidebar1 img, #logo img {opacity:0!important}'
  1390. ], {
  1391. id: 'tempHidingStyles'
  1392. }, true);
  1393. preventPopups();
  1394. },
  1395. 'DOMContentLoaded': function() {
  1396. for (var o of document.querySelectorAll('IMG, A')) {
  1397. if ((o.clientWidth === 728 && o.clientHeight === 90) ||
  1398. (o.clientWidth === 300 && o.clientHeight === 250)) {
  1399. while (o && o.tagName !== 'A') {
  1400. o = o.parentNode;
  1401. }
  1402. if (o) {
  1403. o.setAttribute('style', 'display: none !important');
  1404. }
  1405. }
  1406. }
  1407. var s = document.querySelector('#tempHidingStyles');
  1408. s.parentNode.removeChild(s);
  1409. }
  1410. };
  1411. scripts['rumedia.ws'] = scripts['rustorka.com'];
  1412.  
  1413. scripts['sport-express.ru'] = function() {
  1414. gardener('.js-relap__item',/>Реклама\s+<\//, {root:'.container', observe: true});
  1415. };
  1416.  
  1417. scripts['sports.ru'] = function() {
  1418. gardener('.aside-news-list__item', /aside-news-list__advert/i, {root:'.aside-news-block'});
  1419. };
  1420.  
  1421. scripts['turbobit.net'] = {'now': preventBackgroundRedirect};
  1422.  
  1423. scripts['yap.ru'] = function() {
  1424. var words = /member1438|Administration/;
  1425. gardener('form > table[id^="p_row_"]', words);
  1426. gardener('tr > .holder.newsbottom', words, {parent:'tr', siblings:-2});
  1427. };
  1428. scripts['yaplakal.com'] = scripts['yap.ru'];
  1429.  
  1430. scripts['reactor.cc'] = {
  1431. 'now': function() {
  1432. win.open = (function(){ throw new Error('Redirect prevention.'); }).bind(window);
  1433. },
  1434. 'click': function(e) {
  1435. var node = e.target;
  1436. if (node.nodeType === Node.ELEMENT_NODE &&
  1437. node.style.position === 'absolute' &&
  1438. node.style.zIndex > 0)
  1439. node.parentNode.removeChild(node);
  1440. },
  1441. 'DOMContentLoaded': function() {
  1442. var words = new RegExp(
  1443. 'блокировщика рекламы'
  1444. .split('')
  1445. .map(function(e){return e+'[\u200b\u200c\u200d]*';})
  1446. .join('')
  1447. .replace(' ', '\\s*')
  1448. .replace(/[аоре]/g, function(e){return ['[аa]','[оo]','[рp]','[еe]']['аоре'.indexOf(e)];}),
  1449. 'i'),
  1450. can;
  1451. function deeper(spider) {
  1452. var c, l, n;
  1453. if (words.test(spider.innerText)) {
  1454. if (spider.nodeType === Node.TEXT_NODE) {
  1455. return true;
  1456. }
  1457. c = spider.childNodes;
  1458. l = c.length;
  1459. n = 0;
  1460. while(l--) {
  1461. if (deeper(c[l]), can) {
  1462. n++;
  1463. }
  1464. }
  1465. if (n > 0 && n === c.length && spider.offsetHeight < 750) {
  1466. can.push(spider);
  1467. }
  1468. return false;
  1469. }
  1470. return true;
  1471. }
  1472. function probe(){
  1473. if (words.test(document.body.innerText)) {
  1474. can = [];
  1475. deeper(document.body);
  1476. var i = can.length, j, spider;
  1477. while(i--) {
  1478. spider = can[i];
  1479. if (spider.offsetHeight > 10 && spider.offsetHeight < 750) {
  1480. spider.setAttribute('style', 'background:none!important');
  1481. }
  1482. }
  1483. }
  1484. }
  1485. var o = new MutationObserver(probe);
  1486. o.observe(document,{childList:true, subtree:true});
  1487. }
  1488. };
  1489. scripts['joyreactor.cc'] = scripts['reactor.cc'];
  1490. scripts['pornreactor.cc'] = scripts['reactor.cc'];
  1491.  
  1492. scripts['auto.ru'] = function() {
  1493. var words = /Реклама|Яндекс.Директ|yandex_ad_/;
  1494. var userAdsListAds = [
  1495. '.listing-list > .listing-item',
  1496. '.listing-item_type_fixed.listing-item'
  1497. ];
  1498. var catalogAds = [
  1499. 'div[class*="layout_catalog-inline"]',
  1500. 'div[class$="layout_horizontal"]'
  1501. ];
  1502. var otherAds = [
  1503. '.advt_auto',
  1504. '.sidebar-block',
  1505. '.pager-listing + div[class]',
  1506. '.card > div[class][style]',
  1507. '.sidebar > div[class]',
  1508. '.main-page__section + div[class]',
  1509. '.listing > tbody'];
  1510. gardener(userAdsListAds.join(','), words, {root:'.listing-wrap', observe:true});
  1511. gardener(catalogAds.join(','), words, {root:'.catalog__page,.content__wrapper', observe:true});
  1512. gardener(otherAds.join(','), words);
  1513. };
  1514.  
  1515. scripts['rsload.net'] = {
  1516. 'load': function() {
  1517. var dis = document.querySelector('.cb-disable');
  1518. if (dis) {
  1519. dis.click();
  1520. }
  1521. },
  1522. 'click': function(e) {
  1523. var t = e.target;
  1524. if (t && t.href && (/:\/\/\d+\.\d+\.\d+\.\d+\//.test(t.href))) {
  1525. t.href = t.href.replace('://','://rsload.net:rsload.net@');
  1526. }
  1527. }
  1528. };
  1529.  
  1530. scripts['tapochek.net'] = {
  1531. 'now': preventPopups
  1532. }
  1533.  
  1534. var domain = document.domain, name;
  1535. while (domain.indexOf('.') !== -1) {
  1536. if (scripts.hasOwnProperty(domain)) {
  1537. if (typeof scripts[domain] === 'function') {
  1538. document.addEventListener ('DOMContentLoaded', scripts[domain], false);
  1539. }
  1540. for (name in scripts[domain]) {
  1541. if (name !== 'now') {
  1542. (name === 'load' ? window : document)
  1543. .addEventListener (name, scripts[domain][name], false);
  1544. } else {
  1545. scripts[domain][name]();
  1546. }
  1547. }
  1548. }
  1549. domain = domain.slice(domain.indexOf('.') + 1);
  1550. }
  1551. })();