RU AdList JS Fixes

try to take over the world!

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

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

QingJ © 2025

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