RU AdList JS Fixes

try to take over the world!

当前为 2016-12-17 提交的版本,查看 最新版本

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