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