RU AdList JS Fixes

try to take over the world!

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

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

QingJ © 2025

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