RU AdList JS Fixes

try to take over the world!

当前为 2016-05-26 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name RU AdList JS Fixes
  3. // @namespace ruadlist_js_fixes
  4. // @version 0.1
  5. // @description try to take over the world!
  6. // @author lainverse & dimisa
  7. // @match *://*/*
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11. (function() {
  12. 'use strict';
  13.  
  14. var qSelect = document.querySelector,
  15. qSelectAll = document.querySelectorAll,
  16. nRemove = function(node) {
  17. node.parentNode.removeChild(node);
  18. },
  19. scissors = function(selector, words) {
  20. var nodes = document.querySelectorAll(selector),
  21. i = nodes.length,
  22. ret = false;
  23. while (i--)
  24. if (words.test(nodes[i].innerHTML)) {
  25. nodes[i].parentNode.removeChild(nodes[i]);
  26. ret = true;
  27. }
  28. return ret;
  29. };
  30.  
  31. var scripts = {};
  32. scripts['fs.to'] = function() {
  33. var divs = document.getElementsByTagName('div');
  34. var re = /\w{1,5}\d{1,5}\w{1,5}\d{1,5}/;
  35. for(var i = 0; i < divs.length; i++)
  36. if(re.test(divs[i].className))
  37. divs[i].style.display = 'none';
  38.  
  39. var style = document.head.appendChild( document.createElement('style') );
  40. style.type = 'text/css';
  41.  
  42. style.sheet.insertRule(['.b-aplayer-teasers > a',
  43. '.b-player-popup__content > div[class][style="position: relative;"]',
  44. 'div[class^="b-adproxy"]',
  45. 'div[id^="admixer_async_"]'
  46. ].join(',')+'{display:none!important}', 0);
  47.  
  48. if (/\/view_iframe\//i.test(document.location.pathname)) {
  49. var p = qSelect('#player:not([preload="auto"])'),
  50. m = qSelect('.main'),
  51. adStepper = function(p) {
  52. if (p.currentTime < p.duration)
  53. p.currentTime++;
  54. },
  55. cl = function(p) {
  56. function skipListener() {
  57. p.pause();
  58. p.classList.add('m-hidden');
  59. setTimeout(adStepper, 1000, p);
  60. }
  61. p.addEventListener('timeupdate', skipListener, false);
  62. },
  63. o = new MutationObserver(function (mut) {
  64. mut.forEach(function (e) {
  65. for (var i = 0; i < e.addedNodes.length; i++) {
  66. if (e.addedNodes[i].id === 'player' &&
  67. e.addedNodes[i].nodeName === 'VIDEO' &&
  68. e.addedNodes[i].getAttribute('preload') != 'auto') {
  69. cl(e.addedNodes[i]);
  70. }
  71. }
  72. });
  73. });
  74. if (p.nodeName === 'VIDEO')
  75. cl(p);
  76. else
  77. o.observe(m, {childList: true});
  78. }
  79. };
  80. scripts['brb.to'] = scripts['fs.to'];
  81. scripts['cxz.to'] = scripts['fs.to'];
  82.  
  83. scripts['fishki.net'] = function() {
  84. scissors('.main-post', /543769|Реклама/);
  85. };
  86.  
  87. scripts['yap.ru'] = function() {
  88. var words = /member1438|Administration/;
  89. scissors('form > table[id^="p_row_"]', words);
  90. var b = qSelectAll('tr > .holder.newsbottom');
  91. for (var i=0;i<b.length;i++)
  92. if (words.test(b[i].innerHTML)){
  93. var row = b[i].parentNode.rowIndex;
  94. var table = b[i].parentNode.parentNode;
  95. table.deleteRow(row);
  96. table.deleteRow(row-1);
  97. table.deleteRow(row-2);
  98. }
  99. };
  100. scripts['yaplakal.com'] = scripts['yap.ru'];
  101.  
  102. scripts['auto.ru'] = function() {
  103. function check1(sci, i) {
  104. if (i && !sci('.listing-list > .listing-item, .listing-item_type_fixed.listing-item, div[class*="layout_catalog-inline"], .listing > tbody', /Реклама/))
  105. setTimeout(check1, 100, sci, i-1);
  106. }
  107. function check2(sci, i) {
  108. if (i && !sci('.sidebar-block, .pager-listing + div[class], div[class$="layout_horizontal"], .card > div[class][style], .sidebar > div[class], .main-page__section + div[class]', /Яндекс\.Директ/))
  109. setTimeout(check2, 100, sci, i-1);
  110. }
  111. check1(scissors, 30);
  112. check2(scissors, 30);
  113. };
  114.  
  115. scripts['online.anidub.com'] = function() {
  116. var script = document.createElement('script');
  117. script.type = "text/javascript";
  118. script.innerHTML = "function ogonekstart1() {}";
  119. document.getElementsByTagName('head')[0].appendChild(script);
  120.  
  121. var style = document.createElement('style');
  122. style.type = 'text/css';
  123. style.appendChild(document.createTextNode('.background {background: none!important;}'));
  124. style.appendChild(document.createTextNode('.background > script + div, .background > script ~ div:not([id]):not([class]) + div[id][class] {display:none!important}'));
  125. document.head.appendChild(style);
  126. };
  127.  
  128. if (document.domain in scripts) {
  129. scripts[document.domain]();
  130. } else if ((document.domain.match(/\./g) || empty).length > 2) {
  131. var domainBlocks = document.domain.split('.'),
  132. i = domainBlocks.length - 2;
  133. while(i--) {
  134. var domain = domainBlocks.slice(-2-i).join('.');
  135. if (domain in scripts) {
  136. scripts[domain]();
  137. break;
  138. }
  139. }
  140. }
  141. })();