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