RU AdList JS Fixes

try to take over the world!

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

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