Greasy Fork 还支持 简体中文。

RU AdList JS Fixes

try to take over the world!

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

  1. // ==UserScript==
  2. // @name RU AdList JS Fixes
  3. // @namespace ruadlist_js_fixes
  4. // @version 1.3.3
  5. // @description try to take over the world!
  6. // @author lainverse & dimisa
  7. // @match *://*/*
  8. // @grant unsafeWindow
  9. // @grant window.close
  10. // @grant GM_addStyle
  11. // @run-at document-start
  12. // ==/UserScript==
  13.  
  14. (function() {
  15. 'use strict';
  16. var win = unsafeWindow || window;
  17. function inIFrame() {
  18. try {
  19. return win.self !== win.top;
  20. } catch (ignore) {
  21. return true;
  22. }
  23. }
  24.  
  25. // https://greasyfork.org/scripts/19144-websuckit/
  26. (function() {
  27. function WebSocketWrapper() {
  28. // check if the browser supports Proxy and WebSocket
  29. if (typeof Proxy !== 'function' ||
  30. typeof WebSocket !== 'function') {
  31. return;
  32. }
  33. var to_block = [
  34. '||adlabs.ru',
  35. '||bgrndi.com^',
  36. '||brokeloy.com^',
  37. '||dreadfula.ru^',
  38. '||et-code.ru^',
  39. '||free-torrent.org^',
  40. '||free-torrent.pw^',
  41. '||free-torrents.org^',
  42. '||free-torrents.pw^',
  43. '||game-torrent.info^',
  44. '||gocdn.ru^',
  45. '||hghit.com^',
  46. '||kinotochka.net^',
  47. '||kuveres.com^',
  48. '||lepubs.com^',
  49. '||luxup.ru^',
  50. '||mail.ru^',
  51. '||marketgid.com^',
  52. '||mxtads.com^',
  53. '||oconner.biz^',
  54. '||poolnoodle.tech',
  55. '||psma01.com^',
  56. '||psma02.com^',
  57. '||psma03.com^',
  58. '||recreativ.ru^',
  59. '||regpole.com^',
  60. '||skidl.ru^',
  61. '||torvind.com^',
  62. '||trafmag.com^',
  63. '||xxuhter.ru^',
  64. '||yuiout.online^'
  65. ];
  66. var masks = [];
  67. to_block.forEach(function(m){
  68. masks.push(new RegExp(
  69. m.replace(/([\\\/\[\].*+?(){}$])/g, '\\$1')
  70. .replace(/\^(?!$)/g,'\\.?[^\\w%._-]')
  71. .replace(/\^$/,'\\.?([^\\w%._-]|$)')
  72. .replace(/^\|\|/,'^wss?:\\/+([^\/.]+\\.)*'),
  73. 'i'));
  74. });
  75. var realWS = win.WebSocket,
  76. closingFunctions = ['close', 'send'];
  77. function wsGetter(tgt, nm) {
  78. console.log('[WSI] Registered call to property "', nm, '"');
  79. try {
  80. if (typeof realWS.prototype[nm] === 'function') {
  81. if (closingFunctions.indexOf(nm) > -1) {
  82. tgt.readyState = realWS.CLOSED;
  83. }
  84. return function(){return;};
  85. }
  86. if (typeof realWS.prototype[nm] === 'number') {
  87. return realWS[nm];
  88. }
  89. } catch(ignore) {}
  90. return tgt[nm];
  91. }
  92. win.WebSocket = (new Proxy(realWS, {
  93. construct: function(target, args) {
  94. var url = args[0];
  95. console.log('[WSI] Opening socket on', url, '…');
  96. var i = masks.length;
  97. while(i--) {
  98. if (masks[i].test(url)) {
  99. console.log("[WSI] Blocked.");
  100. return new Proxy({url: url, readyState: realWS.OPEN}, {
  101. get: wsGetter
  102. });
  103. }
  104. }
  105. return new target(args[0], args[1]);
  106. }
  107. }));
  108. }
  109.  
  110. function WorkerWrapper(){
  111. var wr = win.Worker;
  112. win.Worker = function(resourceURI) {
  113. var _promise = new Promise(function(resolve,reject){
  114. var xhr = new XMLHttpRequest();
  115. xhr.open('GET', resourceURI, true);
  116. xhr.responseType = 'blob';
  117. xhr.onload = function(){
  118. if (this.status == 200) {
  119. var reader = new FileReader();
  120. reader.addEventListener("loadend", function() {
  121. resolve(
  122. new wr(
  123. URL.createObjectURL(
  124. new Blob(['(function(){var win = self;'+
  125. WebSocketWrapper.toString()+
  126. ' WebSocketWrapper();})();'+this.result])
  127. )
  128. )
  129. );
  130. });
  131. reader.readAsText(this.response);
  132. }
  133. };
  134. xhr.send();
  135. });
  136. var _worker = null,
  137. _terminate = false,
  138. _onerror = null,
  139. _onmessage = null,
  140. _messages = [],
  141. _events = [];
  142. var setWorker = function(val) {
  143. _worker = val;
  144. _worker.onerror = _onerror;
  145. _worker.onmessage = _onmessage;
  146. if (_terminate) {
  147. _worker.terminate();
  148. }
  149. while(_messages.length) {
  150. _worker.postMessage(_messages.shift());
  151. }
  152. while(_events.length) {
  153. _worker.addEventListener.apply(_worker, _events.pop());
  154. }
  155. };
  156. _promise.then(setWorker);
  157. this.terminate = function(){
  158. _terminate = true;
  159. if (_worker) {
  160. _worker.terminate();
  161. }
  162. };
  163. Object.defineProperty(this, 'onmessage', {
  164. get:function(){
  165. return _onmessage;
  166. },
  167. set:function(val){
  168. _onmessage = val;
  169. if (_worker) {
  170. _worker.onmessage = val;
  171. }
  172. }
  173. });
  174. Object.defineProperty(this, 'onerror', {
  175. get:function(){
  176. return _onerror;
  177. },
  178. set:function(val){
  179. _onerror = val;
  180. if (_worker) {
  181. _worker.onmessage = val;
  182. }
  183. }
  184. });
  185. this.postMessage = function(message){
  186. if (_worker) {
  187. _worker.postMessage(message);
  188. } else {
  189. _messages.push(message);
  190. }
  191. };
  192. this.terminate = function() {
  193. _terminate = true;
  194. if (_worker) {
  195. _worker.terminate();
  196. }
  197. };
  198. this.addEventListener = function(){
  199. if (_worker) {
  200. _worker.addEventListener.apply(_worker, arguments);
  201. } else {
  202. _events.push(arguments);
  203. }
  204. };
  205. this.removeEventListener = function(){
  206. if (_worker) {
  207. _worker.removeEventListener.apply(_worker, arguments);
  208. } // I don't think I should care to remove events here,
  209. // normally it shouldn't be invoked before _worker is created
  210. };
  211. };
  212.  
  213. }
  214.  
  215. if (/firefox/i.test(navigator.userAgent)) {
  216. var script = document.createElement('script');
  217. var WSIstr = '(function(){var win = self||window;'+
  218. WebSocketWrapper.toString() +
  219. WorkerWrapper.toString() +
  220. 'WebSocketWrapper();WorkerWrapper();})();';
  221. script.appendChild(
  222. document.createTextNode(WSIstr + 'if (document.currentScript) {'+
  223. 'document.currentScript.parentNode.removeChild(document.currentScript);'+
  224. '}')
  225. );
  226. (document.head || document.body || document.documentElement).appendChild(script);
  227. return; //exit
  228. }
  229.  
  230. WebSocketWrapper();
  231. WorkerWrapper();
  232. })();
  233.  
  234. if (!(/firefox/i.test(navigator.userAgent))) { // scripts for non-Firefox browsers
  235.  
  236. // https://greasyfork.org/scripts/14720-it-s-not-important
  237. (function(){
  238. var imptt = /((display|(margin|padding)(-top|-bottom)?)\s*:[^;!]*)!\s*important/ig;
  239.  
  240. function unimportanter(el, si) {
  241. if (!imptt.test(si) || el.style.display === 'none') {
  242. return 0; // get out if we have nothing to do here
  243. }
  244. if (el.nodeName === 'IFRAME' && el.src &&
  245. el.src.slice(0,17) === 'chrome-extension:') {
  246. return 0; // Web of Trust uses this method to add their frame
  247. }
  248. var so = si.replace(imptt, function(){return arguments[1];}), ret = 0;
  249. if (si !== so) {
  250. ret = 1;
  251. el.setAttribute('style', so);
  252. }
  253. return ret;
  254. }
  255.  
  256. function logger(c) {
  257. if (c) {
  258. console.log('Some page elements became a bit less important.');
  259. }
  260. }
  261.  
  262. function checkTarget(m, c) {
  263. var si = m.getAttribute ? m.getAttribute('style') : null;
  264. if (si && si.indexOf('!') > -1) {
  265. c += unimportanter(m, si);
  266. }
  267. return c;
  268. }
  269.  
  270. function checkNodes(m, c) {
  271. var i = m.length;
  272. while(i--) {
  273. c = checkTarget(m[i], c);
  274. }
  275. return c;
  276. }
  277.  
  278. var observer = new MutationObserver(function(mutations) {
  279. setTimeout(function(m) {
  280. var i = m.length, c = 0;
  281. while(i--) {
  282. if (m[i].target) {
  283. c = checkTarget(m[i].target, c);
  284. }
  285. if (m[i].addedNodes.length) {
  286. c = checkNodes(m[i].addedNodes, c);
  287. }
  288. }
  289. logger(c);
  290. },0,mutations);
  291. });
  292.  
  293. observer.observe(document, { childList : true, attributes : true, attributeFilter : ['style'], subtree : true });
  294.  
  295. win.addEventListener ("load", function(){
  296. var c = 0, imp = document.querySelectorAll('[style*="!"]'), i = imp.length;
  297. while(i--) {
  298. c+= checkTarget(imp[i], c);
  299. }
  300. logger(c);
  301. }, false);
  302. })();
  303.  
  304. }
  305.  
  306. if (/^https?:\/\/(news\.yandex\.|(www\.)?yandex\.[^\/]+\/(yand)?search[\/?])/i.test(win.location.href)) {
  307. // https://greasyfork.org/en/scripts/809-no-yandex-ads
  308. (function(){
  309. var adWords = ['Яндекс.Директ','Реклама','Ad'];
  310. function remove(node) {
  311. node.parentNode.removeChild(node);
  312. }
  313. // Generic ads removal and fixes
  314. function removeGenericAds() {
  315. var s, i;
  316. s = document.querySelector('.serp-header');
  317. if (s) {
  318. s.style.marginTop='0';
  319. }
  320. s = document.querySelectorAll('.serp-adv__head + .serp-item');
  321. i = s.length;
  322. while(i--) {
  323. s[i].parentNode.removeChild(s[i]);
  324. }
  325. s = document.querySelectorAll('#adbanner, .serp-adv, .b-spec-adv, div[class*="serp-adv__"]');
  326. i = s.length;
  327. while(i--) {
  328. remove(s[i]);
  329. }
  330. }
  331. // Search ads
  332. function removeSearchAds() {
  333. var s = document.querySelectorAll('.serp-block, .serp-item, .search-item');
  334. var i = s.length, item;
  335. while(i--) {
  336. item = s[i].querySelector('.label, .serp-item__label, .document__provider-name');
  337. if (item && adWords.indexOf(item.textContent) > -1) {
  338. remove(s[i]);
  339. console.log('Ads removed.');
  340. }
  341. }
  342. }
  343. // News ads
  344. function removeNewsAds() {
  345. var s = document.querySelectorAll('.page-content__left > *,.page-content__right > *:not(.page-content__col),.page-content__right > .page-content__col > *');
  346. var i = s.length;
  347. while(i--) {
  348. if (s[i].textContent.indexOf(adWords[0]) > -1) {
  349. remove(s[i]);
  350. console.log('Ads removed.');
  351. }
  352. }
  353. }
  354. // News fixes
  355. function removePageAdsClass() {
  356. if (document.body.classList.contains("b-page_ads_yes")){
  357. document.body.classList.remove("b-page_ads_yes");
  358. console.log('Page ads class removed.');
  359. }
  360. }
  361. // Function to attach an observer to monitor dynamic changes on the page
  362. function pageUpdateObserver(func, obj, params) {
  363. if (obj) {
  364. var o = new MutationObserver(func);
  365. o.observe(obj,(params || {childList:true, subtree:true}));
  366. }
  367. }
  368. // Cleaner
  369. document.addEventListener ("DOMContentLoaded", function() {
  370. removeGenericAds();
  371. if (win.location.hostname.search(/^news\./i) === 0) {
  372. pageUpdateObserver(removeNewsAds, document.querySelector('BODY'));
  373. pageUpdateObserver(removePageAdsClass, document.body, {attributes:true, attributesFilter:['class']});
  374. removeNewsAds();
  375. removePageAdsClass();
  376. } else {
  377. pageUpdateObserver(removeSearchAds, document.querySelector('.main__content'));
  378. removeSearchAds();
  379. }
  380. });
  381. })();
  382. return; //skip fixes for other sites
  383. }
  384.  
  385. // https://greasyfork.org/en/scripts/14470-4pda-unbrender
  386. if (/(^|\.)4pda\.ru$/i.test(window.location.hostname)) {
  387. (function(){
  388. var isForum = document.location.href.search('/forum/') !== -1,
  389. isSafari = (/Safari/i.test(navigator.userAgent)) && (/Apple\sComputer/i.test(navigator.vendor)),
  390. hStyle;
  391.  
  392. function remove(n) {
  393. if (n) {
  394. n.parentNode.removeChild(n);
  395. }
  396. }
  397.  
  398. function afterClean() {
  399. hStyle.disabled = true;
  400. remove(hStyle);
  401. }
  402.  
  403. function beforeClean() {
  404. // attach styles before document displayed
  405. hStyle = document.createElement('style');
  406. hStyle.id = 'ubrHider';
  407. hStyle.type = 'text/css';
  408. document.head.appendChild(hStyle);
  409.  
  410. hStyle.sheet.insertRule('html { overflow-y: scroll }', 0);
  411. hStyle.sheet.insertRule('article + aside * { display: none !important }', 0);
  412. hStyle.sheet.insertRule('#header + div:after {'+(
  413. 'content: "";'+
  414. 'position: fixed;'+
  415. 'top: 0;'+
  416. 'left: 0;'+
  417. 'width: 100%;'+
  418. 'height: 100%;'+
  419. 'background-color: #E6E7E9'
  420. )+'}', 0);
  421. // http://codepen.io/Beaugust/pen/DByiE
  422. hStyle.sheet.insertRule('@keyframes spin { 100% { transform: rotate(360deg) } }', 0);
  423. hStyle.sheet.insertRule('article + aside:after {'+(
  424. 'content: "";'+
  425. 'position: absolute;'+
  426. 'width: 150px;'+
  427. 'height: 150px;'+
  428. 'top: 150px;'+
  429. 'left: 50%;'+
  430. 'margin-top: -75px;'+
  431. 'margin-left: -75px;'+
  432. 'box-sizing: border-box;'+
  433. 'border-radius: 100%;'+
  434. 'border: 10px solid rgba(0, 0, 0, 0.2);'+
  435. 'border-top-color: rgba(0, 0, 0, 0.6);'+
  436. 'animation: spin 2s infinite linear'
  437. )+'}', 0);
  438.  
  439. // display content of a page if time to load a page is more than 2 seconds to avoid
  440. // blocking access to a page if it is loading for too long or stuck in a loading state
  441. setTimeout(2000, afterClean);
  442. }
  443.  
  444. GM_addStyle('#nav .use-ad {display: block !important;} ' +
  445. 'article:not(.post) + article:not(#id) { display: none !important }');
  446. if (!isForum && !isSafari) {
  447. beforeClean();
  448. }
  449.  
  450. // clean the page
  451. window.addEventListener('DOMContentLoaded', function(){
  452. var rem, si, lst, i;
  453. function width(){ return window.innerWidth||document.documentElement.clientWidth||document.body.clientWidth||0; }
  454. function height(){ return window.innerHeight||document.documentElement.clientHeight||document.body.clientHeight||0; }
  455.  
  456.  
  457. if (isForum) {
  458. si = document.querySelector('#logostrip');
  459. if (si) {
  460. remove(si.parentNode.nextSibling);
  461. }
  462. }
  463.  
  464. if (document.location.href.search('/forum/dl/') !== -1) {
  465. lst = document.querySelectorAll('body>div');
  466. i = lst.length;
  467. document.body.setAttribute('style', (document.body.getAttribute('style')||'')+
  468. ';background-color:black!important');
  469. while (i--) {
  470. if (!lst[i].querySelector('.dw-fdwlink')) {
  471. remove(lst[i]);
  472. }
  473. }
  474. }
  475.  
  476. if (isForum) { // Do not continue if it's a forum
  477. return;
  478. }
  479.  
  480. si = document.querySelector('#header');
  481. if (si) {
  482. rem = si.previousSibling;
  483. while (rem) {
  484. si = rem.previousSibling;
  485. remove(rem);
  486. rem = si;
  487. }
  488. }
  489.  
  490. lst = document.querySelectorAll('#nav li[class]');
  491. i = lst.length;
  492. while (i--) {
  493. if (lst[i] && lst[i].querySelector('a[href^="/tag/"]')) {
  494. remove(lst[i]);
  495. }
  496. }
  497.  
  498. lst = document.querySelectorAll('DIV');
  499. i = lst.length;
  500. var style, result;
  501. while (i--) {
  502. if (lst[i].offsetWidth > 0.95 * width() && lst[i].offsetHeight > 0.9 * height()) {
  503. style = window.getComputedStyle(lst[i], null);
  504. result = [];
  505. if(style.backgroundImage !== 'none') {
  506. result.push('background-image:none!important');
  507. }
  508. if(style.backgroundColor !== 'transparent') {
  509. result.push('background-color:transparent!important');
  510. }
  511. if (result.length) {
  512. if (lst[i].getAttribute('style')) {
  513. result.unshift(lst[i].getAttribute('style'));
  514. }
  515. lst[i].setAttribute('style', result.join(';'));
  516. }
  517. }
  518. }
  519.  
  520. lst = document.querySelectorAll('ASIDE>DIV');
  521. i = lst.length;
  522. while (i--) {
  523. if ( ((lst[i].querySelector('script, iframe, a[href*="/ad/www/"]') ||
  524. lst[i].querySelector('img[src$=".gif"]:not([height="0"]), img[height="400"]')) &&
  525. !lst[i].classList.contains('post') ) || !lst[i].childNodes.length ) {
  526. remove(lst[i]);
  527. }
  528. }
  529.  
  530. document.body.setAttribute('style', (document.body.getAttribute('style')||'')+';background-color:#E6E7E9!important');
  531.  
  532. // display content of the page
  533. afterClean();
  534. });
  535. })();
  536. return;
  537. }
  538.  
  539. // https://greasyfork.org/en/scripts/21937-moonwalk-hdgo-kodik-fix
  540. (function () {
  541. if (!inIFrame) {
  542. return;
  543. }
  544.  
  545. document.addEventListener ("DOMContentLoaded", function() {
  546. var player;
  547. if (win.iframe_adv_enabled !== undefined) {
  548. win.iframe_adv_enabled = false;
  549. } else if (win.banner_second !== undefined) {
  550. win.banner_second = 0;
  551. player = document.getElementById('play-player-hd');
  552. if (player) {
  553. player.onclick = function() {
  554. var adsdiv = document.getElementById("ads-player-hd");
  555. adsdiv.parentNode.removeChild(adsdiv);
  556. win.setPlayer();
  557. };
  558. }
  559. } else if (win.MXoverrollCallback !== undefined) {
  560. player = document.getElementsByClassName('play_button')[0];
  561. if (player) {
  562. player.onclick = win.MXoverrollCallback.bind(window);
  563. }
  564. }
  565. },false);
  566. })();
  567. // hdgo.cc/couber.be fix
  568. if (['couber.be','hdgo.cc','46.30.43.38'].indexOf(document.domain) > -1) {
  569. Object.defineProperty(win, 'canRunAds', {
  570. value: true,
  571. configurable: false,
  572. enumerable: false,
  573. writable: false
  574. });
  575. }
  576.  
  577. document.addEventListener ("DOMContentLoaded", function() {
  578. // function to search and remove nodes by content
  579. // selector - standard CSS selector to define set of nodes to check
  580. // words - regular expression to check content of the suspicious nodes
  581. // params - object with multiple extra parameters:
  582. // .hide - set display to none instead of removing from the page
  583. // .parent - parent node to remove if content is found in the child node
  584. // .siblings - number of simling nodes to remove (excluding text nodes)
  585. function scRemove(e) {e.parentNode.removeChild(e);}
  586. function scHide(e) {e.style.display='none';}
  587. function scissors (selector, words, scope, params) {
  588. var remFunc = (params.hide ? scHide : scRemove),
  589. iterFunc = (params.siblings > 0 ?
  590. 'nextSibling' :
  591. 'previousSibling'),
  592. nodes = scope.querySelectorAll(selector),
  593. i = nodes.length,
  594. toRemove = [],
  595. siblings,
  596. node;
  597. while(i--) {
  598. node = nodes[i];
  599. if (words.test(node.innerHTML) || !node.childNodes.length) {
  600. // drill up to the specified parent node if required
  601. if (params.parent) {
  602. while(node !== scope && !(node.matches(params.parent))) {
  603. node = node.parentNode;
  604. }
  605. }
  606. if (node === scope) {
  607. break;
  608. }
  609. toRemove.push(node);
  610. // add multiple nodes if defined more than one sibling
  611. siblings = Math.abs(params.siblings) || 0;
  612. while (siblings) {
  613. node = node[iterFunc];
  614. toRemove.push(node);
  615. if (node.nodeType === 1) {
  616. siblings -= 1; //count only element nodes
  617. }
  618. }
  619. }
  620. }
  621. i = toRemove.length;
  622. while(i--) {
  623. remFunc(toRemove[i]);
  624. }
  625.  
  626. return toRemove.length;
  627. }
  628.  
  629. // function to perform multiple checks if ads inserted with a delay
  630. // by default does 30 checks withing a 3 seconds unless nonstop mode specified
  631. // also does 1 extra check when a page completely loads
  632. // selector and words - passed dow to scissors
  633. // params - object with multiple extra parameters:
  634. // .root - selector to narrow down scope to scan;
  635. // .observe - if true then check will be performed continuously;
  636. // Other parameters passed down to scissors.
  637. function gardener(selector, words, params) {
  638. params = params || {};
  639. var scope = document.body,
  640. nonstop = false;
  641. // narrow down scope to a specific element
  642. if (params.root) {
  643. scope = scope.querySelector(params.root);
  644. if (!scope) {// exit if the root element is not present on the page
  645. return 0;
  646. }
  647. }
  648. // add observe mode if required
  649. if (params.observe) {
  650. if (typeof MutationObserver === 'function') {
  651. var o = new MutationObserver(function(ms){
  652. ms.forEach(function(m){
  653. if (m.addedNodes.length) {
  654. scissors(selector, words, scope, params);
  655. }
  656. });
  657. });
  658. o.observe(scope, {childList:true, subtree: true});
  659. } else {
  660. nonstop = true;
  661. }
  662. }
  663. // wait for a full page load to do one extra cut
  664. win.addEventListener('load',function(){
  665. scissors(selector, words, scope, params);
  666. });
  667. // do multiple cuts until ads removed
  668. function cut(sci, s, w, sc, p, i) {
  669. if (i > 0) {
  670. i -= 1;
  671. }
  672. if (i && !sci(s, w, sc, p)) {
  673. setTimeout(cut, 100, sci, s, w, sc, p, i);
  674. }
  675. }
  676. cut(scissors, selector, words, scope, params, (nonstop ? -1 : 30));
  677. }
  678.  
  679. function preventBackgroundRedirect() {
  680. console.log("Background redirect prevention enabled.");
  681. var orgOpen = win.open;
  682. win.open = function(){
  683. var loc = arguments[0];
  684. if (loc.indexOf(win.location.host) > -1 ||
  685. loc.indexOf('://') === -1) {
  686. win.addEventListener('unload',function(){
  687. win.close();
  688. }, true);
  689. }
  690. orgOpen.apply(window, arguments);
  691. };
  692. }
  693.  
  694. var scripts = {};
  695. scripts['fs.to'] = function() {
  696. function skipClicker(i) {
  697. if (!i) {
  698. return;
  699. }
  700. var skip = document.querySelector('.b-aplayer-banners__close');
  701. if (skip) {
  702. skip.click();
  703. } else {
  704. setTimeout(skipClicker, 100, i-1);
  705. }
  706. }
  707. setTimeout(skipClicker, 100, 30);
  708.  
  709. var divs = document.getElementsByTagName('div'),
  710. re = /^b-[a-z]+\d+[a-z\d]*$/,
  711. i = divs.length;
  712. while(i--) {
  713. if (re.test(divs[i].className)) {
  714. divs[i].style.display = 'none';
  715. }
  716. }
  717.  
  718. GM_addStyle('.b-aplayer-teasers > a, div[class^="b-adproxy"], div[id^="admixer_async_"],'+
  719. '.b-player-popup__content > div[class][style="position: relative;"]'+
  720. '{display:none!important}');
  721.  
  722. if (/\/(view_iframe|iframeplayer)\//i.test(document.location.pathname)) {
  723. var p = document.querySelector('#player:not([preload="auto"])'),
  724. m = document.querySelector('.main'),
  725. adStepper = function(p) {
  726. if (p.currentTime < p.duration) {
  727. p.currentTime += 1;
  728. }
  729. },
  730. adSkipper = function(f, p) {
  731. f.click();
  732. p.waitAfterSkip = false;
  733. p.longerSkipper = false;
  734. console.log('Пропустили.');
  735. },
  736. cl = function(p) {
  737. var faster = document.querySelector('.b-aplayer__html5-desktop-skip'),
  738. series = document.querySelector('.b-aplayer__actions-series');
  739.  
  740. function clickSelected() {
  741. var s = document.querySelector('.b-aplayer__popup-series-episodes .selected a');
  742. if (s) {
  743. s.click();
  744. }
  745. }
  746.  
  747. if ((!faster || faster.style.display !== 'block') && series && !p.seriesClicked) {
  748. series.click();
  749. p.seriesClicked = true;
  750. p.longerSkipper = true;
  751. setTimeout(clickSelected, 1000);
  752. p.pause();
  753. }
  754.  
  755. function skipListener() {
  756. if (p.waitAfterSkip) {
  757. console.log('В процессе пропуска…');
  758. return;
  759. }
  760. p.pause();
  761. if (!p.classList.contains('m-hidden')) {
  762. p.classList.add('m-hidden');
  763. }
  764. if (faster && p.currentTime &&
  765. win.getComputedStyle(faster).display === 'block' &&
  766. !faster.querySelector('.b-aplayer__html5-desktop-skip-timer')) {
  767. p.waitAfterSkip = true;
  768. setTimeout(adSkipper, (p.longerSkipper?3:1)*1000, faster, p);
  769. console.log('Доступен быстрый пропуск…');
  770. } else {
  771. setTimeout(adStepper, 1000, p);
  772. }
  773. }
  774.  
  775. p.addEventListener('timeupdate', skipListener, false);
  776. },
  777. o = new MutationObserver(function (mut) {
  778. mut.forEach(function (e) {
  779. var i = e.addedNodes.length;
  780. while(i--) {
  781. if (e.addedNodes[i].id === 'player' &&
  782. e.addedNodes[i].nodeName === 'VIDEO' &&
  783. e.addedNodes[i].getAttribute('preload') !== 'auto') {
  784. cl(e.addedNodes[i]);
  785. }
  786. }
  787. });
  788. });
  789. if (p.nodeName === 'VIDEO') {
  790. cl(p);
  791. } else {
  792. o.observe(m, {childList: true});
  793. }
  794. }
  795. };
  796. scripts['brb.to'] = scripts['fs.to'];
  797. scripts['cxz.to'] = scripts['fs.to'];
  798.  
  799. scripts['drive2.ru'] = function() {
  800. gardener('.c-block', />Реклама<\/|\.relap\..*display:\s?none/i);
  801. };
  802.  
  803. scripts['fishki.net'] = function() {
  804. gardener('.main-post', /543769|Реклама/);
  805. };
  806.  
  807. scripts['hdrezka.me'] = function() {
  808. gardener('div[id][onclick][onmouseup][onmousedown]', /onmouseout/i);
  809. };
  810.  
  811. scripts['naruto-base.su'] = function() {
  812. gardener('div[id^="entryID"],.block', /href="http.*?target="_blank"/i);
  813. };
  814.  
  815. scripts['pb.wtf'] = function() {
  816. GM_addStyle('#result,tbody.row1:not([id]) {display: none !important}');
  817. gardener('a[href$="=="]', /img/i, {root:'#page_container .containe', observe:true, parent:'div[class]'});
  818. gardener('a[href^="/"]', /<img\s.*<br>/i, {root:'#main_content', observe:true, parent:'div[class]'});
  819. gardener('.re_top1', /./, {root:'#main_content', parent:'table.border'});
  820. };
  821. scripts['piratbit.org'] = scripts['pb.wtf'];
  822. scripts['piratbit.ru'] = scripts['pb.wtf'];
  823.  
  824. scripts['pikabu.ru'] = function() {
  825. gardener('.story', /story__sponsor|story__gag|profile\/ads"/i, {root: '.inner_wrap', observe: true});
  826. };
  827.  
  828. scripts['rustorka.com'] = function() {
  829. var s = document.head.childNodes, i = s.length;
  830. if (i < 5) {
  831. while(i--) {
  832. if (s[i].httpEquiv && s[i].httpEquiv === 'refresh') {
  833. win.close();
  834. }
  835. }
  836. }
  837. gardener('span[class],ul[class],span[id],ul[id]', /\/\d{12,}\.php/i, {root:'#sidebar1', observe:true});
  838. gardener('div[id][style*="!important"]', /!important/i);
  839. };
  840. scripts['rumedia.ws'] = scripts['rustorka.com'];
  841.  
  842. scripts['sports.ru'] = function() {
  843. gardener('.aside-news-list__item', /aside-news-list__advert/i, {root:'.aside-news-block'});
  844. };
  845.  
  846. scripts['yap.ru'] = function() {
  847. var words = /member1438|Administration/;
  848. gardener('form > table[id^="p_row_"]', words);
  849. gardener('tr > .holder.newsbottom', words, {parent:'tr', siblings:-2});
  850. };
  851. scripts['yaplakal.com'] = scripts['yap.ru'];
  852.  
  853. scripts['reactor.cc'] = function() {
  854. preventBackgroundRedirect();
  855. gardener('a[href="/donate"]', /100/i, {parent:'#content,#sidebar', root:'#pageinner', observe:true});
  856. };
  857. scripts['joyreactor.cc'] = scripts['reactor.cc'];
  858. scripts['pornreactor.cc'] = scripts['reactor.cc'];
  859.  
  860. scripts['auto.ru'] = function() {
  861. var words = /Реклама|Яндекс.Директ|yandex_ad_/;
  862. var userAdsListAds = [
  863. '.listing-list > .listing-item',
  864. '.listing-item_type_fixed.listing-item'
  865. ];
  866. var catalogAds = [
  867. 'div[class*="layout_catalog-inline"]',
  868. 'div[class$="layout_horizontal"]'
  869. ];
  870. var otherAds = [
  871. '.advt_auto',
  872. '.sidebar-block',
  873. '.pager-listing + div[class]',
  874. '.card > div[class][style]',
  875. '.sidebar > div[class]',
  876. '.main-page__section + div[class]',
  877. '.listing > tbody'];
  878. gardener(userAdsListAds.join(','), words, {root:'.listing-wrap', observe:true});
  879. gardener(catalogAds.join(','), words, {root:'.catalog__page,.content__wrapper', observe:true});
  880. gardener(otherAds.join(','), words);
  881. };
  882.  
  883. scripts['online.anidub.com'] = function() {
  884. var script = document.createElement('script');
  885. script.type = "text/javascript";
  886. script.innerHTML = "function ogonekstart1() {}";
  887. document.getElementsByTagName('head')[0].appendChild(script);
  888.  
  889. var style = document.createElement('style');
  890. style.type = 'text/css';
  891. style.appendChild(document.createTextNode('.background {background: none!important;}'));
  892. style.appendChild(document.createTextNode('.background > script + div, .background > script ~ div:not([id]):not([class]) + div[id][class] {display:none!important}'));
  893. document.head.appendChild(style);
  894. };
  895.  
  896. scripts['rsload.net'] = function() {
  897. win.addEventListener('load', function() {
  898. var dis = document.querySelector('.cb-disable');
  899. if (dis) {
  900. dis.click();
  901. }
  902. });
  903. document.addEventListener('click',function(e){
  904. var t = e.target;
  905. if (t && t.href && (/:\/\/\d+\.\d+\.\d+\.\d+\//.test(t.href))) {
  906. t.href = t.href.replace('://','://rsload.net:rsload.net@');
  907. }
  908. });
  909. };
  910.  
  911. scripts['imageban.ru'] = function() {
  912. preventBackgroundRedirect();
  913. win.addEventListener('unload', function() {
  914. if (!window.location.hash) {
  915. window.location.replace(window.location+'#');
  916. } else {
  917. window.location.hash = '';
  918. }
  919. }, true);
  920. };
  921.  
  922. var domain = document.domain;
  923. while (domain.indexOf('.') !== -1) {
  924. if (scripts.hasOwnProperty(domain)) {
  925. scripts[domain]();
  926. break;
  927. }
  928. domain = domain.slice(domain.indexOf('.') + 1);
  929. }
  930. });
  931. })();