RU AdList JS Fixes

try to take over the world!

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

  1. // ==UserScript==
  2. // @name RU AdList JS Fixes
  3. // @namespace ruadlist_js_fixes
  4. // @version 1.0.22
  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. inIFrame = function() {
  17. try {
  18. return win.self !== win.top;
  19. } catch (e) {
  20. return true;
  21. }
  22. };
  23.  
  24. if (!/firefox/i.test(navigator.userAgent)) { // scripts for non-Firefox browsers
  25.  
  26. // https://gf.qytechs.cn/scripts/19144-websuckit/
  27. (function() {
  28. // check if the browser supports Proxy and WebSocket
  29. if (typeof Proxy != 'function' || typeof WebSocket != 'function') return;
  30. var to_block = [
  31. '||bgrndi.com^',
  32. '||brokeloy.com^',
  33. '||dreadfula.ru^',
  34. '||et-code.ru^',
  35. '||gocdn.ru^',
  36. '||hghit.com^',
  37. '||kuveres.com^',
  38. '||lepubs.com^',
  39. '||mail.ru^',
  40. '||marketgid.com^',
  41. '||mxtads.com^',
  42. '||psma01.com^',
  43. '||psma02.com^',
  44. '||psma03.com^',
  45. '||recreativ.ru^',
  46. '||regpole.com^',
  47. '||torvind.com^',
  48. '||trafmag.com^',
  49. '||xxuhter.ru^'
  50. ], masks = [];
  51. to_block.forEach(function(m){
  52. masks.push(new RegExp(
  53. m.replace(/([\./*+?()[]{}$])/g, '\\$1')
  54. .replace(/\^(?!$)/g,'\\.?[^\\w%._-]')
  55. .replace(/\^$/,'(\\.?[^\\w%._-]|$)')
  56. .replace(/^\|\|/,'^wss?:\\/+([^/.]+\\.)*'),
  57. 'i'));
  58. });
  59. var ws = win.WebSocket;
  60. win.WebSocket = new Proxy(ws, {
  61. construct: function(e,i) {
  62. var url = i[0];
  63. console.log('[WSI] Opening socket on', url, '…');
  64. var j = masks.length;
  65. while(j--)
  66. if (masks[j].test(url)) {
  67. console.log("[WSI] Blocked.");
  68. return new Proxy({url: url, readyState: ws.OPEN}, {
  69. get: function(tgt, nm) {
  70. console.log('[WSI] Registered call to property "', nm, '"');
  71. try {
  72. if (typeof ws.prototype[nm] === 'function') {
  73. if (['close', 'send'].indexOf(nm) > -1)
  74. tgt.readyState = ws.CLOSED;
  75. return function(){};
  76. }
  77. if (typeof ws.prototype[nm] === 'number') {
  78. return ws[nm];
  79. }
  80. } catch(e) {}
  81. return tgt[nm];
  82. }
  83. });
  84. }
  85. return new e(i[0],i[1]);
  86. }
  87. });
  88. })();
  89.  
  90. // https://gf.qytechs.cn/scripts/14720-it-s-not-important
  91. (function(){
  92. var imptt = /((display|(margin|padding)(-top|-bottom)?)\s*:[^;!]*)!\s*important/ig,
  93. rplsf = function(str,grp){return grp;};
  94.  
  95. function unimportanter(el, si) {
  96. if (!imptt.test(si) || el.style.display == 'none')
  97. return 0; // get out if we have nothing to do here
  98. var so = si.replace(imptt, rplsf), ret = 0;
  99. if (si != so) {
  100. ret = 1;
  101. el.setAttribute('style', so);
  102. }
  103. return ret;
  104. }
  105.  
  106. function logger(c) {
  107. if (c) console.log('Some page elements became a bit less important.');
  108. }
  109.  
  110. function checkTarget(m, c) {
  111. var si = m.getAttribute ? m.getAttribute('style') : null;
  112. if (si && si.indexOf('!') > -1)
  113. c+=unimportanter(m, si);
  114. return c;
  115. }
  116.  
  117. function checkNodes(m, c) {
  118. var i = m.length;
  119. while(i--)
  120. c = checkTarget(m[i], c);
  121. return c;
  122. }
  123.  
  124. var observer = new MutationObserver(function(mutations) {
  125. setTimeout(function(m) {
  126. var i = m.length, c = 0;
  127. while(i--) {
  128. if (m[i].target)
  129. c = checkTarget(m[i].target, c);
  130. if (m[i].addedNodes.length)
  131. c = checkNodes(m[i].addedNodes, c);
  132. }
  133. logger(c);
  134. },0,mutations);
  135. });
  136.  
  137. observer.observe(document, { childList : true, attributes : true, attributeFilter : ['style'], subtree : true });
  138.  
  139. win.addEventListener ("load", function(){
  140. var c = 0, imp = document.querySelectorAll('[style*="!"]'), i = imp.length;
  141. while(i--) {
  142. c+= checkTarget(imp[i], c);
  143. }
  144. logger(c);
  145. }, false);
  146. })();
  147.  
  148. }
  149.  
  150. // https://gf.qytechs.cn/en/scripts/21937-moonwalk-hdgo-kodik-fix
  151. (function () {
  152. if (!inIFrame)
  153. return;
  154.  
  155. document.addEventListener ("DOMContentLoaded", function() {
  156. var player;
  157. if (win.condition_detected !== undefined) {
  158. win.request_host_id = "19804";
  159. player = document.getElementById('player');
  160. if (player) player.onclick = function() {
  161. win.showVideo();
  162. };
  163. } else if (win.banner_second !== undefined) {
  164. win.banner_second = 0;
  165. player = document.getElementById('MT_overroll');
  166. if (player) player.onclick = function() {
  167. var adsdiv = document.getElementById("ads-player-hd");
  168. adsdiv.parentNode.removeChild(adsdiv);
  169. win.setPlayer();
  170. };
  171. } else if (win.MXoverrollCallback !== undefined) {
  172. player = document.getElementsByClassName('play_button')[0];
  173. if (player) player.onclick = function() {
  174. win.MXoverrollCallback();
  175. };
  176. }
  177. },false);
  178. })();
  179.  
  180. if (/^https?:\/\/(news\.yandex\.|(www\.)?yandex\.[^/]+\/(yand)?search[/?])/i.test(win.location.href))
  181. // https://gf.qytechs.cn/en/scripts/809-no-yandex-ads
  182. document.addEventListener ("DOMContentLoaded", function() {
  183. // Generic ads removal and fixes
  184. (function(s){
  185. if (s) s.style.marginTop='0';
  186. })(document.querySelector('.serp-header'));
  187. (function(s, i){
  188. i = s.length;
  189. while(i--)
  190. s[i].parentNode.removeChild(s[i]);
  191. })(document.querySelectorAll('.serp-adv__head + .serp-item'), 0);
  192. (function(s){
  193. for (var l = 0; l < s.length; l++) s[l].parentNode.removeChild(s[l]);
  194. })(document.querySelectorAll(['#adbanner',
  195. '.serp-adv',
  196. '.b-spec-adv',
  197. 'div[class*="serp-adv__"]'].join(',')));
  198.  
  199. // Search ads
  200. var removeAds = function() {
  201. var s = document.querySelectorAll(['.serp-block',
  202. '.serp-item',
  203. '.search-item'].join(','));
  204. for (var l = 0; l < s.length; l++) {
  205. var i = s[l].querySelector(['.label',
  206. '.serp-item__label',
  207. '.document__provider-name'].join(','));
  208. if (!i) continue;
  209. if (i.textContent.indexOf('Реклама') > -1 || i.textContent.indexOf('Яндекс.Директ') > -1){
  210. s[l].parentNode.removeChild(s[l]);
  211. console.log('Ads removed.');
  212. }
  213. }
  214. };
  215.  
  216. // News ads
  217. var removeNewsAds = function() {
  218. var s = document.querySelectorAll(['.story[id]',
  219. '.document[id]',
  220. '.story__group[id]'].join(','));
  221. for (var l = 0; l < s.length; l++)
  222. if (win.getComputedStyle(s[l]).position === 'absolute') {
  223. s[l].parentNode.removeChild(s[l]);
  224. console.log('Ads removed.');
  225. }
  226. };
  227. // News fixes
  228. var removePageAdsClass = function() {
  229. if (document.body.classList.contains("b-page_ads_yes")){
  230. document.body.classList.remove("b-page_ads_yes");
  231. console.log('Page ads class removed.');
  232. }
  233. };
  234.  
  235. // Attaches observer to the page elements which Yandex updates via AJAX to display new search or news results
  236. var pageUpdateObserver = function(func, obj, params) {
  237. if (obj)
  238. new MutationObserver(func).observe(obj,(params?params:{childList:true}));
  239. };
  240.  
  241. if (win.location.hostname.search(/^news\./i) === 0) {
  242. pageUpdateObserver(removeNewsAds, document.querySelector('BODY'));
  243. pageUpdateObserver(removePageAdsClass, document.body, {attributes:true, attributesFilter:['class']});
  244. removeNewsAds();
  245. removePageAdsClass();
  246. } else {
  247. pageUpdateObserver(removeAds, document.querySelector('.main__content'));
  248. removeAds();
  249. }
  250. });
  251. else
  252. // all the other cases
  253. document.addEventListener ("DOMContentLoaded", function() {
  254. // function to search and remove nodes by conten
  255. // selector - standard CSS selector to define set of nodes to check
  256. // words - regular expression to check content of the suspicious nodes
  257. // params - object with multiple extra parameters:
  258. // .parent - parent node to remove if content is found in the child node
  259. // .siblings - number of simling nodes to remove (excluding text nodes)
  260. function scissors (selector, words, scope, params) {
  261. var nodes = scope.querySelectorAll(selector),
  262. i = nodes.length,
  263. toRemove = [];
  264.  
  265. while (i--)
  266. if (words.test(nodes[i].innerHTML) || !nodes[i].childNodes.length) {
  267. var node = nodes[i],
  268. siblings = Math.abs(params.siblings) || 0,
  269. iterFunc = params.siblings > 0 ? 'nextSibling' : 'previousSibling';
  270. // drill up to the specified parent node if required
  271. if (params.parent)
  272. while(node !== scope &&
  273. node.tagName.toLowerCase() !== params.parent)
  274. node = node.parentNode;
  275. if (node === scope)
  276. break;
  277. toRemove.push(node);
  278. // add multiple nodes if defined more than one sibling
  279. while (siblings) {
  280. node = node[iterFunc];
  281. toRemove.push(node);
  282. if (node.tagName) siblings--; //don't count text nodes
  283. }
  284. }
  285. i = toRemove.length;
  286. while(i--)
  287. toRemove[i].parentNode.removeChild(toRemove[i]);
  288.  
  289. return toRemove.length;
  290. }
  291.  
  292. // function to perform multiple checks if ads inserted with a delay
  293. // by default does 30 checks withing a 3 seconds unless nonstop mode specified
  294. // also does 1 extra check when a page completely loads
  295. // selector and words - passed dow to scissors
  296. // params - object with multiple extra parameters:
  297. // .root - selector to narrow down scope to scan;
  298. // .observe - if true then check will be performed continuously;
  299. // .parent - passed down to scissors;
  300. // .siblings - passed down to scissors;
  301. function gardener(selector, words, params) {
  302. params = params || {};
  303. var scope = document.body,
  304. nonstop = false;
  305. // narrow dowsn scope to a specific element
  306. if (params.root) {
  307. scope = scope.querySelector(params.root);
  308. if (!scope) // exit if the root element is not present on the page
  309. return 0;
  310. }
  311. // add observe mode if required
  312. if (params.observe) {
  313. if (typeof MutationObserver == 'function') {
  314. var o = new MutationObserver(function(ms){
  315. ms.forEach(function(m){
  316. if (m.addedNodes.length)
  317. scissors(selector, words, scope, params);
  318. });
  319. });
  320. o.observe(document.querySelector(params.root),
  321. {childList:true, subtree: true});
  322. } else nonstop = true;
  323. }
  324. // wait for a full page load to do one extra cut
  325. win.addEventListener('load',function(){
  326. scissors(selector, words, scope, params);
  327. });
  328. // do multiple cuts until ads removed
  329. function cut(sci, s, w, sc, p, i) {
  330. if (i > 0) i--;
  331. if (i && !sci(s, w, sc, p))
  332. setTimeout(cut, 100, sci, s, w, sc, p, i);
  333. }
  334. cut(scissors, selector, words, scope, params, (nonstop ? -1 : 30));
  335. }
  336.  
  337. function preventBackgroundRedirect() {
  338. console.log("Background redirect prevention enabled.");
  339. var orgOpen = window.open;
  340. win.open = function(){
  341. var loc = arguments[0];
  342. if (loc.indexOf(window.location.host) > -1 ||
  343. loc.indexOf('://') == -1) {
  344. window.addEventListener('unload',function(e){
  345. window.close();
  346. },true);
  347. }
  348. orgOpen.apply(window, arguments);
  349. };
  350. }
  351.  
  352. var scripts = {};
  353. scripts['fs.to'] = function() {
  354. function skipClicker(i) {
  355. if (!i) return;
  356. var skip = document.querySelector('.b-aplayer-banners__close');
  357. if (skip)
  358. skip.click();
  359. else
  360. setTimeout(skipClicker, 100, i-1);
  361. }
  362. setTimeout(skipClicker, 100, 30);
  363.  
  364. var divs = document.getElementsByTagName('div');
  365. var re = /\w{1,5}\d{1,5}\w{1,5}\d{1,5}/;
  366. for(var i = 0; i < divs.length; i++)
  367. if(re.test(divs[i].className))
  368. divs[i].style.display = 'none';
  369.  
  370. var style = document.head.appendChild( document.createElement('style') );
  371. style.type = 'text/css';
  372.  
  373. style.sheet.insertRule([
  374. '.b-aplayer-teasers > a',
  375. '.b-player-popup__content > div[class][style="position: relative;"]',
  376. 'div[class^="b-adproxy"]',
  377. 'div[id^="admixer_async_"]'
  378. ].join(',')+'{display:none!important}', 0);
  379.  
  380. if (/\/view_iframe\//i.test(document.location.pathname)) {
  381. var p = document.querySelector('#player:not([preload="auto"])'),
  382. m = document.querySelector('.main'),
  383. adStepper = function(p) {
  384. if (p.currentTime < p.duration)
  385. p.currentTime++;
  386. },
  387. adSkipper = function(f, p) {
  388. f.click();
  389. p.waitAfterSkip = false;
  390. console.log('Пропущена.');
  391. },
  392. cl = function(p) {
  393. var faster = document.querySelector('.b-aplayer__html5-desktop-skip');
  394.  
  395. function skipListener() {
  396. if (p.waitAfterSkip) {
  397. console.log('Доступен быстрый пропуск рекламы…');
  398. return;
  399. }
  400. p.pause();
  401. if (!p.classList.contains('m-hidden'))
  402. p.classList.add('m-hidden');
  403. if (faster &&
  404. window.getComputedStyle(faster).display == 'block' &&
  405. !faster.querySelector('.b-aplayer__html5-desktop-skip-timer')) {
  406. p.waitAfterSkip = true;
  407. setTimeout(adSkipper, 1000, faster, p);
  408. } else
  409. setTimeout(adStepper, 1000, p);
  410. }
  411.  
  412. p.addEventListener('timeupdate', skipListener, false);
  413. },
  414. o = new MutationObserver(function (mut) {
  415. mut.forEach(function (e) {
  416. for (var i = 0; i < e.addedNodes.length; i++) {
  417. if (e.addedNodes[i].id === 'player' &&
  418. e.addedNodes[i].nodeName === 'VIDEO' &&
  419. e.addedNodes[i].getAttribute('preload') != 'auto') {
  420. cl(e.addedNodes[i]);
  421. }
  422. }
  423. });
  424. });
  425. if (p.nodeName === 'VIDEO')
  426. cl(p);
  427. else
  428. o.observe(m, {childList: true});
  429. }
  430. };
  431. scripts['brb.to'] = scripts['fs.to'];
  432. scripts['cxz.to'] = scripts['fs.to'];
  433.  
  434. scripts['drive2.ru'] = function() {
  435. gardener('.g-column-wide > .c-block', /Реклама|\.relap\./i);
  436. };
  437.  
  438. scripts['pikabu.ru'] = function() {
  439. gardener('.story', /story__sponsor|profile\/ads"/i, {root:'.stories,.page-story', observe: true});
  440. };
  441.  
  442. scripts['fishki.net'] = function() {
  443. gardener('.main-post', /543769|Реклама/);
  444. };
  445.  
  446. scripts['hdrezka.me'] = function() {
  447. gardener('div[id][onclick][onmouseup][onmousedown]', /onmouseout/i);
  448. };
  449.  
  450. scripts['rustorka.com'] = function() {
  451. var s = document.head.childNodes, i = s.length;
  452. if (i < 5)
  453. while(i--)
  454. if (s[i].httpEquiv && s[i].httpEquiv=='refresh')
  455. window.close();
  456. gardener('a[href$="php"]', /\/\d{12,}\.php/i);
  457. gardener('div[id][style*="!important"]', /!important/i);
  458. };
  459.  
  460. scripts['yap.ru'] = function() {
  461. var words = /member1438|Administration/;
  462. gardener('form > table[id^="p_row_"]', words);
  463. gardener('tr > .holder.newsbottom', words, {parent:'tr', siblings:-2});
  464. };
  465. scripts['yaplakal.com'] = scripts['yap.ru'];
  466.  
  467. scripts['reactor.cc'] = preventBackgroundRedirect;
  468. scripts['joyreactor.cc'] = preventBackgroundRedirect;
  469. scripts['pornreactor.cc'] = preventBackgroundRedirect;
  470.  
  471. scripts['auto.ru'] = function() {
  472. var words = /Реклама|Яндекс.Директ|yandex_ad_/;
  473. var userAdsListAds = [
  474. '.listing-list > .listing-item',
  475. '.listing-item_type_fixed.listing-item'
  476. ];
  477. var catalogAds = [
  478. 'div[class*="layout_catalog-inline"]',
  479. 'div[class$="layout_horizontal"]'
  480. ];
  481. var otherAds = [
  482. '.advt_auto',
  483. '.sidebar-block',
  484. '.pager-listing + div[class]',
  485. '.card > div[class][style]',
  486. '.sidebar > div[class]',
  487. '.main-page__section + div[class]',
  488. '.listing > tbody'];
  489. gardener(userAdsListAds.join(','), words, {root:'.listing-wrap', observe:true});
  490. gardener(catalogAds.join(','), words, {root:'.catalog__page,.content__wrapper', observe:true});
  491. gardener(otherAds.join(','), words);
  492. };
  493.  
  494. scripts['online.anidub.com'] = function() {
  495. var script = document.createElement('script');
  496. script.type = "text/javascript";
  497. script.innerHTML = "function ogonekstart1() {}";
  498. document.getElementsByTagName('head')[0].appendChild(script);
  499.  
  500. var style = document.createElement('style');
  501. style.type = 'text/css';
  502. style.appendChild(document.createTextNode('.background {background: none!important;}'));
  503. style.appendChild(document.createTextNode('.background > script + div, .background > script ~ div:not([id]):not([class]) + div[id][class] {display:none!important}'));
  504. document.head.appendChild(style);
  505. };
  506.  
  507. scripts['rsload.net'] = function() {
  508. window.addEventListener('load', function() {
  509. var dis = document.querySelector('.cb-disable');
  510. if (dis) dis.click();
  511. });
  512. document.addEventListener('click',function(e){
  513. var t = e.target;
  514. if (t && t.href && /:\/\/\d+\.\d+\.\d+\.\d+\//.test(t.href)) {
  515. t.href = t.href.replace('://','://rsload.net:rsload.net@');
  516. }
  517. });
  518. };
  519.  
  520. var domain = document.domain;
  521. while (domain.indexOf('.') + 1) {
  522. if (domain in scripts) {
  523. scripts[domain]();
  524. break;
  525. }
  526. domain = domain.slice(domain.indexOf('.') + 1);
  527. }
  528. });
  529. })();

QingJ © 2025

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