RU AdList JS Fixes

try to take over the world!

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

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