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

QingJ © 2025

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