RU AdList JS Fixes

try to take over the world!

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

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

QingJ © 2025

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