RU AdList JS Fixes

try to take over the world!

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

  1. // ==UserScript==
  2. // @name RU AdList JS Fixes
  3. // @namespace ruadlist_js_fixes
  4. // @version 2016-09-20:4
  5. // @description try to take over the world!
  6. // @author lainverse & dimisa
  7. // @match *://*/*
  8. // @grant unsafeWindow
  9. // @grant window.close
  10. // @run-at document-start
  11. // ==/UserScript==
  12.  
  13. (function() {
  14. 'use strict';
  15. var win = (unsafeWindow || window),
  16. inIFrame = (function() {
  17. try {
  18. return win.self !== win.top;
  19. } catch (ignore) {
  20. return true;
  21. }
  22. })();
  23.  
  24. if (!NodeList.prototype[Symbol.iterator]) { // it's a bad and dangerous idea, but I
  25. // really want to use for..of over lists of nodes. However, Safari fails to do so.
  26. NodeList.prototype[Symbol.iterator] = Array.prototype[Symbol.iterator];
  27. }
  28. // Creates and return protected style (unless protection is manually disabled).
  29. // Protected style will re-add itself on removal and remaind enabled on attempt to disable it.
  30. function createStyle(rules, props, skip_protect) {
  31. var root = document.head;
  32.  
  33. function _protect(style) {
  34. Object.defineProperty(style, 'sheet', {
  35. value: style.sheet,
  36. enumerable: true
  37. });
  38. Object.defineProperty(style, 'disabled', {
  39. get: function() {return true;}, //pretend to be disabled
  40. set: function() {},
  41. enumerable: true
  42. });
  43. }
  44.  
  45. function _create() {
  46. var style = root.appendChild(document.createElement('style')),
  47. prop, rule;
  48. style.type = 'text/css';
  49. for (prop in props) {
  50. if (style.hasOwnProperty(prop)) {
  51. style[prop] = props[prop];
  52. }
  53. }
  54. for (rule of rules) {
  55. try {
  56. style.sheet.insertRule(rule, 0);
  57. } catch (e) {
  58. console.error(e);
  59. }
  60. }
  61. if (!skip_protect) {
  62. _protect(style);
  63. }
  64. return style;
  65. }
  66.  
  67. var style = _create();
  68. if (skip_protect) {
  69. return style;
  70. }
  71.  
  72. var o = new MutationObserver(function(ms){
  73. var m, node, rule;
  74. for (m of ms) {
  75. for (node of m.removedNodes) {
  76. if (node === style) {
  77. style = _create();
  78. }
  79. }
  80. }
  81. });
  82. o.observe(root, {childList:true});
  83.  
  84. return style;
  85. }
  86.  
  87. // https://gf.qytechs.cn/scripts/19144-websuckit/
  88. (function() {
  89. function getWrappedCode(removeSelf) {
  90. var text = getWrappedCode.toString()+WSI.toString();
  91. text = (
  92. '(function(){"use strict";'+
  93. text.replace(/\/\/[^\r\n]*/g,'').replace(/[\s\r\n]+/g,' ')+
  94. '(new WSI(self||window)).init();'+
  95. '})();'+
  96. (removeSelf?'var s = document.currentScript; if (s) {s.parentNode.removeChild(s);}':'')
  97. );
  98. return text;
  99. }
  100.  
  101. function WSI(win, safeWin) {
  102. safeWin = safeWin || win;
  103. var masks = [], filter;
  104. for (filter of [// blacklist
  105. '||24video.xxx^',
  106. '||adlabs.ru^',
  107. '||bgrndi.com^',
  108. '||brokeloy.com^',
  109. '||cnamerutor.ru^',
  110. '||docfilms.info^',
  111. '||dreadfula.ru^',
  112. '||et-code.ru^',
  113. '||free-torrent.org^',
  114. '||free-torrent.pw^',
  115. '||free-torrents.org^',
  116. '||free-torrents.pw^',
  117. '||game-torrent.info^',
  118. '||gocdn.ru^',
  119. '||hdkinoshka.com^',
  120. '||hghit.com^',
  121. '||kinotochka.net^',
  122. '||kuveres.com^',
  123. '||lepubs.com^',
  124. '||luxadv.com^',
  125. '||luxup.ru^',
  126. '||mail.ru^',
  127. '||marketgid.com^',
  128. '||mxtads.com^',
  129. '||oconner.biz^',
  130. '||abbp1.website',
  131. '||psma01.com^',
  132. '||psma02.com^',
  133. '||psma03.com^',
  134. '||recreativ.ru^',
  135. '||regpole.com^',
  136. '||ruttwind.com^',
  137. '||skidl.ru^',
  138. '||torvind.com^',
  139. '||trafmag.com^',
  140. '||xxuhter.ru^',
  141. '||yuiout.online^'
  142. ]) {
  143. masks.push(new RegExp(
  144. filter.replace(/([\\\/\[\].*+?(){}$])/g, '\\$1')
  145. .replace(/\^(?!$)/g,'\\.?[^\\w%._-]')
  146. .replace(/\^$/,'\\.?([^\\w%._-]|$)')
  147. .replace(/^\|\|/,'^wss?:\\/+([^\/.]+\\.)*'),
  148. 'i'));
  149. }
  150.  
  151. function isBlocked(url) {
  152. for (var mask of masks) {
  153. if (mask.test(url)) {
  154. return true;
  155. }
  156. }
  157. return false;
  158. }
  159.  
  160. function WebSocketWrapper() {
  161. var realWebSocket = win.WebSocket;
  162. // check does browser support Proxy and WebSocket
  163. if (typeof Proxy !== 'function' ||
  164. typeof WebSocket !== 'function') {
  165. return;
  166. }
  167.  
  168. function wsGetter (target, name) {
  169. console.log('[WSI] Registered call to property "', name, '"');
  170. try {
  171. if (typeof realWebSocket.prototype[name] === 'function') {
  172. if (name === 'close' || name === 'send') { // send also closes connection
  173. target.readyState = realWebSocket.CLOSED;
  174. }
  175. return function(){return;};
  176. }
  177. if (typeof realWebSocket.prototype[name] === 'number') {
  178. return realWebSocket[name];
  179. }
  180. } catch(ignore) {}
  181. return target[name];
  182. }
  183.  
  184. win.WebSocket = new Proxy(realWebSocket, {
  185. construct: function (target, args) {
  186. var url = args[0];
  187. console.log('[WSI] Opening socket on', url, '\u2026');
  188. if (isBlocked(url)) {
  189. console.log("[WSI] Blocked.");
  190. return new Proxy({url: url, readyState: realWebSocket.OPEN}, {
  191. get: wsGetter
  192. });
  193. }
  194. return new target(args[0], args[1]);
  195. }
  196. });
  197. }
  198.  
  199. function WorkerWrapper() {
  200. var realWorker = win.Worker;
  201. function wrappedWorker(resourceURI) {
  202. var _worker = null,
  203. _terminate = false,
  204. _onerror = null,
  205. _onmessage = null,
  206. _messages = [],
  207. _events = [],
  208. _self = this;
  209.  
  210. (new Promise(function(resolve,reject){
  211. var xhrLoadEnd = function() {
  212. resolve(new realWorker(URL.createObjectURL(
  213. new Blob([getWrappedCode(false)+this.result])
  214. )));
  215. };
  216. var xhr = new XMLHttpRequest();
  217. xhr.open('GET', resourceURI, true);
  218. xhr.responseType = 'blob';
  219. xhr.onload = function(){
  220. if (this.status === 200) {
  221. var reader = new FileReader();
  222. reader.addEventListener("loadend", xhrLoadEnd);
  223. reader.readAsText(this.response);
  224. }
  225. };
  226. xhr.send();
  227. })).then(function(val) {
  228. _worker = val;
  229. _worker.onerror = _onerror;
  230. _worker.onmessage = _onmessage;
  231. var _e;
  232. while(_events.length) {
  233. _e = _events.shift();
  234. _worker[_e[0]].apply(_worker, _e[1]);
  235. }
  236. while(_messages.length) {
  237. _worker.postMessage(_messages.shift());
  238. }
  239. if (_terminate) {
  240. _worker.terminate();
  241. }
  242. });
  243.  
  244. _self.terminate = function(){
  245. _terminate = true;
  246. if (_worker) {
  247. _worker.terminate();
  248. }
  249. };
  250. Object.defineProperty(_self, 'onmessage', {
  251. get:function(){
  252. return _onmessage;
  253. },
  254. set:function(val){
  255. _onmessage = val;
  256. if (_worker) {
  257. _worker.onmessage = val;
  258. }
  259. }
  260. });
  261. Object.defineProperty(_self, 'onerror', {
  262. get:function(){
  263. return _onerror;
  264. },
  265. set:function(val){
  266. _onerror = val;
  267. if (_worker) {
  268. _worker.onmessage = val;
  269. }
  270. }
  271. });
  272. _self.postMessage = function(message){
  273. if (_worker) {
  274. _worker.postMessage(message);
  275. } else {
  276. _messages.push(message);
  277. }
  278. };
  279. _self.terminate = function() {
  280. _terminate = true;
  281. if (_worker) {
  282. _worker.terminate();
  283. }
  284. };
  285. _self.addEventListener = function(){
  286. if (_worker) {
  287. _worker.addEventListener.apply(_worker, arguments);
  288. } else {
  289. _events.push(['addEventListener',arguments]);
  290. }
  291. };
  292. _self.removeEventListener = function(){
  293. if (_worker) {
  294. _worker.removeEventListener.apply(_worker, arguments);
  295. } else {
  296. _events.push(['removeEventListener',arguments]);
  297. }
  298. };
  299. }
  300. win.Worker = wrappedWorker.bind(safeWin);
  301. }
  302.  
  303. function CreateElementWrapper() {
  304. var realCreateElement = document.createElement.bind(document),
  305. code = escape('<scr'+'ipt>'+getWrappedCode(true)+'</scr'+'ipt>');
  306.  
  307. function frameRewrite(e) {
  308. var f = e.target;
  309. if (f.src && /^data:text/i.test(f.src) && f.src.indexOf(code) < 0) {
  310. f.src = f.src.replace(',',',' + code);
  311. }
  312. }
  313.  
  314. function wrappedCreateElement(name) {
  315. if (name && name.toUpperCase &&
  316. name.toUpperCase() === 'IFRAME') {
  317. var ifr = realCreateElement.apply(document, arguments);
  318. ifr.addEventListener('load', frameRewrite, false);
  319. return ifr;
  320. }
  321. return realCreateElement.apply(document, arguments);
  322. }
  323. document.createElement = wrappedCreateElement.bind(document);
  324.  
  325. document.addEventListener('DOMContentLoaded', function(){
  326. for (var ifr of document.getElementsByTagName('IFRAME')) {
  327. ifr.addEventListener('load', frameRewrite, false);
  328. }
  329. }, false);
  330. }
  331.  
  332. this.init = function() {
  333. WebSocketWrapper();
  334. WorkerWrapper();
  335. if (typeof document !== 'undefined') {
  336. CreateElementWrapper();
  337. }
  338. };
  339. }
  340.  
  341. if (/firefox/i.test(navigator.userAgent)) {
  342. var script = document.createElement('script');
  343. script.appendChild(document.createTextNode(getWrappedCode()));
  344. document.head.insertBefore(script, document.head.firstChild);
  345. return; //we don't want to call functions on page from here in Fx, so exit
  346. }
  347.  
  348. (new WSI((unsafeWindow||self||window),(self||window))).init();
  349. })();
  350.  
  351. if (!(/firefox/i.test(navigator.userAgent))) { // scripts for non-Firefox browsers
  352.  
  353. // https://gf.qytechs.cn/scripts/14720-it-s-not-important
  354. (function(){
  355. var imptt = /((display|(margin|padding)(-top|-bottom)?)\s*:[^;!]*)!\s*important/ig;
  356.  
  357. function unimportanter(el, si) {
  358. if (!imptt.test(si) || el.style.display === 'none') {
  359. return 0; // get out if we have nothing to do here
  360. }
  361. if (el.nodeName === 'IFRAME' && el.src &&
  362. el.src.slice(0,17) === 'chrome-extension:') {
  363. return 0; // Web of Trust uses this method to add their frame
  364. }
  365. var so = si.replace(imptt, function(){return arguments[1];}), ret = 0;
  366. if (si !== so) {
  367. ret = 1;
  368. el.setAttribute('style', so);
  369. }
  370. return ret;
  371. }
  372.  
  373. function logger(c) {
  374. if (c) {
  375. console.log('Some page elements became a bit less important.');
  376. }
  377. }
  378.  
  379. function checkTarget(node, cnt) {
  380. if (!(node && node.getAttribute)) {
  381. return 0;
  382. }
  383. var si = node.getAttribute('style');
  384. if (si && si.indexOf('!') > -1) {
  385. cnt += unimportanter(node, si);
  386. }
  387. return cnt;
  388. }
  389.  
  390. var observer = new MutationObserver(function(mutations) {
  391. setTimeout(function(ms) {
  392. var cnt = 0, m, node;
  393. for (m of ms) {
  394. cnt = checkTarget(m.target, cnt);
  395. for (node of m.addedNodes) {
  396. cnt += checkTarget(node, cnt);
  397. }
  398. }
  399. logger(cnt);
  400. }, 0, mutations);
  401. });
  402.  
  403. observer.observe(document, { childList : true, attributes : true, attributeFilter : ['style'], subtree : true });
  404.  
  405. win.addEventListener ("load", function(){
  406. var c = 0, imp;
  407. for (imp of document.querySelectorAll('[style*="!"]')) {
  408. c+= checkTarget(imp, c);
  409. }
  410. logger(c);
  411. }, false);
  412. })();
  413.  
  414. }
  415.  
  416. if (/^https?:\/\/(news\.yandex\.|(www\.)?yandex\.[^\/]+\/(yand)?search[\/?])/i.test(win.location.href)) {
  417. // https://gf.qytechs.cn/en/scripts/809-no-yandex-ads
  418. (function(){
  419. var adWords = ['Яндекс.Директ','Реклама','Ad'];
  420. function remove(node) {
  421. node.parentNode.removeChild(node);
  422. }
  423. // Generic ads removal and fixes
  424. function removeGenericAds() {
  425. var s, i;
  426. s = document.querySelector('.serp-header');
  427. if (s) {
  428. s.style.marginTop='0';
  429. }
  430. for (s of document.querySelectorAll('.serp-adv__head + .serp-item, #adbanner, .serp-adv, .b-spec-adv, div[class*="serp-adv__"]')) {
  431. remove(s);
  432. }
  433. }
  434. // Search ads
  435. function removeSearchAds() {
  436. var s, item;
  437. for (s of document.querySelectorAll('.serp-block, .serp-item, .search-item')) {
  438. item = s.querySelector('.label, .serp-item__label, .document__provider-name');
  439. if (item && adWords.indexOf(item.textContent) > -1) {
  440. remove(s);
  441. console.log('Ads removed.');
  442. }
  443. }
  444. }
  445. // News ads
  446. function removeNewsAds() {
  447. var s;
  448. for (s of document.querySelectorAll('.page-content__left > *,.page-content__right > *:not(.page-content__col),.page-content__right > .page-content__col > *')) {
  449. if (s.textContent.indexOf(adWords[0]) > -1) {
  450. remove(s);
  451. console.log('Ads removed.');
  452. }
  453. }
  454. }
  455. // News fixes
  456. function removePageAdsClass() {
  457. if (document.body.classList.contains("b-page_ads_yes")){
  458. document.body.classList.remove("b-page_ads_yes");
  459. console.log('Page ads class removed.');
  460. }
  461. }
  462. // Function to attach an observer to monitor dynamic changes on the page
  463. function pageUpdateObserver(func, obj, params) {
  464. if (obj) {
  465. var o = new MutationObserver(func);
  466. o.observe(obj,(params || {childList:true, subtree:true}));
  467. }
  468. }
  469. // Cleaner
  470. document.addEventListener ("DOMContentLoaded", function() {
  471. removeGenericAds();
  472. if (win.location.hostname.search(/^news\./i) === 0) {
  473. pageUpdateObserver(removeNewsAds, document.querySelector('BODY'));
  474. pageUpdateObserver(removePageAdsClass, document.body, {attributes:true, attributesFilter:['class']});
  475. removeNewsAds();
  476. removePageAdsClass();
  477. } else {
  478. pageUpdateObserver(removeSearchAds, document.querySelector('.main__content'));
  479. removeSearchAds();
  480. }
  481. });
  482. })();
  483. return; //skip fixes for other sites
  484. }
  485.  
  486. // https://gf.qytechs.cn/en/scripts/14470-4pda-unbrender
  487. if (/(^|\.)4pda\.ru$/i.test(window.location.hostname)) {
  488. (function() {
  489. var isForum = document.location.href.search('/forum/') !== -1,
  490. isSafari = (/Safari/i.test(navigator.userAgent)) && (/Apple\sComputer/i.test(navigator.vendor)),
  491. hStyle;
  492.  
  493. function remove(n) {
  494. if (n) {
  495. n.parentNode.removeChild(n);
  496. }
  497. }
  498.  
  499. function afterClean() {
  500. hStyle.disabled = true;
  501. remove(hStyle);
  502. }
  503.  
  504. function beforeClean() {
  505. // attach styles before document displayed
  506. hStyle = createStyle([
  507. 'html { overflow-y: scroll }',
  508. 'article + aside * { display: none !important }',
  509. '#header + div:after {'+(
  510. 'content: "";'+
  511. 'position: fixed;'+
  512. 'top: 0;'+
  513. 'left: 0;'+
  514. 'width: 100%;'+
  515. 'height: 100%;'+
  516. 'background-color: #E6E7E9'
  517. )+'}',
  518. // http://codepen.io/Beaugust/pen/DByiE
  519. '@keyframes spin { 100% { transform: rotate(360deg) } }',
  520. 'article + aside:after {'+(
  521. 'content: "";'+
  522. 'position: absolute;'+
  523. 'width: 150px;'+
  524. 'height: 150px;'+
  525. 'top: 150px;'+
  526. 'left: 50%;'+
  527. 'margin-top: -75px;'+
  528. 'margin-left: -75px;'+
  529. 'box-sizing: border-box;'+
  530. 'border-radius: 100%;'+
  531. 'border: 10px solid rgba(0, 0, 0, 0.2);'+
  532. 'border-top-color: rgba(0, 0, 0, 0.6);'+
  533. 'animation: spin 2s infinite linear'
  534. )+'}'
  535. ], {id:'ubrHider'}, true);
  536.  
  537. // display content of a page if time to load a page is more than 2 seconds to avoid
  538. // blocking access to a page if it is loading for too long or stuck in a loading state
  539. setTimeout(2000, afterClean);
  540. }
  541.  
  542. createStyle([
  543. '#nav .use-ad {display: block !important;}',
  544. 'article:not(.post) + article:not(#id) { display: none !important }'
  545. ]);
  546.  
  547. if (!isForum && !isSafari) {
  548. beforeClean();
  549. }
  550.  
  551. // clean a page
  552. window.addEventListener('DOMContentLoaded', function(){
  553. var rem, si, itm;
  554. function width(){ return window.innerWidth||document.documentElement.clientWidth||document.body.clientWidth||0; }
  555. function height(){ return window.innerHeight||document.documentElement.clientHeight||document.body.clientHeight||0; }
  556.  
  557.  
  558. if (isForum) {
  559. si = document.querySelector('#logostrip');
  560. if (si) {
  561. remove(si.parentNode.nextSibling);
  562. }
  563. }
  564.  
  565. if (document.location.href.search('/forum/dl/') !== -1) {
  566. document.body.setAttribute('style', (document.body.getAttribute('style')||'')+
  567. ';background-color:black!important');
  568. for (itm of document.querySelectorAll('body>div')) {
  569. if (!itm.querySelector('.dw-fdwlink')) {
  570. remove(itm);
  571. }
  572. }
  573. }
  574.  
  575. if (isForum) { // Do not continue if it's a forum
  576. return;
  577. }
  578.  
  579. si = document.querySelector('#header');
  580. if (si) {
  581. rem = si.previousSibling;
  582. while (rem) {
  583. si = rem.previousSibling;
  584. remove(rem);
  585. rem = si;
  586. }
  587. }
  588.  
  589. for (itm of document.querySelectorAll('#nav li[class]')) {
  590. if (itm && itm.querySelector('a[href^="/tag/"]')) {
  591. remove(itm);
  592. }
  593. }
  594.  
  595. var style, result;
  596. for (itm of document.querySelectorAll('DIV')) {
  597. if (itm.offsetWidth > 0.95 * width() && itm.offsetHeight > 0.9 * height()) {
  598. style = window.getComputedStyle(itm, null);
  599. result = [];
  600. if(style.backgroundImage !== 'none') {
  601. result.push('background-image:none!important');
  602. }
  603. if(style.backgroundColor !== 'transparent') {
  604. result.push('background-color:transparent!important');
  605. }
  606. if (result.length) {
  607. if (itm.getAttribute('style')) {
  608. result.unshift(itm.getAttribute('style'));
  609. }
  610. itm.setAttribute('style', result.join(';'));
  611. }
  612. }
  613. }
  614.  
  615. for (itm of document.querySelectorAll('ASIDE>DIV')) {
  616. if ( ((itm.querySelector('script, iframe, a[href*="/ad/www/"]') ||
  617. itm.querySelector('img[src$=".gif"]:not([height="0"]), img[height="400"]')) &&
  618. !itm.classList.contains('post') ) || !itm.childNodes.length ) {
  619. remove(itm);
  620. }
  621. }
  622.  
  623. document.body.setAttribute('style', (document.body.getAttribute('style')||'')+';background-color:#E6E7E9!important');
  624.  
  625. // display content of the page
  626. afterClean();
  627. });
  628. })();
  629. return;
  630. }
  631.  
  632. // https://gf.qytechs.cn/en/scripts/21937-moonwalk-hdgo-kodik-fix v0.6
  633. document.addEventListener ("DOMContentLoaded", function() {
  634. if (!inIFrame) {
  635. return;
  636. }
  637. var tmp;
  638. function log (e) {
  639. console.log('Moonwalk&HDGo&Kodik FIX: ' + e + ' player in ' + win.location.href);
  640. }
  641. if (win.adv_enabled !== undefined && win.condition_detected !== undefined) {
  642. log('Moonwalk');
  643. win.adv_enabled = false;
  644. win.condition_detected = false;
  645. } else if (win.banner_second !== undefined && win.$banner_ads !== undefined) {
  646. log('HDGo');
  647. win.banner_second = 0;
  648. win.$banner_ads = false;
  649. win.$new_ads = false;
  650. win.canRunAds = true;
  651. tmp = document.body.querySelector('#swtf');
  652. if (tmp) {
  653. tmp.style.display = 'none';
  654. }
  655. } else if (win.MXoverrollCallback !== undefined && win.iframeSearch !== undefined) {
  656. log('Kodik');
  657. win.IsAdBlock = false;
  658. win.iframeSearch = null;
  659. tmp = document.getElementsByClassName('play_button')[0];
  660. if (tmp) {
  661. tmp.onclick = win.MXoverrollCallback.bind(window);
  662. }
  663. }
  664. }, false);
  665.  
  666. // function to search and remove nodes by content
  667. // selector - standard CSS selector to define set of nodes to check
  668. // words - regular expression to check content of the suspicious nodes
  669. // params - object with multiple extra parameters:
  670. // .hide - set display to none instead of removing from the page
  671. // .parent - parent node to remove if content is found in the child node
  672. // .siblings - number of simling nodes to remove (excluding text nodes)
  673. function scRemove(e) {e.parentNode.removeChild(e);}
  674. function scHide(e) {
  675. var s = e.getAttribute('style')||'',
  676. h = ';display:none!important;';
  677. if (s.indexOf(h) < 0) {
  678. e.setAttribute('style', s+h);
  679. }
  680. }
  681. function scissors (selector, words, scope, params) {
  682. var remFunc = (params.hide ? scHide : scRemove),
  683. iterFunc = (params.siblings > 0 ?
  684. 'nextSibling' :
  685. 'previousSibling'),
  686. toRemove = [],
  687. siblings,
  688. node;
  689. for (node of scope.querySelectorAll(selector)) {
  690. if (words.test(node.innerHTML) || !node.childNodes.length) {
  691. // drill up to the specified parent node if required
  692. if (params.parent) {
  693. while(node !== scope && !(node.matches(params.parent))) {
  694. node = node.parentNode;
  695. }
  696. }
  697. if (node === scope) {
  698. break;
  699. }
  700. toRemove.push(node);
  701. // add multiple nodes if defined more than one sibling
  702. siblings = Math.abs(params.siblings) || 0;
  703. while (siblings) {
  704. node = node[iterFunc];
  705. toRemove.push(node);
  706. if (node.nodeType === 1) {
  707. siblings -= 1; //count only element nodes
  708. }
  709. }
  710. }
  711. }
  712. for (node of toRemove) {
  713. remFunc(node);
  714. }
  715. return toRemove.length;
  716. }
  717.  
  718. // function to perform multiple checks if ads inserted with a delay
  719. // by default does 30 checks withing a 3 seconds unless nonstop mode specified
  720. // also does 1 extra check when a page completely loads
  721. // selector and words - passed dow to scissors
  722. // params - object with multiple extra parameters:
  723. // .root - selector to narrow down scope to scan;
  724. // .observe - if true then check will be performed continuously;
  725. // Other parameters passed down to scissors.
  726. function gardener(selector, words, params) {
  727. params = params || {};
  728. var scope = document.body,
  729. nonstop = false;
  730. // narrow down scope to a specific element
  731. if (params.root) {
  732. scope = scope.querySelector(params.root);
  733. if (!scope) {// exit if the root element is not present on the page
  734. return 0;
  735. }
  736. }
  737. // add observe mode if required
  738. if (params.observe) {
  739. if (typeof MutationObserver === 'function') {
  740. var o = new MutationObserver(function(ms){
  741. for (var m of ms) {
  742. if (m.addedNodes.length) {
  743. scissors(selector, words, scope, params);
  744. }
  745. }
  746. });
  747. o.observe(scope, {childList:true, subtree: true});
  748. } else {
  749. nonstop = true;
  750. }
  751. }
  752. // wait for a full page load to do one extra cut
  753. win.addEventListener('load',function(){
  754. scissors(selector, words, scope, params);
  755. });
  756. // do multiple cuts until ads removed
  757. function cut(sci, s, w, sc, p, i) {
  758. if (i > 0) {
  759. i -= 1;
  760. }
  761. if (i && !sci(s, w, sc, p)) {
  762. setTimeout(cut, 100, sci, s, w, sc, p, i);
  763. }
  764. }
  765. cut(scissors, selector, words, scope, params, (nonstop ? -1 : 30));
  766. }
  767.  
  768. function preventBackgroundRedirect() {
  769. // create "cose_me" event to call high-level window.close()
  770. var key = Math.random().toString(36).substr(2);
  771. window.addEventListener('close_me_'+key, function(e) {
  772. console.log('event!');
  773. window.close();
  774. });
  775.  
  776. // window.open wrapper
  777. function pbrLander() {
  778. var orgOpen = window.open.bind(window);
  779. function closeWindow(){
  780. // site went to a new tab and attempts to unload
  781. // call for high-level close through event
  782. var event = new CustomEvent("close_me_%key%", {});
  783. window.dispatchEvent(event);
  784. }
  785. function open(){
  786. var loc = arguments[0];
  787. if (loc && loc.indexOf &&
  788. (loc.indexOf(window.location.host) > -1 ||
  789. loc.indexOf('://') === -1)) {
  790. window.addEventListener('unload', closeWindow, true);
  791. }
  792. orgOpen.apply(window, arguments);
  793. }
  794. window.open = open.bind(window);
  795. var s = document.currentScript;
  796. if (s) {s.parentNode.removeChild(s);}
  797. }
  798.  
  799. // land wrapper on the page
  800. var script = document.createElement('script');
  801. script.appendChild(document.createTextNode('('+pbrLander.toString().replace(/%key%/g,key)+')();'));
  802. document.head.insertBefore(script,document.head.firstChild);
  803. console.log("Background redirect prevention enabled.");
  804. }
  805.  
  806. function forbidServiceWorker() {
  807. if (!("serviceWorker" in navigator)) {
  808. return;
  809. }
  810. var svr = navigator.serviceWorker.ready;
  811. Object.defineProperty(navigator, 'serviceWorker', {
  812. value: {
  813. register: function(){
  814. console.log('Registration of serviceWorker', arguments[0], 'blocked.');
  815. return new Promise(function(){});
  816. },
  817. ready: new Promise(function(){}),
  818. addEventListener:function(){}
  819. }
  820. });
  821. document.addEventListener('DOMContentLoaded', function() {
  822. if (!svr) {
  823. return;
  824. }
  825. svr.then(function(sw) {
  826. console.log('Found existing serviceWorker:', sw);
  827. console.log('Attempting to unregister...');
  828. sw.unregister().then(function() {
  829. console.log('Unregistered! :)');
  830. }).catch(function(err) {
  831. console.log('Unregistration failed. :(', err);
  832. console.log('Try to remove it manually:');
  833. console.log(' 1. Open: chrome://serviceworker-internals/ (Google Chrome and alike) or about:serviceworkers (Mozilla Firefox) in a new tab.');
  834. console.log(' 2. Search there for one with "'+document.domain+'" in the name.');
  835. console.log(' 3. Use buttons in the same block with service you found to stop it and uninstall/unregister.');
  836. });
  837. }).catch(function(err) {
  838. console.log("Lol, it failed on it's own. -_-", err);
  839. });
  840. }, false);
  841. }
  842.  
  843. var scripts = {};
  844. scripts['fs.to'] = function() {
  845. function skipClicker(i) {
  846. if (!i) {
  847. return;
  848. }
  849. var skip = document.querySelector('.b-aplayer-banners__close');
  850. if (skip) {
  851. skip.click();
  852. } else {
  853. setTimeout(skipClicker, 100, i-1);
  854. }
  855. }
  856. setTimeout(skipClicker, 100, 30);
  857.  
  858. createStyle([
  859. '.l-body-branding *,'+
  860. '.b-styled__item-central,'+
  861. '.b-styled__content-right,'+
  862. '.b-styled__section-central,'+
  863. 'div[id^="adsProxy-"]'+
  864. '{display:none!important}',
  865. 'body {background-image:url(data:image/png;base64,'+
  866. 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAACX'+
  867. 'BIWXMAAC4jAAAuIwF4pT92AAAADUlEQVR42mOQUdL5DwACMgFq'+
  868. 'BC3ttwAAAABJRU5ErkJggg==)!important}'
  869. ]);
  870.  
  871. if (/\/(view_iframe|iframeplayer)\//i.test(document.location.pathname)) {
  872. var p = document.querySelector('#player:not([preload="auto"])'),
  873. m = document.querySelector('.main'),
  874. adStepper = function(p) {
  875. if (p.currentTime < p.duration) {
  876. p.currentTime += 1;
  877. }
  878. },
  879. adSkipper = function(f, p) {
  880. f.click();
  881. p.waitAfterSkip = false;
  882. p.longerSkipper = false;
  883. console.log('Пропустили.');
  884. },
  885. cl = function(p) {
  886. var faster = document.querySelector('.b-aplayer__html5-desktop-skip'),
  887. series = document.querySelector('.b-aplayer__actions-series');
  888.  
  889. function clickSelected() {
  890. var s = document.querySelector('.b-aplayer__popup-series-episodes .selected a');
  891. if (s) {
  892. s.click();
  893. }
  894. }
  895.  
  896. if ((!faster || faster.style.display !== 'block') && series && !p.seriesClicked) {
  897. series.click();
  898. p.seriesClicked = true;
  899. p.longerSkipper = true;
  900. setTimeout(clickSelected, 1000);
  901. p.pause();
  902. }
  903.  
  904. function skipListener() {
  905. if (p.waitAfterSkip) {
  906. console.log('В процессе пропуска…');
  907. return;
  908. }
  909. p.pause();
  910. if (!p.classList.contains('m-hidden')) {
  911. p.classList.add('m-hidden');
  912. }
  913. if (faster && p.currentTime &&
  914. win.getComputedStyle(faster).display === 'block' &&
  915. !faster.querySelector('.b-aplayer__html5-desktop-skip-timer')) {
  916. p.waitAfterSkip = true;
  917. setTimeout(adSkipper, (p.longerSkipper?3:1)*1000, faster, p);
  918. console.log('Доступен быстрый пропуск…');
  919. } else {
  920. setTimeout(adStepper, 1000, p);
  921. }
  922. }
  923.  
  924. p.addEventListener('timeupdate', skipListener, false);
  925. },
  926. o = new MutationObserver(function (ms) {
  927. var m, node;
  928. for (m of ms) {
  929. for (node of m.addedNodes) {
  930. if (node.id === 'player' &&
  931. node.nodeName === 'VIDEO' &&
  932. node.getAttribute('preload') !== 'auto') {
  933. cl(node);
  934. }
  935. }
  936. }
  937. });
  938. if (p.nodeName === 'VIDEO') {
  939. cl(p);
  940. } else {
  941. o.observe(m, {childList: true});
  942. }
  943. }
  944. };
  945. scripts['brb.to'] = scripts['fs.to'];
  946. scripts['cxz.to'] = scripts['fs.to'];
  947.  
  948. scripts['drive2.ru'] = function() {
  949. gardener('.c-block', />Реклама<\/|\.relap\..*display:\s?none/i);
  950. };
  951.  
  952. scripts['fishki.net'] = function() {
  953. gardener('.main-post', /543769|Реклама/);
  954. };
  955.  
  956. scripts['hdgo.cc'] = {
  957. 'now': function(){
  958. var o = new MutationObserver(function(ms) {
  959. var m, node;
  960. for (m of ms) {
  961. for (node of m.addedNodes) {
  962. if (node.tagName === 'SCRIPT' && node.getAttribute('onerror') !== null) {
  963. node.removeAttribute('onerror');
  964. }
  965. }
  966. }
  967. });
  968. o.observe(document, {childList:true, subtree: true});
  969. }
  970. };
  971. scripts['couber.be'] = scripts['hdgo.cc'];
  972. scripts['46.30.43.38'] = scripts['hdgo.cc'];
  973.  
  974. scripts['hdrezka.me'] = {
  975. 'now': function() {
  976. Object.defineProperty(win, 'fuckAdBlock', {
  977. value: {
  978. onDetected: function() {
  979. console.log('Pretending to be an ABP detector.');
  980. }
  981. }
  982. });
  983. Object.defineProperty(win, 'ab', { value: false });
  984. },
  985. 'DOMContentLoaded': function() {
  986. gardener('div[id][onclick][onmouseup][onmousedown]', /onmouseout/i);
  987. }
  988. };
  989.  
  990. scripts['naruto-base.su'] = function() {
  991. gardener('div[id^="entryID"],.block', /href="http.*?target="_blank"/i);
  992. };
  993.  
  994. scripts['pb.wtf'] = function() {
  995. createStyle(['.reques,#result,tbody.row1:not([id]) {display: none !important}']);
  996. // image in the slider in the header
  997. gardener('a[href$="=="]', /img/i, {root:'.release-navbar', observe:true, parent:'div'});
  998. // ads in blocks on the page
  999. gardener('a[href^="/"]', /<img\s.*<br>/i, {root:'#main_content', observe:true, parent:'div[class]'});
  1000. // line above topic content
  1001. gardener('.re_top1', /./, {root:'#main_content', parent:'.hidden-sm'});
  1002. };
  1003. scripts['piratbit.org'] = scripts['pb.wtf'];
  1004. scripts['piratbit.ru'] = scripts['pb.wtf'];
  1005.  
  1006. scripts['pikabu.ru'] = function() {
  1007. gardener('.story', /story__sponsor|story__gag|profile\/ads"/i, {root: '.inner_wrap', observe: true});
  1008. };
  1009.  
  1010. scripts['rustorka.com'] = function() {
  1011. var s = document.head.childNodes, i = s.length;
  1012. if (i < 5) {
  1013. while(i--) {
  1014. if (s[i].httpEquiv && s[i].httpEquiv === 'refresh') {
  1015. win.close();
  1016. }
  1017. }
  1018. }
  1019. gardener('span[class],ul[class],span[id],ul[id]', /\/\d{12,}\.php/i, {root:'#sidebar1', observe:true});
  1020. gardener('div[id][style*="!important"]', /!important/i);
  1021. };
  1022. scripts['rumedia.ws'] = scripts['rustorka.com'];
  1023.  
  1024. scripts['sports.ru'] = function() {
  1025. gardener('.aside-news-list__item', /aside-news-list__advert/i, {root:'.aside-news-block'});
  1026. };
  1027.  
  1028. scripts['turbobit.net'] = {'now': preventBackgroundRedirect};
  1029.  
  1030. scripts['yap.ru'] = function() {
  1031. var words = /member1438|Administration/;
  1032. gardener('form > table[id^="p_row_"]', words);
  1033. gardener('tr > .holder.newsbottom', words, {parent:'tr', siblings:-2});
  1034. };
  1035. scripts['yaplakal.com'] = scripts['yap.ru'];
  1036.  
  1037. scripts['reactor.cc'] = {
  1038. 'now': preventBackgroundRedirect,
  1039. 'DOMContentLoaded': function() {
  1040. var words = new RegExp(
  1041. 'блокировщика рекламы'
  1042. .split('')
  1043. .map(function(e){return e+'[\u200b\u200c\u200d]*';})
  1044. .join('')
  1045. .replace(' ', '\\s*')
  1046. .replace(/[аоре]/g, function(e){return ['[аa]','[оo]','[рp]','[еe]']['аоре'.indexOf(e)];}),
  1047. 'i'),
  1048. can;
  1049. function deeper(spider) {
  1050. var c, l, n;
  1051. if (words.test(spider.innerText)) {
  1052. if (spider.nodeType === Node.TEXT_NODE) {
  1053. return true;
  1054. }
  1055. c = spider.childNodes;
  1056. l = c.length;
  1057. n = 0;
  1058. while(l--) {
  1059. if (deeper(c[l]), can) {
  1060. n++;
  1061. }
  1062. }
  1063. if (n > 0 && n === c.length && spider.offsetHeight < 750) {
  1064. can.push(spider);
  1065. }
  1066. return false;
  1067. }
  1068. return true;
  1069. }
  1070. function probe(){
  1071. if (words.test(document.body.innerText)) {
  1072. can = [];
  1073. deeper(document.body);
  1074. var i = can.length, j, spider;
  1075. while(i--) {
  1076. spider = can[i];
  1077. if (spider.offsetHeight > 10 && spider.offsetHeight < 750) {
  1078. spider.setAttribute('style', 'background:none!important');
  1079. }
  1080. }
  1081. }
  1082. }
  1083. var o = new MutationObserver(probe);
  1084. o.observe(document,{childList:true, subtree:true});
  1085. }
  1086. };
  1087. scripts['joyreactor.cc'] = scripts['reactor.cc'];
  1088. scripts['pornreactor.cc'] = scripts['reactor.cc'];
  1089.  
  1090. scripts['auto.ru'] = function() {
  1091. var words = /Реклама|Яндекс.Директ|yandex_ad_/;
  1092. var userAdsListAds = [
  1093. '.listing-list > .listing-item',
  1094. '.listing-item_type_fixed.listing-item'
  1095. ];
  1096. var catalogAds = [
  1097. 'div[class*="layout_catalog-inline"]',
  1098. 'div[class$="layout_horizontal"]'
  1099. ];
  1100. var otherAds = [
  1101. '.advt_auto',
  1102. '.sidebar-block',
  1103. '.pager-listing + div[class]',
  1104. '.card > div[class][style]',
  1105. '.sidebar > div[class]',
  1106. '.main-page__section + div[class]',
  1107. '.listing > tbody'];
  1108. gardener(userAdsListAds.join(','), words, {root:'.listing-wrap', observe:true});
  1109. gardener(catalogAds.join(','), words, {root:'.catalog__page,.content__wrapper', observe:true});
  1110. gardener(otherAds.join(','), words);
  1111. };
  1112.  
  1113. scripts['online.anidub.com'] = function() {
  1114. var script = document.createElement('script');
  1115. script.type = "text/javascript";
  1116. script.innerHTML = "function ogonekstart1() {}";
  1117. document.getElementsByTagName('head')[0].appendChild(script);
  1118.  
  1119. var style = document.createElement('style');
  1120. style.type = 'text/css';
  1121. style.appendChild(document.createTextNode('.background {background: none!important;}'));
  1122. style.appendChild(document.createTextNode('.background > script + div, .background > script ~ div:not([id]):not([class]) + div[id][class] {display:none!important}'));
  1123. document.head.appendChild(style);
  1124. };
  1125.  
  1126. scripts['rsload.net'] = function() {
  1127. win.addEventListener('load', function() {
  1128. var dis = document.querySelector('.cb-disable');
  1129. if (dis) {
  1130. dis.click();
  1131. }
  1132. });
  1133. document.addEventListener('click',function(e){
  1134. var t = e.target;
  1135. if (t && t.href && (/:\/\/\d+\.\d+\.\d+\.\d+\//.test(t.href))) {
  1136. t.href = t.href.replace('://','://rsload.net:rsload.net@');
  1137. }
  1138. });
  1139. };
  1140.  
  1141. scripts['imageban.ru'] = {
  1142. 'now': preventBackgroundRedirect,
  1143. 'DOMContentLoaded': function() {
  1144. win.addEventListener('unload', function() {
  1145. if (!window.location.hash) {
  1146. window.location.replace(window.location+'#');
  1147. } else {
  1148. window.location.hash = '';
  1149. }
  1150. }, true);
  1151. }
  1152. };
  1153.  
  1154. var domain = document.domain, name;
  1155. while (domain.indexOf('.') !== -1) {
  1156. if (scripts.hasOwnProperty(domain)) {
  1157. if (typeof scripts[domain] === 'function') {
  1158. document.addEventListener ('DOMContentLoaded', scripts[domain], false);
  1159. }
  1160. for (name in scripts[domain]) {
  1161. if (name !== 'now') {
  1162. document.addEventListener (name, scripts[domain][name], false);
  1163. } else {
  1164. scripts[domain].now();
  1165. }
  1166. }
  1167. }
  1168. domain = domain.slice(domain.indexOf('.') + 1);
  1169. }
  1170. })();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址