RU AdList JS Fixes

try to take over the world!

当前为 2017-02-05 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name RU AdList JS Fixes
  3. // @namespace ruadlist_js_fixes
  4. // @version 20170204.2
  5. // @description try to take over the world!
  6. // @author lainverse & dimisa
  7. // @match *://*/*
  8. // @grant unsafeWindow
  9. // @grant window.close
  10. // @run-at document-start
  11. // ==/UserScript==
  12.  
  13. (function() {
  14. 'use strict';
  15. var win = (unsafeWindow || window),
  16. // http://stackoverflow.com/questions/9847580/how-to-detect-safari-chrome-ie-firefox-and-opera-browser
  17. isOpera = (!!window.opr && !!opr.addons) || !!window.opera || navigator.userAgent.indexOf(' OPR/') >= 0,
  18. isChrome = !!window.chrome && !!window.chrome.webstore,
  19. isSafari = (Object.prototype.toString.call(window.HTMLElement).indexOf('Constructor') > 0 ||
  20. (function (p) { return p.toString() === "[object SafariRemoteNotification]"; })(!window['safari'] || safari.pushNotification)),
  21. isFirefox = typeof InstallTrigger !== 'undefined';
  22.  
  23. // NodeList iterator polyfill (mostly for Safari)
  24. // https://jakearchibald.com/2014/iterators-gonna-iterate/
  25. if (!NodeList.prototype[Symbol.iterator]) {
  26. NodeList.prototype[Symbol.iterator] = Array.prototype[Symbol.iterator];
  27. }
  28.  
  29. // Creates and return protected style (unless protection is manually disabled).
  30. // Protected style will re-add itself on removal and remaind enabled on attempt to disable it.
  31. function createStyle(rules, props, skip_protect) {
  32. var root = document.documentElement;
  33.  
  34. function _protect(style) {
  35. Object.defineProperty(style, 'sheet', {
  36. value: style.sheet,
  37. enumerable: true
  38. });
  39. Object.defineProperty(style, 'disabled', {
  40. get: function() {return true;}, //pretend to be disabled
  41. set: function() {},
  42. enumerable: true
  43. });
  44. }
  45.  
  46. function _create() {
  47. var style = root.appendChild(document.createElement('style')),
  48. prop, rule;
  49. style.type = 'text/css';
  50. for (prop in props) {
  51. if (style[prop] !== undefined) {
  52. style[prop] = props[prop];
  53. }
  54. }
  55. function insertRule(rule) {
  56. try {
  57. style.sheet.insertRule(rule, 0);
  58. } catch (e) {
  59. console.error(e);
  60. }
  61. }
  62. if (typeof rules === 'string') {
  63. insertRule(rules);
  64. } else {
  65. rules.forEach(insertRule);
  66. }
  67. if (!skip_protect) {
  68. _protect(style);
  69. }
  70. return style;
  71. }
  72.  
  73. var style = _create();
  74. if (skip_protect) {
  75. return style;
  76. }
  77.  
  78. var o = new MutationObserver(function(ms){
  79. var m, node, rule;
  80. for (m of ms) {
  81. for (node of m.removedNodes) {
  82. if (node === style) {
  83. (new Promise(function(resolve){
  84. setTimeout(function(resolve){
  85. resolve(_create());
  86. }, 0, resolve);
  87. })).then(function(st){
  88. style = st;
  89. });
  90. }
  91. }
  92. }
  93. });
  94. o.observe(root, {childList:true});
  95.  
  96. return style;
  97. }
  98.  
  99. // https://gf.qytechs.cn/scripts/19144-websuckit/
  100. (function() {
  101. // check does browser support Proxy and WebSocket
  102. if (typeof Proxy !== 'function' ||
  103. typeof WebSocket !== 'function') {
  104. return;
  105. }
  106.  
  107. function getWrappedCode(removeSelf) {
  108. var text = getWrappedCode.toString()+WSI.toString();
  109. text = (
  110. '(function(){"use strict";'+
  111. text.replace(/\/\/[^\r\n]*/g,'').replace(/[\s\r\n]+/g,' ')+
  112. '(new WSI(self||window)).init();'+
  113. '})();\n'+
  114. (removeSelf?'var s = document.currentScript; if (s) {s.parentNode.removeChild(s);}':'')
  115. );
  116. return text;
  117. }
  118.  
  119. function WSI(win, safeWin) {
  120. safeWin = safeWin || win;
  121. var masks = [], filter;
  122. for (filter of [// blacklist
  123. '||10root25.website^', '||24video.xxx^',
  124. '||adlabs.ru^', '||adspayformymortgage.win^', '||aviabay.ru^',
  125. '||bgrndi.com^', '||brokeloy.com^',
  126. '||cnamerutor.ru^',
  127. '||docfilms.info^', '||dreadfula.ru^',
  128. '||et-code.ru^',
  129. '||film-doma.ru^',
  130. '||free-torrent.org^', '||free-torrent.pw^',
  131. '||free-torrents.org^', '||free-torrents.pw^',
  132. '||game-torrent.info^', '||gocdn.ru^',
  133. '||hdkinoshka.com^', '||hghit.com^', '||hindcine.net^',
  134. '||kiev.ua^', '||kinotochka.net^',
  135. '||kinott.com^', '||kinott.ru^', '||kuveres.com^',
  136. '||lepubs.com^', '||luxadv.com^', '||luxup.ru^', '||luxupcdna.com^',
  137. '||mail.ru^', '||marketgid.com^', '||mxtads.com^',
  138. '||nickhel.com^',
  139. '||oconner.biz^',
  140. '||pkpojhc.com^',
  141. '||psma01.com^', '||psma02.com^', '||psma03.com^',
  142. '||recreativ.ru^', '||redtram.com^', '||regpole.com^', '||rootmedia.ws^', '||ruttwind.com^',
  143. '||skidl.ru^',
  144. '||torvind.com^', '||trafmag.com^',
  145. '||webadvert-gid.ru^', '||webadvertgid.ru^',
  146. '||xxuhter.ru^',
  147. '||yuiout.online^',
  148. '||zoom-film.ru^'
  149. ]) {
  150. masks.push(new RegExp(
  151. filter.replace(/([\\\/\[\].*+?(){}$])/g, '\\$1')
  152. .replace(/\^(?!$)/g,'\\.?[^\\w%._-]')
  153. .replace(/\^$/,'\\.?([^\\w%._-]|$)')
  154. .replace(/^\|\|/,'^wss?:\\/+([^\/.]+\\.)*'),
  155. 'i'));
  156. }
  157.  
  158. function isBlocked(url) {
  159. for (var mask of masks) {
  160. if (mask.test(url)) {
  161. return true;
  162. }
  163. }
  164. return false;
  165. }
  166.  
  167. var realWebSocket = win.WebSocket;
  168. function wsGetter (target, name) {
  169. try {
  170. if (typeof realWebSocket.prototype[name] === 'function') {
  171. if (name === 'close' || name === 'send') { // send also closes connection
  172. target.readyState = realWebSocket.CLOSED;
  173. }
  174. return (
  175. function fake() {
  176. console.log('[WSI] Invoked function "'+name+'"', '| Tracing', (new Error()));
  177. return;
  178. }
  179. );
  180. }
  181. if (typeof realWebSocket.prototype[name] === 'number') {
  182. return realWebSocket[name];
  183. }
  184. } catch(ignore) {}
  185. return target[name];
  186. }
  187.  
  188. function createWebSocketWrapper(target) {
  189. return new Proxy(realWebSocket, {
  190. construct: function (target, args) {
  191. var url = args[0];
  192. console.log('[WSI] Opening socket on ' + url + ' \u2026');
  193. if (isBlocked(url)) {
  194. console.log("[WSI] Blocked.");
  195. return new Proxy({
  196. url: url,
  197. readyState: realWebSocket.OPEN
  198. }, {
  199. get: wsGetter
  200. });
  201. }
  202. return new target(args[0], args[1]);
  203. }
  204. });
  205. }
  206.  
  207. function WorkerWrapper() {
  208. var realWorker = win.Worker;
  209. function wrappedWorker(resourceURI) {
  210. var isBlobURL = /^blob:/i,
  211. xhr = null,
  212. _callbacks = new WeakMap(),
  213. _worker = null,
  214. _terminate = false,
  215. _onerror = null,
  216. _onmessage = null,
  217. _messages = [],
  218. _events = [],
  219. /*jshint validthis:true */
  220. _self = this;
  221.  
  222. function callbackWrapper(func) {
  223. if (typeof func !== 'function') {
  224. return undefined;
  225. }
  226. return (
  227. function callback() {
  228. func.apply(_self, arguments);
  229. }
  230. );
  231. }
  232.  
  233. _self.terminate = function(){
  234. _terminate = true;
  235. if (_worker) {
  236. _worker.terminate();
  237. }
  238. };
  239. Object.defineProperty(_self, 'onmessage', {
  240. get: function() {
  241. return _onmessage;
  242. },
  243. set: function(val) {
  244. _onmessage = val;
  245. if (_worker) {
  246. _worker.onmessage = callbackWrapper(val);
  247. }
  248. }
  249. });
  250. Object.defineProperty(_self, 'onerror', {
  251. get: function() {
  252. return _onerror;
  253. },
  254. set: function(val) {
  255. _onerror = val;
  256. if (_worker) {
  257. _worker.onerror = callbackWrapper(val);
  258. }
  259. }
  260. });
  261. _self.postMessage = function(message){
  262. if (_worker) {
  263. _worker.postMessage(message);
  264. } else {
  265. _messages.push(message);
  266. }
  267. };
  268. _self.terminate = function() {
  269. _terminate = true;
  270. if (_worker) {
  271. _worker.terminate();
  272. }
  273. };
  274. _self.addEventListener = function(){
  275. if (typeof arguments[1] !== 'function') {
  276. return;
  277. }
  278. if (!_callbacks.has(arguments[1])) {
  279. _callbacks.set(arguments[1], callbackWrapper(arguments[1]));
  280. }
  281. arguments[1] = _callbacks.get(arguments[1]);
  282. if (_worker) {
  283. _worker.addEventListener.apply(_worker, arguments);
  284. } else {
  285. _events.push(['addEventListener', arguments]);
  286. }
  287. };
  288. _self.removeEventListener = function(){
  289. if (typeof arguments[1] !== 'function' || !_callbacks.has(arguments[1])) {
  290. return;
  291. }
  292. arguments[1] = _callbacks.get(arguments[1]);
  293. _callbacks.delete(arguments[1]);
  294. if (_worker) {
  295. _worker.removeEventListener.apply(_worker, arguments);
  296. } else {
  297. _events.push(['removeEventListener', arguments]);
  298. }
  299. };
  300.  
  301. if (!isBlobURL.test(resourceURI)) {
  302. _worker = new realWorker(resourceURI);
  303. return; // not a blob, no need to wrap
  304. }
  305.  
  306. xhr = new XMLHttpRequest();
  307. xhr.responseType = 'blob';
  308. try {
  309. xhr.open('GET', resourceURI, true);
  310. } catch(ignore) {
  311. _worker = new realWorker(resourceURI);
  312. return; // failed to open connection, unable to continue wrapping procedure
  313. }
  314. (new Promise(function(resolve, reject){
  315. if (xhr.readyState !== XMLHttpRequest.OPENED) {
  316. // connection wasn't opened, unable to continue wrapping procedure
  317. return reject();
  318. }
  319. xhr.onload = function(){
  320. if (this.status === 200) {
  321. var reader = new FileReader();
  322. reader.addEventListener("loadend", function() {
  323. resolve(new realWorker(URL.createObjectURL(
  324. new Blob([getWrappedCode(false)+this.result])
  325. )));
  326. });
  327. reader.readAsText(this.response);
  328. }
  329. };
  330. xhr.send();
  331. })).then(function(val) {
  332. _worker = val;
  333. _worker.onerror = callbackWrapper(_onerror);
  334. _worker.onmessage = callbackWrapper(_onmessage);
  335. var _e;
  336. while(_events.length) {
  337. _e = _events.shift();
  338. _worker[_e[0]].apply(_worker, _e[1]);
  339. }
  340. while(_messages.length) {
  341. _worker.postMessage(_messages.shift());
  342. }
  343. if (_terminate) {
  344. _worker.terminate();
  345. }
  346. }).catch(function(){});
  347.  
  348. }
  349. win.Worker = wrappedWorker.bind(safeWin);
  350. }
  351.  
  352. function CreateElementWrapper() {
  353. var realCreateElement = Document.prototype.createElement,
  354. code = encodeURIComponent('<scr'+'ipt>'+getWrappedCode(true)+'</scr'+'ipt>\n'),
  355. isDataURL = /^data:/i,
  356. isBlobURL = /^blob:/i;
  357.  
  358. function frameRewrite(e) {
  359. var f = e.target,
  360. w = f.contentWindow;
  361. if (!f.src || (w && isBlobURL.test(f.src))) {
  362. w.WebSocket = createWebSocketWrapper();
  363. }
  364. if (isDataURL.test(f.src) && f.src.indexOf(code) < 0) {
  365. f.src = f.src.replace(',',',' + code);
  366. }
  367. }
  368.  
  369. function wrappedCreateElement(name) {
  370. /*jshint validthis:true */
  371. var el = realCreateElement.apply(this, arguments);
  372. if (el.tagName === 'IFRAME') {
  373. el.addEventListener('load', frameRewrite, false);
  374. }
  375. return el;
  376. }
  377. Document.prototype.createElement = wrappedCreateElement;
  378.  
  379. document.addEventListener('DOMContentLoaded', function(){
  380. for (var ifr of document.querySelectorAll('IFRAME')) {
  381. ifr.addEventListener('load', frameRewrite, false);
  382. }
  383. }, false);
  384. }
  385.  
  386. this.init = function() {
  387. win.WebSocket = createWebSocketWrapper();
  388. if (!(/firefox/i.test(navigator.userAgent))) {
  389. WorkerWrapper(); // skip WorkerWrapper in Firefox
  390. }
  391. if (typeof document !== 'undefined') {
  392. CreateElementWrapper();
  393. }
  394. };
  395. }
  396.  
  397. if (isFirefox) {
  398. var script = document.createElement('script');
  399. script.appendChild(document.createTextNode(getWrappedCode(true)));
  400. document.head.insertBefore(script, document.head.firstChild);
  401. return; //we don't want to call functions on page from here in Fx, so exit
  402. }
  403.  
  404. (new WSI((unsafeWindow||self||window),(self||window))).init();
  405. })();
  406.  
  407. if (!isFirefox) { // scripts for non-Firefox browsers
  408.  
  409. // https://gf.qytechs.cn/scripts/14720-it-s-not-important
  410. (function(){
  411. var imptt = /((display|(margin|padding)(-top|-bottom)?)\s*:[^;!]*)!\s*important/ig;
  412.  
  413. function unimportanter(el, si) {
  414. if (!imptt.test(si) || el.style.display === 'none') {
  415. return 0; // get out if we have nothing to do here
  416. }
  417. if (el.nodeName === 'IFRAME' && el.src &&
  418. el.src.slice(0,17) === 'chrome-extension:') {
  419. return 0; // Web of Trust uses this method to add their frame
  420. }
  421. var so = si.replace(imptt, function(){return arguments[1];}), ret = 0;
  422. if (si !== so) {
  423. ret = 1;
  424. el.setAttribute('style', so);
  425. }
  426. return ret;
  427. }
  428.  
  429. function logger(c) {
  430. if (c) {
  431. console.log('Some page elements became a bit less important.');
  432. }
  433. }
  434.  
  435. function checkTarget(node, cnt) {
  436. if (!(node && node.getAttribute)) {
  437. return 0;
  438. }
  439. var si = node.getAttribute('style');
  440. if (si && si.indexOf('!') > -1) {
  441. cnt += unimportanter(node, si);
  442. }
  443. return cnt;
  444. }
  445.  
  446. var observer = new MutationObserver(function(mutations) {
  447. setTimeout(function(ms) {
  448. var cnt = 0, m, node;
  449. for (m of ms) {
  450. cnt = checkTarget(m.target, cnt);
  451. for (node of m.addedNodes) {
  452. cnt += checkTarget(node, cnt);
  453. }
  454. }
  455. logger(cnt);
  456. }, 0, mutations);
  457. });
  458.  
  459. observer.observe(document, { childList : true, attributes : true, attributeFilter : ['style'], subtree : true });
  460.  
  461. win.addEventListener ("load", function(){
  462. var c = 0, imp;
  463. for (imp of document.querySelectorAll('[style*="!"]')) {
  464. c+= checkTarget(imp, c);
  465. }
  466. logger(c);
  467. }, false);
  468. })();
  469.  
  470. }
  471.  
  472. if (/^https?:\/\/(mail\.yandex\.|music\.yandex\.|news\.yandex\.|(www\.)?yandex\.[^\/]+\/(yand)?search[\/?])/i.test(win.location.href)) {
  473. // https://gf.qytechs.cn/en/scripts/809-no-yandex-ads
  474. (function(){
  475. var adWords = ['Яндекс.Директ','Реклама','Ad'];
  476. function remove(node) {
  477. node.parentNode.removeChild(node);
  478. }
  479. // Generic ads removal and fixes
  480. function removeGenericAds() {
  481. var s, i;
  482. s = document.querySelector('.serp-header');
  483. if (s) {
  484. s.style.marginTop='0';
  485. }
  486. for (s of document.querySelectorAll('.serp-adv__head + .serp-item, #adbanner, .serp-adv, .b-spec-adv, div[class*="serp-adv__"]:not(.serp-adv__found):not(.serp-adv__displayed)')) {
  487. remove(s);
  488. }
  489. }
  490. // Search ads
  491. function removeSearchAds() {
  492. var s, item;
  493. for (s of document.querySelectorAll('.serp-block, .serp-item, .search-item')) {
  494. item = s.querySelector('.label, .serp-item__label, .document__provider-name');
  495. if (item && adWords.indexOf(item.textContent) > -1) {
  496. remove(s);
  497. console.log('Ads removed.');
  498. }
  499. }
  500. }
  501. // News ads
  502. function removeNewsAds() {
  503. for (var s of document.querySelectorAll(
  504. '.page-content__left > *,'+
  505. '.page-content__right > *:not(.page-content__col),'+
  506. '.page-content__right > .page-content__col > *'
  507. )) {
  508. if (s.textContent.indexOf(adWords[0]) > -1 ||
  509. (s.clientHeight < 15 && s.classList.contains('rubric'))) {
  510. remove(s);
  511. console.log('Ads removed.');
  512. }
  513. }
  514. }
  515. // Music ads
  516. function removeMusicAds() {
  517. for (var s of document.querySelectorAll('.ads-block')) {
  518. remove(s);
  519. }
  520. }
  521. // Mail ads
  522. function removeMailAds() {
  523. var slice = Array.prototype.slice,
  524. nodes = slice.call(document.querySelectorAll('.ns-view-folders')),
  525. node, len, classes, cls;
  526. for (node of nodes) {
  527. if (!len || len > node.classList.length) {
  528. len = node.classList.length;
  529. }
  530. }
  531. node = nodes.pop();
  532. while (node) {
  533. if (node.classList.length > len) {
  534. for (cls of slice.call(node.classList)) {
  535. if (cls.indexOf('-') === -1) {
  536. remove(node);
  537. break;
  538. }
  539. }
  540. }
  541. node = nodes.pop();
  542. }
  543. }
  544. // News fixes
  545. function removePageAdsClass() {
  546. if (document.body.classList.contains("b-page_ads_yes")){
  547. document.body.classList.remove("b-page_ads_yes");
  548. console.log('Page ads class removed.');
  549. }
  550. }
  551. // Function to attach an observer to monitor dynamic changes on the page
  552. function pageUpdateObserver(func, obj, params) {
  553. if (obj) {
  554. var o = new MutationObserver(func);
  555. o.observe(obj,(params || {childList:true, subtree:true}));
  556. }
  557. }
  558. // Cleaner
  559. document.addEventListener ('DOMContentLoaded', function() {
  560. removeGenericAds();
  561. if (win.location.hostname.search(/^mail\./i) === 0) {
  562. pageUpdateObserver(function(ms, o){
  563. var aside = document.querySelector('.mail-Layout-Aside');
  564. if (aside) {
  565. o.disconnect();
  566. pageUpdateObserver(removeMailAds, aside);
  567. }
  568. }, document.querySelector('BODY'));
  569. removeMailAds();
  570. } else if (win.location.hostname.search(/^music\./i) === 0) {
  571. pageUpdateObserver(removeMusicAds, document.querySelector('.sidebar'));
  572. removeMusicAds();
  573. } else if (win.location.hostname.search(/^news\./i) === 0) {
  574. pageUpdateObserver(removeNewsAds, document.querySelector('BODY'));
  575. pageUpdateObserver(removePageAdsClass, document.body, {attributes:true, attributesFilter:['class']});
  576. removeNewsAds();
  577. removePageAdsClass();
  578. } else {
  579. pageUpdateObserver(removeSearchAds, document.querySelector('.main__content'));
  580. removeSearchAds();
  581. }
  582. });
  583. })();
  584. return; //skip fixes for other sites
  585. }
  586.  
  587. // https://gf.qytechs.cn/en/scripts/21937-moonwalk-hdgo-kodik-fix v0.8 (adapted)
  588. document.addEventListener ('DOMContentLoaded', function() {
  589. var tmp;
  590. function log (e) {
  591. console.log('Moonwalk&HDGo&Kodik FIX: ' + e + ' player in ' + win.location.href);
  592. }
  593. if (win.adv_enabled !== undefined && win.condition_detected !== undefined) { // moonwalk
  594. log('Moonwalk');
  595. if (win.adv_enabled) {
  596. win.adv_enabled = false;
  597. }
  598. win.condition_detected = false;
  599. if (win.MXoverrollCallback) {
  600. document.addEventListener('click', function catcher(e){
  601. e.stopPropagation();
  602. win.MXoverrollCallback.call(window);
  603. document.removeEventListener('click', catcher, true);
  604. }, true);
  605. }
  606. } else if (win.stat_url !== undefined && win.is_html5 !== undefined && win.is_wp8 !== undefined) { // hdgo
  607. log('HDGo');
  608. document.body.onclick = null;
  609. tmp = document.querySelector('#swtf');
  610. if (tmp) {
  611. tmp.style.display = 'none';
  612. }
  613. if (win.banner_second !== undefined) {
  614. win.banner_second = 0;
  615. }
  616. if (win.$banner_ads !== undefined) {
  617. win.$banner_ads = false;
  618. }
  619. if (win.$new_ads !== undefined) {
  620. win.$new_ads = false;
  621. }
  622. if (win.createCookie !== undefined) {
  623. win.createCookie('popup','true','999');
  624. }
  625. if (win.canRunAds !== undefined && win.canRunAds !== true) {
  626. win.canRunAds = true;
  627. }
  628. } else if (win.MXoverrollCallback && win.iframeSearch !== undefined) { // kodik
  629. log('Kodik');
  630. tmp = document.querySelector('.play_button');
  631. if (tmp) {
  632. tmp.onclick = win.MXoverrollCallback.bind(window);
  633. }
  634. win.IsAdBlock = false;
  635. }
  636. }, false);
  637.  
  638. // function to search and remove nodes by content
  639. // selector - standard CSS selector to define set of nodes to check
  640. // words - regular expression to check content of the suspicious nodes
  641. // params - object with multiple extra parameters:
  642. // .hide - set display to none instead of removing from the page
  643. // .parent - parent node to remove if content is found in the child node
  644. // .siblings - number of simling nodes to remove (excluding text nodes)
  645. function scRemove(e) {e.parentNode.removeChild(e);}
  646. function scHide(e) {
  647. var s = e.getAttribute('style')||'',
  648. h = ';display:none!important;';
  649. if (s.indexOf(h) < 0) {
  650. e.setAttribute('style', s+h);
  651. }
  652. }
  653. function scissors (selector, words, scope, params) {
  654. var remFunc = (params.hide ? scHide : scRemove),
  655. iterFunc = (params.siblings > 0 ?
  656. 'nextSibling' :
  657. 'previousSibling'),
  658. toRemove = [],
  659. siblings,
  660. node;
  661. for (node of scope.querySelectorAll(selector)) {
  662. if (words.test(node.innerHTML) || !node.childNodes.length) {
  663. // drill up to the specified parent node if required
  664. if (params.parent) {
  665. while(node !== scope && !(node.matches(params.parent))) {
  666. node = node.parentNode;
  667. }
  668. }
  669. if (node === scope) {
  670. break;
  671. }
  672. toRemove.push(node);
  673. // add multiple nodes if defined more than one sibling
  674. siblings = Math.abs(params.siblings) || 0;
  675. while (siblings) {
  676. node = node[iterFunc];
  677. toRemove.push(node);
  678. if (node.nodeType === Node.ELEMENT_NODE) {
  679. siblings -= 1; //count only element nodes
  680. }
  681. }
  682. }
  683. }
  684. for (node of toRemove) {
  685. remFunc(node);
  686. }
  687. return toRemove.length;
  688. }
  689.  
  690. // function to perform multiple checks if ads inserted with a delay
  691. // by default does 30 checks withing a 3 seconds unless nonstop mode specified
  692. // also does 1 extra check when a page completely loads
  693. // selector and words - passed dow to scissors
  694. // params - object with multiple extra parameters:
  695. // .root - selector to narrow down scope to scan;
  696. // .observe - if true then check will be performed continuously;
  697. // Other parameters passed down to scissors.
  698. function gardener(selector, words, params) {
  699. params = params || {};
  700. var scope = document,
  701. nonstop = false;
  702. // narrow down scope to a specific element
  703. if (params.root) {
  704. scope = scope.querySelector(params.root);
  705. if (!scope) {// exit if the root element is not present on the page
  706. return 0;
  707. }
  708. }
  709. // add observe mode if required
  710. if (params.observe) {
  711. if (typeof MutationObserver === 'function') {
  712. var o = new MutationObserver(function(ms){
  713. for (var m of ms) {
  714. if (m.addedNodes.length) {
  715. scissors(selector, words, scope, params);
  716. }
  717. }
  718. });
  719. o.observe(scope, {childList:true, subtree: true});
  720. } else {
  721. nonstop = true;
  722. }
  723. }
  724. // wait for a full page load to do one extra cut
  725. win.addEventListener('load',function(){
  726. scissors(selector, words, scope, params);
  727. });
  728. // do multiple cuts until ads removed
  729. function cut(sci, s, w, sc, p, i) {
  730. if (i > 0) {
  731. i -= 1;
  732. }
  733. if (i && !sci(s, w, sc, p)) {
  734. setTimeout(cut, 100, sci, s, w, sc, p, i);
  735. }
  736. }
  737. cut(scissors, selector, words, scope, params, (nonstop ? -1 : 30));
  738. }
  739.  
  740. function preventBackgroundRedirect() {
  741. // create "cose_me" event to call high-level window.close()
  742. var key = Math.random().toString(36).substr(2);
  743. window.addEventListener('close_me_'+key, function(e) {
  744. window.close();
  745. });
  746.  
  747. // window.open wrapper
  748. function pbrLander() {
  749. var orgOpen = window.open.bind(window),
  750. idx = String.prototype.indexOf,
  751. event = new CustomEvent("close_me_%key%", {});
  752. function closeWindow(){
  753. // site went to a new tab and attempts to unload
  754. // call for high-level close through event
  755. window.dispatchEvent(event);
  756. }
  757. // window.open wrapper
  758. function open(){
  759. console.log(arguments, window.location.host);
  760. if (arguments[0] &&
  761. (idx.call(arguments[0], window.location.host) > -1 ||
  762. idx.call(arguments[0], '://') === -1)) {
  763. window.addEventListener('unload', closeWindow, true);
  764. }
  765. orgOpen.apply(window, arguments);
  766. }
  767. window.open = open.bind(window);
  768. // Node.createElement wrapper to prevent click-dispatch in Google Chrome and similar browsers
  769. var realCreateElement = Document.prototype.createElement;
  770. function wrappedCreateElement(name) {
  771. /*jshint validthis:true */
  772. var el = realCreateElement.apply(this, arguments);
  773. if (el.tagName === 'A') {
  774. el.addEventListener('click', function(e){
  775. if (!e.target.parentNode || !e.isTrusted) {
  776. window.addEventListener('unload', closeWindow, true);
  777. }
  778. }, false);
  779. }
  780. return el;
  781. }
  782. Document.prototype.createElement = wrappedCreateElement;
  783. }
  784.  
  785. // land wrapper on the page
  786. var script = document.createElement('script');
  787. script.appendChild(document.createTextNode('('+pbrLander.toString().replace(/%key%/g,key)+')();'));
  788. document.head.insertBefore(script, document.head.firstChild);
  789. script.parentNode.removeChild(script);
  790. console.log("Background redirect prevention enabled.");
  791. }
  792.  
  793. function preventPopups() {
  794. win.open = function(){
  795. console.log('Site attempted to open a new window', arguments);
  796. };
  797. window.open = win.open;
  798. var realCreateElement = Document.prototype.createElement;
  799. function wrappedCreateElement(name) {
  800. /*jshint validthis:true */
  801. var el = realCreateElement.apply(this, arguments);
  802. if (el.tagName === 'A') {
  803. el.addEventListener('click', function(e){
  804. if (!e.target.parentNode || !e.isTrusted) {
  805. e.preventDefault();
  806. console.log('Blocked suspicious click event', e, 'on', e.target);
  807. }
  808. }, false);
  809. }
  810. return el;
  811. }
  812. Document.prototype.createElement = wrappedCreateElement;
  813. }
  814.  
  815. function forbidServiceWorker() {
  816. if (!("serviceWorker" in navigator)) {
  817. return;
  818. }
  819. var svr = navigator.serviceWorker.ready;
  820. Object.defineProperty(navigator, 'serviceWorker', {
  821. value: {
  822. register: function(){
  823. console.log('Registration of serviceWorker ' + arguments[0] + ' blocked.');
  824. return new Promise(function(){});
  825. },
  826. ready: new Promise(function(){}),
  827. addEventListener:function(){}
  828. }
  829. });
  830. document.addEventListener('DOMContentLoaded', function() {
  831. if (!svr) {
  832. return;
  833. }
  834. svr.then(function(sw) {
  835. console.log('Found existing serviceWorker:', sw);
  836. console.log('Attempting to unregister...');
  837. sw.unregister().then(function() {
  838. console.log('Unregistered! :)');
  839. }).catch(function(err) {
  840. console.log('Unregistration failed. :(', err);
  841. console.log('Try to remove it manually:');
  842. console.log(' 1. Open: chrome://serviceworker-internals/ (Google Chrome and alike) or about:serviceworkers (Mozilla Firefox) in a new tab.');
  843. console.log(' 2. Search there for one with "'+document.domain+'" in the name.');
  844. console.log(' 3. Use buttons in the same block with service you found to stop it and uninstall/unregister.');
  845. });
  846. }).catch(function(err) {
  847. console.log("Lol, it failed on it's own. -_-", err);
  848. });
  849. }, false);
  850. }
  851.  
  852. var scripts = {};
  853. // prevent popups and redirects block
  854. var preventPopupsNow = { 'now': preventPopups },
  855. preventBackgroundRedirectNow = { 'now': preventBackgroundRedirect };
  856. // Popups
  857. scripts['chaturbate.com'] = preventPopupsNow;
  858. scripts['mirrorcreator.com'] = preventPopupsNow;
  859. scripts['radikal.ru'] = preventPopupsNow;
  860. scripts['tapochek.net'] = preventPopupsNow;
  861. scripts['thepiratebay.org'] = preventPopupsNow;
  862. scripts['zippyshare.com'] = preventPopupsNow;
  863. // Background redirects
  864. scripts['mediafire.com'] = preventBackgroundRedirectNow;
  865. scripts['megapeer.org'] = preventBackgroundRedirectNow;
  866. scripts['megapeer.ru'] = preventBackgroundRedirectNow;
  867. scripts['turbobit.net'] = preventBackgroundRedirectNow;
  868.  
  869. // other
  870. scripts['4pda.ru'] = {
  871. 'now': function() {
  872. // https://gf.qytechs.cn/en/scripts/14470-4pda-unbrender
  873. var isForum = document.location.href.search('/forum/') !== -1,
  874. hStyle;
  875.  
  876. function remove(n) {
  877. if (n) {
  878. n.parentNode.removeChild(n);
  879. }
  880. }
  881.  
  882. function afterClean() {
  883. hStyle.disabled = true;
  884. remove(hStyle);
  885. }
  886.  
  887. function beforeClean() {
  888. // attach styles before document displayed
  889. hStyle = createStyle([
  890. 'html { overflow-y: scroll }',
  891. 'section[id] {'+(
  892. 'position: absolute;'+
  893. 'width: 100%'
  894. )+'}',
  895. 'article + aside * { display: none !important }',
  896. '#header + div:after {'+(
  897. 'content: "";'+
  898. 'position: fixed;'+
  899. 'top: 0;'+
  900. 'left: 0;'+
  901. 'width: 100%;'+
  902. 'height: 100%;'+
  903. 'background-color: #E6E7E9'
  904. )+'}',
  905. // http://codepen.io/Beaugust/pen/DByiE
  906. '@keyframes spin { 100% { transform: rotate(360deg) } }',
  907. 'article + aside:after {'+(
  908. 'content: "";'+
  909. 'position: absolute;'+
  910. 'width: 150px;'+
  911. 'height: 150px;'+
  912. 'top: 150px;'+
  913. 'left: 50%;'+
  914. 'margin-top: -75px;'+
  915. 'margin-left: -75px;'+
  916. 'box-sizing: border-box;'+
  917. 'border-radius: 100%;'+
  918. 'border: 10px solid rgba(0, 0, 0, 0.2);'+
  919. 'border-top-color: rgba(0, 0, 0, 0.6);'+
  920. 'animation: spin 2s infinite linear'
  921. )+'}'
  922. ], {id:'ubrHider'}, true);
  923.  
  924. // display content of a page if time to load a page is more than 2 seconds to avoid
  925. // blocking access to a page if it is loading for too long or stuck in a loading state
  926. setTimeout(2000, afterClean);
  927. }
  928.  
  929. createStyle([
  930. '#nav .use-ad { display: block !important }',
  931. 'article:not(.post) + article:not(#id), a[target="_blank"] img[height="90"] { display: none !important }'
  932. ]);
  933.  
  934. if (!isForum) {
  935. beforeClean();
  936. }
  937.  
  938. // save links to non-overridden functions to use later
  939. var oGA = Element.prototype.getAttribute,
  940. oSA = Element.prototype.setAttribute,
  941. protectedElems;
  942. // protect/hide changed attributes in case site attempt to restore them
  943. function styleProtector(eventMode) {
  944. var oRAN = Element.prototype.removeAttributeNode,
  945. isStyleText = function(t){ return t === 'style'; },
  946. isStyleAttr = function(a){ return a instanceof Attr && a.nodeName === 'style'; },
  947. returnUndefined = function(){},
  948. protectedElems = new WeakMap();
  949. function protoOverride(element, functionName, isStyleCheck, returnIfProtected) {
  950. var oF = element.prototype[functionName], r;
  951. element.prototype[functionName] = function(){
  952. if (protectedElems.get(this) !== undefined && isStyleCheck(arguments[0])) {
  953. return returnIfProtected(protectedElems.get(this), arguments, this);
  954. }
  955. r = oF.apply(this, arguments)
  956. return r;
  957. };
  958. }
  959. protoOverride(Element, 'removeAttribute', isStyleText, returnUndefined);
  960. protoOverride(Element, 'hasAttribute', isStyleText, function(o) {
  961. return o.oldStyle !== null;
  962. });
  963. protoOverride(Element, 'setAttribute', isStyleText, function(o, args) {
  964. o.oldStyle = args[1];
  965. });
  966. protoOverride(Element, 'getAttribute', isStyleText, function(o) {
  967. return o.oldStyle;
  968. });
  969. if (eventMode) {
  970. var e = document.createEvent('Event');
  971. e.initEvent('protoOverride', false, false);
  972. window.protectedElems = protectedElems;
  973. window.dispatchEvent(e);
  974. } else {
  975. return protectedElems;
  976. }
  977. }
  978. if (isFirefox) {
  979. var s = document.createElement('script');
  980. s.textContent = '(' + styleProtector.toString() + ')(true);' +
  981. 'var s = document.currentScript; if (s) {s.parentNode.removeChild(s);}';
  982. window.addEventListener('protoOverride', function protoOverrideCallback(e){
  983. if (win.protectedElems) {
  984. protectedElems = win.protectedElems;
  985. delete win.protectedElems;
  986. }
  987. document.removeEventListener('protoOverride', protoOverrideCallback, true);
  988. }, true);
  989. document.documentElement.appendChild(s);
  990. } else {
  991. protectedElems = styleProtector(false);
  992. }
  993.  
  994. // clean a page
  995. window.addEventListener('DOMContentLoaded', function(){
  996. var rem, si, itm;
  997. function width(){ return window.innerWidth||document.documentElement.clientWidth||document.body.clientWidth||0; }
  998. function height(){ return window.innerHeight||document.documentElement.clientHeight||document.body.clientHeight||0; }
  999.  
  1000.  
  1001. if (isForum) {
  1002. si = document.querySelector('#logostrip');
  1003. if (si) {
  1004. remove(si.parentNode.nextSibling);
  1005. }
  1006. }
  1007.  
  1008. if (document.location.href.search('/forum/dl/') !== -1) {
  1009. document.body.setAttribute('style', (document.body.getAttribute('style')||'')+
  1010. ';background-color:black!important');
  1011. for (itm of document.querySelectorAll('body>div')) {
  1012. if (!itm.querySelector('.dw-fdwlink')) {
  1013. remove(itm);
  1014. }
  1015. }
  1016. }
  1017.  
  1018. if (isForum) { // Do not continue if it's a forum
  1019. return;
  1020. }
  1021.  
  1022. si = document.querySelector('#header');
  1023. if (si) {
  1024. rem = si.previousSibling;
  1025. while (rem) {
  1026. si = rem.previousSibling;
  1027. remove(rem);
  1028. rem = si;
  1029. }
  1030. }
  1031.  
  1032. for (itm of document.querySelectorAll('#nav li[class]')) {
  1033. if (itm && itm.querySelector('a[href^="/tag/"]')) {
  1034. remove(itm);
  1035. }
  1036. }
  1037.  
  1038. var style, result;
  1039. for (itm of document.querySelectorAll('DIV, A')) {
  1040. if (itm.tagName ==='DIV' && itm.offsetWidth > 0.95 * width() && itm.offsetHeight > 0.85 * height()) {
  1041. style = window.getComputedStyle(itm, null);
  1042. result = [];
  1043. if (style.backgroundImage !== 'none') {
  1044. result.push('background-image:none!important');
  1045. }
  1046. if (style.backgroundColor !== 'transparent' &&
  1047. style.backgroundColor !== 'rgba(0, 0, 0, 0)') {
  1048. result.push('background-color:transparent!important');
  1049. }
  1050. if (result.length) {
  1051. if (itm.getAttribute('style')) {
  1052. result.unshift(itm.getAttribute('style'));
  1053. }
  1054. (function(){
  1055. var fakeStyle = {
  1056. 'backgroundImage': itm.style.backgroundImage,
  1057. 'backgroundColor': itm.style.backgroundColor
  1058. };
  1059. try {
  1060. Object.defineProperty(itm, 'style', {
  1061. value: new Proxy(itm.style, {
  1062. get: function(target, prop){
  1063. if (fakeStyle.hasOwnProperty(prop)) {
  1064. return fakeStyle[prop];
  1065. } else {
  1066. return target[prop];
  1067. }
  1068. },
  1069. set: function(target, prop, value){
  1070. if (fakeStyle.hasOwnProperty(prop)) {
  1071. fakeStyle[prop] = value;
  1072. } else {
  1073. target[prop] = value;
  1074. }
  1075. return value;
  1076. }
  1077. }),
  1078. enumerable: true
  1079. });
  1080. } catch (e) {
  1081. console.log('Unable to protect style property.', e);
  1082. }
  1083. })();
  1084. if (protectedElems) {
  1085. protectedElems.set(itm, {oldStyle: oGA.call(itm, 'style')});
  1086. }
  1087. oSA.call(itm, 'style', result.join(';'));
  1088. }
  1089. }
  1090. if (itm.tagName ==='A' && (itm.offsetWidth > 0.95 * width() || itm.offsetHeight > 0.85 * height())) {
  1091. if (protectedElems) {
  1092. protectedElems.set(itm, {oldStyle: oGA.call(itm, 'style')});
  1093. }
  1094. oSA.call(itm, 'style', 'display:none!important');
  1095. }
  1096. }
  1097.  
  1098. for (itm of document.querySelectorAll('ASIDE>DIV')) {
  1099. if ( ((itm.querySelector('script, iframe, a[href*="/ad/www/"]') ||
  1100. itm.querySelector('img[src$=".gif"]:not([height="0"]), img[height="400"]')) &&
  1101. !itm.classList.contains('post') ) || !itm.childNodes.length ) {
  1102. remove(itm);
  1103. }
  1104. }
  1105.  
  1106. document.body.setAttribute('style', (document.body.getAttribute('style')||'')+';background-color:#E6E7E9!important');
  1107.  
  1108. // display content of the page
  1109. afterClean();
  1110. });
  1111. }
  1112. };
  1113.  
  1114. scripts['allmovie.pro'] = function() {
  1115. // pretend to be Android to make site use different played for ads
  1116. if (isSafari) {
  1117. return;
  1118. }
  1119. Object.defineProperty(navigator, 'userAgent', {
  1120. get: function(){ return 'Mozilla/5.0 (Linux; Android 4.1.1; Nexus 7 Build/JRO03D) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.166 Safari/535.19' },
  1121. enumerable: true
  1122. });
  1123. }
  1124. scripts['rufilmtv.org'] = scripts['allmovie.pro'];
  1125.  
  1126. scripts['anidub-online.ru'] = function() {
  1127. var script = document.createElement('script');
  1128. script.type = "text/javascript";
  1129. script.innerHTML = "function ogonekstart1() {}";
  1130. document.getElementsByTagName('head')[0].appendChild(script);
  1131.  
  1132. var style = document.createElement('style');
  1133. style.type = 'text/css';
  1134. style.appendChild(document.createTextNode('.background {background: none!important;}'));
  1135. style.appendChild(document.createTextNode('.background > script + div, .background > script ~ div:not([id]):not([class]) + div[id][class] {display:none!important}'));
  1136. document.head.appendChild(style);
  1137. };
  1138. scripts['online.anidub.com'] = scripts['anidub-online.ru'];
  1139.  
  1140. scripts['fs.to'] = function() {
  1141. function skipClicker(i) {
  1142. if (!i) {
  1143. return;
  1144. }
  1145. var skip = document.querySelector('.b-aplayer-banners__close');
  1146. if (skip) {
  1147. skip.click();
  1148. } else {
  1149. setTimeout(skipClicker, 100, i-1);
  1150. }
  1151. }
  1152. setTimeout(skipClicker, 100, 30);
  1153.  
  1154. createStyle([
  1155. '.l-body-branding *,'+
  1156. '.b-styled__item-central,'+
  1157. '.b-styled__content-right,'+
  1158. '.b-styled__section-central,'+
  1159. 'div[id^="adsProxy-"]'+
  1160. '{display:none!important}',
  1161. 'body {background-image:url(data:image/png;base64,'+
  1162. 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAACX'+
  1163. 'BIWXMAAC4jAAAuIwF4pT92AAAADUlEQVR42mOQUdL5DwACMgFq'+
  1164. 'BC3ttwAAAABJRU5ErkJggg==)!important}'
  1165. ]);
  1166.  
  1167. if (/\/(view_iframe|iframeplayer)\//i.test(document.location.pathname)) {
  1168. var p = document.querySelector('#player:not([preload="auto"])'),
  1169. m = document.querySelector('.main'),
  1170. adStepper = function(p) {
  1171. if (p.currentTime < p.duration) {
  1172. p.currentTime += 1;
  1173. }
  1174. },
  1175. adSkipper = function(f, p) {
  1176. f.click();
  1177. p.waitAfterSkip = false;
  1178. p.longerSkipper = false;
  1179. console.log('Пропустили.');
  1180. },
  1181. cl = function(p) {
  1182. var faster = document.querySelector('.b-aplayer__html5-desktop-skip'),
  1183. series = document.querySelector('.b-aplayer__actions-series');
  1184.  
  1185. function clickSelected() {
  1186. var s = document.querySelector('.b-aplayer__popup-series-episodes .selected a');
  1187. if (s) {
  1188. s.click();
  1189. }
  1190. }
  1191.  
  1192. if ((!faster || faster.style.display !== 'block') && series && !p.seriesClicked) {
  1193. series.click();
  1194. p.seriesClicked = true;
  1195. p.longerSkipper = true;
  1196. setTimeout(clickSelected, 1000);
  1197. p.pause();
  1198. }
  1199.  
  1200. function skipListener() {
  1201. if (p.waitAfterSkip) {
  1202. console.log('В процессе пропуска…');
  1203. return;
  1204. }
  1205. p.pause();
  1206. if (!p.classList.contains('m-hidden')) {
  1207. p.classList.add('m-hidden');
  1208. }
  1209. if (faster && p.currentTime &&
  1210. win.getComputedStyle(faster).display === 'block' &&
  1211. !faster.querySelector('.b-aplayer__html5-desktop-skip-timer')) {
  1212. p.waitAfterSkip = true;
  1213. setTimeout(adSkipper, (p.longerSkipper?3:1)*1000, faster, p);
  1214. console.log('Доступен быстрый пропуск…');
  1215. } else {
  1216. setTimeout(adStepper, 1000, p);
  1217. }
  1218. }
  1219.  
  1220. p.addEventListener('timeupdate', skipListener, false);
  1221. },
  1222. o = new MutationObserver(function (ms) {
  1223. var m, node;
  1224. for (m of ms) {
  1225. for (node of m.addedNodes) {
  1226. if (node.id === 'player' &&
  1227. node.nodeName === 'VIDEO' &&
  1228. node.getAttribute('preload') !== 'auto') {
  1229. cl(node);
  1230. }
  1231. }
  1232. }
  1233. });
  1234. if (p.nodeName === 'VIDEO') {
  1235. cl(p);
  1236. } else {
  1237. o.observe(m, {childList: true});
  1238. }
  1239. }
  1240. };
  1241. scripts['brb.to'] = scripts['fs.to'];
  1242. scripts['cxz.to'] = scripts['fs.to'];
  1243.  
  1244. scripts['drive2.ru'] = function() {
  1245. gardener('.c-block:not([data-metrika="recomm"]),.o-grid__item', />Реклама<\//i);
  1246. };
  1247.  
  1248. scripts['fishki.net'] = function() {
  1249. gardener('.main-post', /543769|Реклама/);
  1250. };
  1251.  
  1252. scripts['gidonline.club'] = {
  1253. 'now': function() {
  1254. createStyle('.tray > div[style] {display: none!important}');
  1255. }
  1256. };
  1257. scripts['gidonlinekino.com'] = scripts['gidonline.club'];
  1258.  
  1259. scripts['hdgo.cc'] = {
  1260. 'now': function(){
  1261. var o = new MutationObserver(function(ms) {
  1262. var m, node;
  1263. for (m of ms) {
  1264. for (node of m.addedNodes) {
  1265. if (node.tagName === 'SCRIPT' && node.getAttribute('onerror') !== null) {
  1266. node.removeAttribute('onerror');
  1267. }
  1268. }
  1269. }
  1270. });
  1271. o.observe(document, {childList:true, subtree: true});
  1272. }
  1273. };
  1274. scripts['couber.be'] = scripts['hdgo.cc'];
  1275. scripts['46.30.43.38'] = scripts['hdgo.cc'];
  1276.  
  1277. scripts['gismeteo.ru'] = {
  1278. 'DOMContentLoaded': function() {
  1279. gardener('div > a[target^="_"]', /Яндекс\.Директ/i, { root: 'body', observe: true, parent: 'div[class*="frame"]' });
  1280. }
  1281. };
  1282.  
  1283. scripts['hdrezka.me'] = {
  1284. 'now': function() {
  1285. Object.defineProperty(win, 'fuckAdBlock', {
  1286. value: {
  1287. onDetected: function() {
  1288. console.log('Pretending to be an ABP detector.');
  1289. }
  1290. }
  1291. });
  1292. Object.defineProperty(win, 'ab', {
  1293. value: false,
  1294. enumerable: true
  1295. });
  1296. },
  1297. 'DOMContentLoaded': function() {
  1298. gardener('div[id][onclick][onmouseup][onmousedown]', /onmouseout/i);
  1299. }
  1300. };
  1301.  
  1302. scripts['imageban.ru'] = {
  1303. 'now': preventBackgroundRedirect,
  1304. 'DOMContentLoaded': function() {
  1305. win.addEventListener('unload', function() {
  1306. if (!window.location.hash) {
  1307. window.location.replace(window.location+'#');
  1308. } else {
  1309. window.location.hash = '';
  1310. }
  1311. }, true);
  1312. }
  1313. };
  1314.  
  1315. scripts['megogo.net'] = {
  1316. 'now': function() {
  1317. Object.defineProperty(win, "adBlock", {
  1318. value : false,
  1319. enumerable : true
  1320. });
  1321. Object.defineProperty(win, "showAdBlockMessage", {
  1322. value : function () {},
  1323. enumerable : true
  1324. });
  1325. }
  1326. };
  1327.  
  1328. scripts['naruto-base.su'] = function() {
  1329. gardener('div[id^="entryID"],.block', /href="http.*?target="_blank"/i);
  1330. };
  1331.  
  1332. scripts['overclockers.ru'] = {
  1333. 'now': function() {
  1334. createStyle('.fixoldhtml {display:block!important}');
  1335. if (!isChrome && !isOpera) {
  1336. return; // Looks like my code works only in Chrome-like browsers
  1337. }
  1338. var noContentYet = true;
  1339. function jWrap() {
  1340. var _$ = win.$, _e = _$.extend;
  1341. win.$ = function() {
  1342. var _ret = _$.apply(window, arguments);
  1343. if (_ret[0] === document.body) {
  1344. _ret.html = function() {
  1345. console.log('Anti-adblock prevented.');
  1346. };
  1347. }
  1348. return _ret;
  1349. };
  1350. win.$.extend = function() {
  1351. return _e.apply(_$, arguments);
  1352. }
  1353. win.jQuery = win.$;
  1354. }
  1355. (function jReady() {
  1356. if (!win.$ && noContentYet) {
  1357. setTimeout(jReady, 0);
  1358. } else {
  1359. jWrap();
  1360. }
  1361. })();
  1362. document.addEventListener ('DOMContentLoaded', function(){
  1363. noContentYet = false;
  1364. }, false);
  1365. }
  1366. };
  1367. scripts['forums.overclockers.ru'] = {
  1368. 'now': function() {
  1369. createStyle('.needblock {position: fixed; left: -10000px}');
  1370. Object.defineProperty(win, 'adblck', {
  1371. value: 'no',
  1372. enumerable: true
  1373. });
  1374. }
  1375. };
  1376.  
  1377. scripts['pb.wtf'] = function() {
  1378. createStyle('.reques,#result,tbody.row1:not([id]) {display: none !important}');
  1379. // image in the slider in the header
  1380. gardener('a[href$="=="]', /img/i, {root:'.release-navbar', observe:true, parent:'div'});
  1381. // ads in blocks on the page
  1382. gardener('a[href^="/"]', /<img\s.*<br>/i, {root:'#main_content', observe:true, parent:'div[class]'});
  1383. // line above topic content
  1384. gardener('.re_top1', /./, {root:'#main_content', parent:'.hidden-sm'});
  1385. };
  1386. scripts['piratbit.org'] = scripts['pb.wtf'];
  1387. scripts['piratbit.ru'] = scripts['pb.wtf'];
  1388.  
  1389. scripts['pesnik.su'] = {
  1390. 'now': function() {
  1391. win.Worker = function(){
  1392. console.log('Site attempted to create a WebWorker:', arguments);
  1393. return {postMessage:function(){}};
  1394. };
  1395. }
  1396. }
  1397.  
  1398. scripts['pikabu.ru'] = function() {
  1399. gardener('.story', /story__sponsor|story__gag|profile\/ads"/i, {root: '.inner_wrap', observe: true});
  1400. };
  1401.  
  1402. scripts['rp5.ru'] = function() {
  1403. createStyle('#bannerBottom {display: none!important}');
  1404. var co = document.querySelector('#content'), i, nodes;
  1405. if (!co) {
  1406. return;
  1407. }
  1408. nodes = co.parentNode.childNodes;
  1409. i = nodes.length;
  1410. while (i--) {
  1411. if (nodes[i] !== co) {
  1412. nodes[i].parentNode.removeChild(nodes[i]);
  1413. }
  1414. }
  1415. };
  1416. scripts['rp5.by'] = scripts['rp5.ru'];
  1417. scripts['rp5.ua'] = scripts['rp5.ru'];
  1418.  
  1419. scripts['rustorka.com'] = {
  1420. 'now': function() {
  1421. createStyle('.header > div:not(.head-block) a, #sidebar1 img, #logo img {opacity:0!important}', {
  1422. id: 'tempHidingStyles'
  1423. }, true);
  1424. preventPopups();
  1425. },
  1426. 'DOMContentLoaded': function() {
  1427. for (var o of document.querySelectorAll('IMG, A')) {
  1428. if ((o.clientWidth === 728 && o.clientHeight === 90) ||
  1429. (o.clientWidth === 300 && o.clientHeight === 250)) {
  1430. while (o && o.tagName !== 'A') {
  1431. o = o.parentNode;
  1432. }
  1433. if (o) {
  1434. o.setAttribute('style', 'display: none !important');
  1435. }
  1436. }
  1437. }
  1438. var s = document.querySelector('#tempHidingStyles');
  1439. s.parentNode.removeChild(s);
  1440. }
  1441. };
  1442. scripts['rumedia.ws'] = scripts['rustorka.com'];
  1443.  
  1444. scripts['sport-express.ru'] = function() {
  1445. gardener('.js-relap__item',/>Реклама\s+<\//, {root:'.container', observe: true});
  1446. };
  1447.  
  1448. scripts['sports.ru'] = function() {
  1449. gardener('.aside-news-list__item', /aside-news-list__advert/i, {root:'.aside-news-block'});
  1450. gardener('.material-list__item', /Реклама/i, {root:'.columns-layout', observe: true});
  1451. // extra functionality: shows/hides panel at the top depending on scroll direction
  1452. createStyle([
  1453. '.user-panel__fixed { transition: top 0.2s ease-in-out!important; }',
  1454. '.user-panel-up { top: -40px!important }'
  1455. ], {id: 'userPanelSlide'}, false);
  1456. (function lookForPanel() {
  1457. var panel = document.querySelector('.user-panel__fixed');
  1458. if (!panel) {
  1459. setTimeout(lookForPanel, 100);
  1460. } else {
  1461. window.addEventListener('wheel', function(e){
  1462. if (e.deltaY > 0 && !panel.classList.contains('user-panel-up')) {
  1463. panel.classList.add('user-panel-up');
  1464. } else
  1465. if (e.deltaY < 0 && panel.classList.contains('user-panel-up')) {
  1466. panel.classList.remove('user-panel-up');
  1467. };
  1468. }, false);
  1469. }
  1470. })();
  1471. };
  1472.  
  1473. scripts['vk.com'] = function() {
  1474. gardener('div[data-post-id]', /wall_marked_as_ads/, {root: '#page_wall_posts', observe: true});
  1475. };
  1476.  
  1477. scripts['yap.ru'] = function() {
  1478. var words = /member1438|Administration/;
  1479. gardener('form > table[id^="p_row_"]', words);
  1480. gardener('tr > .holder.newsbottom', words, {parent:'tr', siblings:-2});
  1481. };
  1482. scripts['yaplakal.com'] = scripts['yap.ru'];
  1483.  
  1484. scripts['reactor.cc'] = {
  1485. 'now': function() {
  1486. win.open = (function(){ throw new Error('Redirect prevention.'); }).bind(window);
  1487. },
  1488. 'click': function(e) {
  1489. var node = e.target;
  1490. if (node.nodeType === Node.ELEMENT_NODE &&
  1491. node.style.position === 'absolute' &&
  1492. node.style.zIndex > 0)
  1493. node.parentNode.removeChild(node);
  1494. },
  1495. 'DOMContentLoaded': function() {
  1496. var words = new RegExp(
  1497. 'блокировщика рекламы'
  1498. .split('')
  1499. .map(function(e){return e+'[\u200b\u200c\u200d]*';})
  1500. .join('')
  1501. .replace(' ', '\\s*')
  1502. .replace(/[аоре]/g, function(e){return ['[аa]','[оo]','[рp]','[еe]']['аоре'.indexOf(e)];}),
  1503. 'i'),
  1504. can;
  1505. function deeper(spider) {
  1506. var c, l, n;
  1507. if (words.test(spider.innerText)) {
  1508. if (spider.nodeType === Node.TEXT_NODE) {
  1509. return true;
  1510. }
  1511. c = spider.childNodes;
  1512. l = c.length;
  1513. n = 0;
  1514. while(l--) {
  1515. if (deeper(c[l]), can) {
  1516. n++;
  1517. }
  1518. }
  1519. if (n > 0 && n === c.length && spider.offsetHeight < 750) {
  1520. can.push(spider);
  1521. }
  1522. return false;
  1523. }
  1524. return true;
  1525. }
  1526. function probe(){
  1527. if (words.test(document.body.innerText)) {
  1528. can = [];
  1529. deeper(document.body);
  1530. var i = can.length, j, spider;
  1531. while(i--) {
  1532. spider = can[i];
  1533. if (spider.offsetHeight > 10 && spider.offsetHeight < 750) {
  1534. spider.setAttribute('style', 'background:none!important');
  1535. }
  1536. }
  1537. }
  1538. }
  1539. var o = new MutationObserver(probe);
  1540. o.observe(document,{childList:true, subtree:true});
  1541. }
  1542. };
  1543. scripts['joyreactor.cc'] = scripts['reactor.cc'];
  1544. scripts['pornreactor.cc'] = scripts['reactor.cc'];
  1545.  
  1546. scripts['auto.ru'] = function() {
  1547. var words = /Реклама|Яндекс.Директ|yandex_ad_/;
  1548. var userAdsListAds = [
  1549. '.listing-list > .listing-item',
  1550. '.listing-item_type_fixed.listing-item'
  1551. ];
  1552. var catalogAds = [
  1553. 'div[class*="layout_catalog-inline"]',
  1554. 'div[class$="layout_horizontal"]'
  1555. ];
  1556. var otherAds = [
  1557. '.advt_auto',
  1558. '.sidebar-block',
  1559. '.pager-listing + div[class]',
  1560. '.card > div[class][style]',
  1561. '.sidebar > div[class]',
  1562. '.main-page__section + div[class]',
  1563. '.listing > tbody'];
  1564. gardener(userAdsListAds.join(','), words, {root:'.listing-wrap', observe:true});
  1565. gardener(catalogAds.join(','), words, {root:'.catalog__page,.content__wrapper', observe:true});
  1566. gardener(otherAds.join(','), words);
  1567. };
  1568.  
  1569. scripts['rsload.net'] = {
  1570. 'load': function() {
  1571. var dis = document.querySelector('.cb-disabless');
  1572. if (dis) {
  1573. dis.click();
  1574. }
  1575. },
  1576. 'click': function(e) {
  1577. var t = e.target;
  1578. if (t && t.href && (/:\/\/\d+\.\d+\.\d+\.\d+\//.test(t.href))) {
  1579. t.href = t.href.replace('://','://rsload.net:rsload.net@');
  1580. }
  1581. }
  1582. };
  1583.  
  1584. var domain = document.domain, name;
  1585. while (domain.indexOf('.') !== -1) {
  1586. if (scripts.hasOwnProperty(domain)) {
  1587. if (typeof scripts[domain] === 'function') {
  1588. document.addEventListener ('DOMContentLoaded', scripts[domain], false);
  1589. }
  1590. for (name in scripts[domain]) {
  1591. if (name !== 'now') {
  1592. (name === 'load' ? window : document)
  1593. .addEventListener (name, scripts[domain][name], false);
  1594. } else {
  1595. scripts[domain][name]();
  1596. }
  1597. }
  1598. }
  1599. domain = domain.slice(domain.indexOf('.') + 1);
  1600. }
  1601. })();

QingJ © 2025

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