RU AdList JS Fixes

try to take over the world!

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

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

QingJ © 2025

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