RU AdList JS Fixes

try to take over the world!

当前为 2016-10-07 提交的版本,查看 最新版本

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

QingJ © 2025

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