RU AdList JS Fixes

try to take over the world!

目前为 2017-01-13 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name RU AdList JS Fixes
  3. // @namespace ruadlist_js_fixes
  4. // @version 20170113.0
  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://greasyfork.org/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://greasyfork.org/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://greasyfork.org/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://greasyfork.org/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. function closeWindow(){
  751. // site went to a new tab and attempts to unload
  752. // call for high-level close through event
  753. var event = new CustomEvent("close_me_%key%", {});
  754. window.dispatchEvent(event);
  755. }
  756. function open(){
  757. var idx = String.prototype.indexOf;
  758. if (arguments[0] &&
  759. (idx.call(arguments[0], window.location.host) > -1 ||
  760. idx.call(arguments[0], '://') === -1)) {
  761. window.addEventListener('unload', closeWindow, true);
  762. }
  763. orgOpen.apply(window, arguments);
  764. }
  765. window.open = open.bind(window);
  766. var s = document.currentScript;
  767. if (s) {s.parentNode.removeChild(s);}
  768. }
  769.  
  770. // land wrapper on the page
  771. var script = document.createElement('script');
  772. script.appendChild(document.createTextNode('('+pbrLander.toString().replace(/%key%/g,key)+')();'));
  773. document.head.insertBefore(script,document.head.firstChild);
  774. console.log("Background redirect prevention enabled.");
  775. }
  776.  
  777. function preventPopups() {
  778. win.open = function(){
  779. console.log('Site attempted to open a new window', arguments);
  780. };
  781. window.open = win.open;
  782. var realCreateElement = Document.prototype.createElement;
  783. function wrappedCreateElement(name) {
  784. /*jshint validthis:true */
  785. var el = realCreateElement.apply(this, arguments);
  786. if (el.tagName === 'A') {
  787. el.addEventListener('click', function(e){
  788. if (!e.target.parentNode || !e.isTrusted) {
  789. e.preventDefault();
  790. console.log('Blocked suspicious click event', e, 'on', e.target);
  791. }
  792. }, false);
  793. }
  794. return el;
  795. }
  796. Document.prototype.createElement = wrappedCreateElement;
  797. }
  798.  
  799. function forbidServiceWorker() {
  800. if (!("serviceWorker" in navigator)) {
  801. return;
  802. }
  803. var svr = navigator.serviceWorker.ready;
  804. Object.defineProperty(navigator, 'serviceWorker', {
  805. value: {
  806. register: function(){
  807. console.log('Registration of serviceWorker ' + arguments[0] + ' blocked.');
  808. return new Promise(function(){});
  809. },
  810. ready: new Promise(function(){}),
  811. addEventListener:function(){}
  812. }
  813. });
  814. document.addEventListener('DOMContentLoaded', function() {
  815. if (!svr) {
  816. return;
  817. }
  818. svr.then(function(sw) {
  819. console.log('Found existing serviceWorker:', sw);
  820. console.log('Attempting to unregister...');
  821. sw.unregister().then(function() {
  822. console.log('Unregistered! :)');
  823. }).catch(function(err) {
  824. console.log('Unregistration failed. :(', err);
  825. console.log('Try to remove it manually:');
  826. console.log(' 1. Open: chrome://serviceworker-internals/ (Google Chrome and alike) or about:serviceworkers (Mozilla Firefox) in a new tab.');
  827. console.log(' 2. Search there for one with "'+document.domain+'" in the name.');
  828. console.log(' 3. Use buttons in the same block with service you found to stop it and uninstall/unregister.');
  829. });
  830. }).catch(function(err) {
  831. console.log("Lol, it failed on it's own. -_-", err);
  832. });
  833. }, false);
  834. }
  835.  
  836. var scripts = {};
  837. // prevent popups and redirects block
  838. var preventPopupsNow = { 'now': preventPopups },
  839. preventBackgroundRedirectNow = { 'now': preventBackgroundRedirect };
  840. // Popups
  841. scripts['chaturbate.com'] = preventPopupsNow;
  842. scripts['mirrorcreator.com'] = preventPopupsNow;
  843. scripts['tapochek.net'] = preventPopupsNow;
  844. scripts['thepiratebay.org'] = preventPopupsNow;
  845. scripts['zippyshare.com'] = preventPopupsNow;
  846. // Background redirects
  847. scripts['mediafire.com'] = preventBackgroundRedirectNow;
  848. scripts['turbobit.net'] = preventBackgroundRedirectNow;
  849.  
  850. // other
  851. scripts['4pda.ru'] = {
  852. 'now': function() {
  853. // https://greasyfork.org/en/scripts/14470-4pda-unbrender
  854. var isForum = document.location.href.search('/forum/') !== -1,
  855. hStyle;
  856.  
  857. function remove(n) {
  858. if (n) {
  859. n.parentNode.removeChild(n);
  860. }
  861. }
  862.  
  863. function afterClean() {
  864. hStyle.disabled = true;
  865. remove(hStyle);
  866. }
  867.  
  868. function beforeClean() {
  869. // attach styles before document displayed
  870. hStyle = createStyle([
  871. 'html { overflow-y: scroll }',
  872. 'section[id] {'+(
  873. 'position: absolute;'+
  874. 'width: 100%'
  875. )+'}',
  876. 'article + aside * { display: none !important }',
  877. '#header + div:after {'+(
  878. 'content: "";'+
  879. 'position: fixed;'+
  880. 'top: 0;'+
  881. 'left: 0;'+
  882. 'width: 100%;'+
  883. 'height: 100%;'+
  884. 'background-color: #E6E7E9'
  885. )+'}',
  886. // http://codepen.io/Beaugust/pen/DByiE
  887. '@keyframes spin { 100% { transform: rotate(360deg) } }',
  888. 'article + aside:after {'+(
  889. 'content: "";'+
  890. 'position: absolute;'+
  891. 'width: 150px;'+
  892. 'height: 150px;'+
  893. 'top: 150px;'+
  894. 'left: 50%;'+
  895. 'margin-top: -75px;'+
  896. 'margin-left: -75px;'+
  897. 'box-sizing: border-box;'+
  898. 'border-radius: 100%;'+
  899. 'border: 10px solid rgba(0, 0, 0, 0.2);'+
  900. 'border-top-color: rgba(0, 0, 0, 0.6);'+
  901. 'animation: spin 2s infinite linear'
  902. )+'}'
  903. ], {id:'ubrHider'}, true);
  904.  
  905. // display content of a page if time to load a page is more than 2 seconds to avoid
  906. // blocking access to a page if it is loading for too long or stuck in a loading state
  907. setTimeout(2000, afterClean);
  908. }
  909.  
  910. createStyle([
  911. '#nav .use-ad { display: block !important }',
  912. 'article:not(.post) + article:not(#id), a[target="_blank"] img[height="90"] { display: none !important }'
  913. ]);
  914.  
  915. if (!isForum) {
  916. beforeClean();
  917. }
  918.  
  919. // save links to non-overridden functions to use later
  920. var oGA = Element.prototype.getAttribute,
  921. oSA = Element.prototype.setAttribute,
  922. protectedElems;
  923. // protect/hide changed attributes in case site attempt to restore them
  924. function styleProtector(eventMode) {
  925. var oRAN = Element.prototype.removeAttributeNode,
  926. isStyleText = function(t){ return t === 'style'; },
  927. isStyleAttr = function(a){ return a instanceof Attr && a.nodeName === 'style'; },
  928. returnUndefined = function(){},
  929. protectedElems = new WeakMap();
  930. function protoOverride(element, functionName, isStyleCheck, returnIfProtected) {
  931. var oF = element.prototype[functionName], r;
  932. element.prototype[functionName] = function(){
  933. if (protectedElems.get(this) !== undefined && isStyleCheck(arguments[0])) {
  934. return returnIfProtected(protectedElems.get(this), arguments, this);
  935. }
  936. r = oF.apply(this, arguments)
  937. return r;
  938. };
  939. }
  940. protoOverride(Element, 'removeAttribute', isStyleText, returnUndefined);
  941. protoOverride(Element, 'hasAttribute', isStyleText, function(o) {
  942. return o.oldStyle !== null;
  943. });
  944. protoOverride(Element, 'setAttribute', isStyleText, function(o, args) {
  945. o.oldStyle = args[1];
  946. });
  947. protoOverride(Element, 'getAttribute', isStyleText, function(o) {
  948. return o.oldStyle;
  949. });
  950. if (eventMode) {
  951. var e = document.createEvent('Event');
  952. e.initEvent('protoOverride', false, false);
  953. window.protectedElems = protectedElems;
  954. window.dispatchEvent(e);
  955. } else {
  956. return protectedElems;
  957. }
  958. }
  959. if (isFirefox) {
  960. var s = document.createElement('script');
  961. s.textContent = '(' + styleProtector.toString() + ')(true);' +
  962. 'var s = document.currentScript; if (s) {s.parentNode.removeChild(s);}';
  963. window.addEventListener('protoOverride', function protoOverrideCallback(e){
  964. if (win.protectedElems) {
  965. protectedElems = win.protectedElems;
  966. delete win.protectedElems;
  967. }
  968. document.removeEventListener('protoOverride', protoOverrideCallback, true);
  969. }, true);
  970. document.documentElement.appendChild(s);
  971. } else {
  972. protectedElems = styleProtector(false);
  973. }
  974.  
  975. // clean a page
  976. window.addEventListener('DOMContentLoaded', function(){
  977. var rem, si, itm;
  978. function width(){ return window.innerWidth||document.documentElement.clientWidth||document.body.clientWidth||0; }
  979. function height(){ return window.innerHeight||document.documentElement.clientHeight||document.body.clientHeight||0; }
  980.  
  981.  
  982. if (isForum) {
  983. si = document.querySelector('#logostrip');
  984. if (si) {
  985. remove(si.parentNode.nextSibling);
  986. }
  987. }
  988.  
  989. if (document.location.href.search('/forum/dl/') !== -1) {
  990. document.body.setAttribute('style', (document.body.getAttribute('style')||'')+
  991. ';background-color:black!important');
  992. for (itm of document.querySelectorAll('body>div')) {
  993. if (!itm.querySelector('.dw-fdwlink')) {
  994. remove(itm);
  995. }
  996. }
  997. }
  998.  
  999. if (isForum) { // Do not continue if it's a forum
  1000. return;
  1001. }
  1002.  
  1003. si = document.querySelector('#header');
  1004. if (si) {
  1005. rem = si.previousSibling;
  1006. while (rem) {
  1007. si = rem.previousSibling;
  1008. remove(rem);
  1009. rem = si;
  1010. }
  1011. }
  1012.  
  1013. for (itm of document.querySelectorAll('#nav li[class]')) {
  1014. if (itm && itm.querySelector('a[href^="/tag/"]')) {
  1015. remove(itm);
  1016. }
  1017. }
  1018.  
  1019. var style, result;
  1020. for (itm of document.querySelectorAll('DIV, A')) {
  1021. if (itm.tagName ==='DIV' && itm.offsetWidth > 0.95 * width() && itm.offsetHeight > 0.85 * height()) {
  1022. style = window.getComputedStyle(itm, null);
  1023. result = [];
  1024. if (style.backgroundImage !== 'none') {
  1025. result.push('background-image:none!important');
  1026. }
  1027. if (style.backgroundColor !== 'transparent' &&
  1028. style.backgroundColor !== 'rgba(0, 0, 0, 0)') {
  1029. result.push('background-color:transparent!important');
  1030. }
  1031. if (result.length) {
  1032. if (itm.getAttribute('style')) {
  1033. result.unshift(itm.getAttribute('style'));
  1034. }
  1035. (function(){
  1036. var fakeStyle = {
  1037. 'backgroundImage': itm.style.backgroundImage,
  1038. 'backgroundColor': itm.style.backgroundColor
  1039. };
  1040. try {
  1041. Object.defineProperty(itm, 'style', {
  1042. value: new Proxy(itm.style, {
  1043. get: function(target, prop){
  1044. if (fakeStyle.hasOwnProperty(prop)) {
  1045. return fakeStyle[prop];
  1046. } else {
  1047. return target[prop];
  1048. }
  1049. },
  1050. set: function(target, prop, value){
  1051. if (fakeStyle.hasOwnProperty(prop)) {
  1052. fakeStyle[prop] = value;
  1053. } else {
  1054. target[prop] = value;
  1055. }
  1056. return value;
  1057. }
  1058. }),
  1059. enumerable: true
  1060. });
  1061. } catch (e) {
  1062. console.log('Unable to protect style property.', e);
  1063. }
  1064. })();
  1065. if (protectedElems) {
  1066. protectedElems.set(itm, {oldStyle: oGA.call(itm, 'style')});
  1067. }
  1068. oSA.call(itm, 'style', result.join(';'));
  1069. }
  1070. }
  1071. if (itm.tagName ==='A' && (itm.offsetWidth > 0.95 * width() || itm.offsetHeight > 0.85 * height())) {
  1072. if (protectedElems) {
  1073. protectedElems.set(itm, {oldStyle: oGA.call(itm, 'style')});
  1074. }
  1075. oSA.call(itm, 'style', 'display:none!important');
  1076. }
  1077. }
  1078.  
  1079. for (itm of document.querySelectorAll('ASIDE>DIV')) {
  1080. if ( ((itm.querySelector('script, iframe, a[href*="/ad/www/"]') ||
  1081. itm.querySelector('img[src$=".gif"]:not([height="0"]), img[height="400"]')) &&
  1082. !itm.classList.contains('post') ) || !itm.childNodes.length ) {
  1083. remove(itm);
  1084. }
  1085. }
  1086.  
  1087. document.body.setAttribute('style', (document.body.getAttribute('style')||'')+';background-color:#E6E7E9!important');
  1088.  
  1089. // display content of the page
  1090. afterClean();
  1091. });
  1092. }
  1093. };
  1094.  
  1095. scripts['allmovie.pro'] = function() {
  1096. // pretend to be Android to make site use different played for ads
  1097. if (isSafari) {
  1098. return;
  1099. }
  1100. Object.defineProperty(navigator, 'userAgent', {
  1101. 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' },
  1102. enumerable: true
  1103. });
  1104. }
  1105. scripts['rufilmtv.org'] = scripts['allmovie.pro'];
  1106.  
  1107. scripts['anidub-online.ru'] = function() {
  1108. var script = document.createElement('script');
  1109. script.type = "text/javascript";
  1110. script.innerHTML = "function ogonekstart1() {}";
  1111. document.getElementsByTagName('head')[0].appendChild(script);
  1112.  
  1113. var style = document.createElement('style');
  1114. style.type = 'text/css';
  1115. style.appendChild(document.createTextNode('.background {background: none!important;}'));
  1116. style.appendChild(document.createTextNode('.background > script + div, .background > script ~ div:not([id]):not([class]) + div[id][class] {display:none!important}'));
  1117. document.head.appendChild(style);
  1118. };
  1119. scripts['online.anidub.com'] = scripts['anidub-online.ru'];
  1120.  
  1121. scripts['fs.to'] = function() {
  1122. function skipClicker(i) {
  1123. if (!i) {
  1124. return;
  1125. }
  1126. var skip = document.querySelector('.b-aplayer-banners__close');
  1127. if (skip) {
  1128. skip.click();
  1129. } else {
  1130. setTimeout(skipClicker, 100, i-1);
  1131. }
  1132. }
  1133. setTimeout(skipClicker, 100, 30);
  1134.  
  1135. createStyle([
  1136. '.l-body-branding *,'+
  1137. '.b-styled__item-central,'+
  1138. '.b-styled__content-right,'+
  1139. '.b-styled__section-central,'+
  1140. 'div[id^="adsProxy-"]'+
  1141. '{display:none!important}',
  1142. 'body {background-image:url(data:image/png;base64,'+
  1143. 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAACX'+
  1144. 'BIWXMAAC4jAAAuIwF4pT92AAAADUlEQVR42mOQUdL5DwACMgFq'+
  1145. 'BC3ttwAAAABJRU5ErkJggg==)!important}'
  1146. ]);
  1147.  
  1148. if (/\/(view_iframe|iframeplayer)\//i.test(document.location.pathname)) {
  1149. var p = document.querySelector('#player:not([preload="auto"])'),
  1150. m = document.querySelector('.main'),
  1151. adStepper = function(p) {
  1152. if (p.currentTime < p.duration) {
  1153. p.currentTime += 1;
  1154. }
  1155. },
  1156. adSkipper = function(f, p) {
  1157. f.click();
  1158. p.waitAfterSkip = false;
  1159. p.longerSkipper = false;
  1160. console.log('Пропустили.');
  1161. },
  1162. cl = function(p) {
  1163. var faster = document.querySelector('.b-aplayer__html5-desktop-skip'),
  1164. series = document.querySelector('.b-aplayer__actions-series');
  1165.  
  1166. function clickSelected() {
  1167. var s = document.querySelector('.b-aplayer__popup-series-episodes .selected a');
  1168. if (s) {
  1169. s.click();
  1170. }
  1171. }
  1172.  
  1173. if ((!faster || faster.style.display !== 'block') && series && !p.seriesClicked) {
  1174. series.click();
  1175. p.seriesClicked = true;
  1176. p.longerSkipper = true;
  1177. setTimeout(clickSelected, 1000);
  1178. p.pause();
  1179. }
  1180.  
  1181. function skipListener() {
  1182. if (p.waitAfterSkip) {
  1183. console.log('В процессе пропуска…');
  1184. return;
  1185. }
  1186. p.pause();
  1187. if (!p.classList.contains('m-hidden')) {
  1188. p.classList.add('m-hidden');
  1189. }
  1190. if (faster && p.currentTime &&
  1191. win.getComputedStyle(faster).display === 'block' &&
  1192. !faster.querySelector('.b-aplayer__html5-desktop-skip-timer')) {
  1193. p.waitAfterSkip = true;
  1194. setTimeout(adSkipper, (p.longerSkipper?3:1)*1000, faster, p);
  1195. console.log('Доступен быстрый пропуск…');
  1196. } else {
  1197. setTimeout(adStepper, 1000, p);
  1198. }
  1199. }
  1200.  
  1201. p.addEventListener('timeupdate', skipListener, false);
  1202. },
  1203. o = new MutationObserver(function (ms) {
  1204. var m, node;
  1205. for (m of ms) {
  1206. for (node of m.addedNodes) {
  1207. if (node.id === 'player' &&
  1208. node.nodeName === 'VIDEO' &&
  1209. node.getAttribute('preload') !== 'auto') {
  1210. cl(node);
  1211. }
  1212. }
  1213. }
  1214. });
  1215. if (p.nodeName === 'VIDEO') {
  1216. cl(p);
  1217. } else {
  1218. o.observe(m, {childList: true});
  1219. }
  1220. }
  1221. };
  1222. scripts['brb.to'] = scripts['fs.to'];
  1223. scripts['cxz.to'] = scripts['fs.to'];
  1224.  
  1225. scripts['drive2.ru'] = function() {
  1226. gardener('.c-block:not([data-metrika="recomm"]),.o-grid__item', />Реклама<\//i);
  1227. };
  1228.  
  1229. scripts['fishki.net'] = function() {
  1230. gardener('.main-post', /543769|Реклама/);
  1231. };
  1232.  
  1233. scripts['gidonline.club'] = {
  1234. 'now': function() {
  1235. createStyle('.tray > div[style] {display: none!important}');
  1236. }
  1237. };
  1238. scripts['gidonlinekino.com'] = scripts['gidonline.club'];
  1239.  
  1240. scripts['hdgo.cc'] = {
  1241. 'now': function(){
  1242. var o = new MutationObserver(function(ms) {
  1243. var m, node;
  1244. for (m of ms) {
  1245. for (node of m.addedNodes) {
  1246. if (node.tagName === 'SCRIPT' && node.getAttribute('onerror') !== null) {
  1247. node.removeAttribute('onerror');
  1248. }
  1249. }
  1250. }
  1251. });
  1252. o.observe(document, {childList:true, subtree: true});
  1253. }
  1254. };
  1255. scripts['couber.be'] = scripts['hdgo.cc'];
  1256. scripts['46.30.43.38'] = scripts['hdgo.cc'];
  1257.  
  1258. scripts['gismeteo.ru'] = {
  1259. 'DOMContentLoaded': function() {
  1260. gardener('div > a[target^="_"]', /Яндекс\.Директ/i, { root: 'body', observe: true, parent: 'div[class*="frame"]' });
  1261. }
  1262. };
  1263.  
  1264. scripts['hdrezka.me'] = {
  1265. 'now': function() {
  1266. Object.defineProperty(win, 'fuckAdBlock', {
  1267. value: {
  1268. onDetected: function() {
  1269. console.log('Pretending to be an ABP detector.');
  1270. }
  1271. }
  1272. });
  1273. Object.defineProperty(win, 'ab', {
  1274. value: false,
  1275. enumerable: true
  1276. });
  1277. },
  1278. 'DOMContentLoaded': function() {
  1279. gardener('div[id][onclick][onmouseup][onmousedown]', /onmouseout/i);
  1280. }
  1281. };
  1282.  
  1283. scripts['imageban.ru'] = {
  1284. 'now': preventBackgroundRedirect,
  1285. 'DOMContentLoaded': function() {
  1286. win.addEventListener('unload', function() {
  1287. if (!window.location.hash) {
  1288. window.location.replace(window.location+'#');
  1289. } else {
  1290. window.location.hash = '';
  1291. }
  1292. }, true);
  1293. }
  1294. };
  1295.  
  1296. scripts['megogo.net'] = {
  1297. 'now': function() {
  1298. Object.defineProperty(win, "adBlock", {
  1299. value : false,
  1300. enumerable : true
  1301. });
  1302. Object.defineProperty(win, "showAdBlockMessage", {
  1303. value : function () {},
  1304. enumerable : true
  1305. });
  1306. }
  1307. };
  1308.  
  1309. scripts['naruto-base.su'] = function() {
  1310. gardener('div[id^="entryID"],.block', /href="http.*?target="_blank"/i);
  1311. };
  1312.  
  1313. scripts['overclockers.ru'] = {
  1314. 'now': function() {
  1315. createStyle('.fixoldhtml {display:block!important}');
  1316. if (!isChrome && !isOpera) {
  1317. return; // Looks like my code works only in Chrome-like browsers
  1318. }
  1319. var noContentYet = true;
  1320. function jWrap() {
  1321. var _$ = win.$, _e = _$.extend;
  1322. win.$ = function() {
  1323. var _ret = _$.apply(window, arguments);
  1324. if (_ret[0] === document.body) {
  1325. _ret.html = function() {
  1326. console.log('Anti-adblock prevented.');
  1327. };
  1328. }
  1329. return _ret;
  1330. };
  1331. win.$.extend = function() {
  1332. return _e.apply(_$, arguments);
  1333. }
  1334. win.jQuery = win.$;
  1335. }
  1336. (function jReady() {
  1337. if (!win.$ && noContentYet) {
  1338. setTimeout(jReady, 0);
  1339. } else {
  1340. jWrap();
  1341. }
  1342. })();
  1343. document.addEventListener ('DOMContentLoaded', function(){
  1344. noContentYet = false;
  1345. }, false);
  1346. }
  1347. };
  1348. scripts['forums.overclockers.ru'] = {
  1349. 'now': function() {
  1350. createStyle('.needblock {position: fixed; left: -10000px}');
  1351. Object.defineProperty(win, 'adblck', {
  1352. value: 'no',
  1353. enumerable: true
  1354. });
  1355. }
  1356. };
  1357.  
  1358. scripts['pb.wtf'] = function() {
  1359. createStyle('.reques,#result,tbody.row1:not([id]) {display: none !important}');
  1360. // image in the slider in the header
  1361. gardener('a[href$="=="]', /img/i, {root:'.release-navbar', observe:true, parent:'div'});
  1362. // ads in blocks on the page
  1363. gardener('a[href^="/"]', /<img\s.*<br>/i, {root:'#main_content', observe:true, parent:'div[class]'});
  1364. // line above topic content
  1365. gardener('.re_top1', /./, {root:'#main_content', parent:'.hidden-sm'});
  1366. };
  1367. scripts['piratbit.org'] = scripts['pb.wtf'];
  1368. scripts['piratbit.ru'] = scripts['pb.wtf'];
  1369.  
  1370. scripts['pikabu.ru'] = function() {
  1371. gardener('.story', /story__sponsor|story__gag|profile\/ads"/i, {root: '.inner_wrap', observe: true});
  1372. };
  1373.  
  1374. scripts['rp5.ru'] = function() {
  1375. createStyle('#bannerBottom {display: none!important}');
  1376. var co = document.querySelector('#content'), i, nodes;
  1377. if (!co) {
  1378. return;
  1379. }
  1380. nodes = co.parentNode.childNodes;
  1381. i = nodes.length;
  1382. while (i--) {
  1383. if (nodes[i] !== co) {
  1384. nodes[i].parentNode.removeChild(nodes[i]);
  1385. }
  1386. }
  1387. };
  1388. scripts['rp5.by'] = scripts['rp5.ru'];
  1389. scripts['rp5.ua'] = scripts['rp5.ru'];
  1390.  
  1391. scripts['rustorka.com'] = {
  1392. 'now': function() {
  1393. createStyle('.header > div:not(.head-block) a, #sidebar1 img, #logo img {opacity:0!important}', {
  1394. id: 'tempHidingStyles'
  1395. }, true);
  1396. preventPopups();
  1397. },
  1398. 'DOMContentLoaded': function() {
  1399. for (var o of document.querySelectorAll('IMG, A')) {
  1400. if ((o.clientWidth === 728 && o.clientHeight === 90) ||
  1401. (o.clientWidth === 300 && o.clientHeight === 250)) {
  1402. while (o && o.tagName !== 'A') {
  1403. o = o.parentNode;
  1404. }
  1405. if (o) {
  1406. o.setAttribute('style', 'display: none !important');
  1407. }
  1408. }
  1409. }
  1410. var s = document.querySelector('#tempHidingStyles');
  1411. s.parentNode.removeChild(s);
  1412. }
  1413. };
  1414. scripts['rumedia.ws'] = scripts['rustorka.com'];
  1415.  
  1416. scripts['sport-express.ru'] = function() {
  1417. gardener('.js-relap__item',/>Реклама\s+<\//, {root:'.container', observe: true});
  1418. };
  1419.  
  1420. scripts['sports.ru'] = function() {
  1421. gardener('.aside-news-list__item', /aside-news-list__advert/i, {root:'.aside-news-block'});
  1422. // extra functionality (shows/hides panel at the top depending on scroll direction)
  1423. var panel = document.querySelector('.user-panel__fixed');
  1424. if (!panel) {
  1425. return;
  1426. }
  1427. createStyle([
  1428. '.user-panel__fixed { transition: top 0.2s ease-in-out!important; }',
  1429. '.user-panel-up { top: -40px!important }'
  1430. ], {id: 'userPanelSlide'}, false);
  1431. window.addEventListener('wheel', function(e){
  1432. if (e.deltaY > 0 && !panel.classList.contains('user-panel-up')) {
  1433. panel.classList.add('user-panel-up');
  1434. } else
  1435. if (e.deltaY < 0 && panel.classList.contains('user-panel-up')) {
  1436. panel.classList.remove('user-panel-up');
  1437. };
  1438. }, false);
  1439. };
  1440.  
  1441. scripts['vk.com'] = function() {
  1442. gardener('div[data-post-id]', /wall_marked_as_ads/, {root: '#page_wall_posts', observe: true});
  1443. };
  1444.  
  1445. scripts['yap.ru'] = function() {
  1446. var words = /member1438|Administration/;
  1447. gardener('form > table[id^="p_row_"]', words);
  1448. gardener('tr > .holder.newsbottom', words, {parent:'tr', siblings:-2});
  1449. };
  1450. scripts['yaplakal.com'] = scripts['yap.ru'];
  1451.  
  1452. scripts['reactor.cc'] = {
  1453. 'now': function() {
  1454. win.open = (function(){ throw new Error('Redirect prevention.'); }).bind(window);
  1455. },
  1456. 'click': function(e) {
  1457. var node = e.target;
  1458. if (node.nodeType === Node.ELEMENT_NODE &&
  1459. node.style.position === 'absolute' &&
  1460. node.style.zIndex > 0)
  1461. node.parentNode.removeChild(node);
  1462. },
  1463. 'DOMContentLoaded': function() {
  1464. var words = new RegExp(
  1465. 'блокировщика рекламы'
  1466. .split('')
  1467. .map(function(e){return e+'[\u200b\u200c\u200d]*';})
  1468. .join('')
  1469. .replace(' ', '\\s*')
  1470. .replace(/[аоре]/g, function(e){return ['[аa]','[оo]','[рp]','[еe]']['аоре'.indexOf(e)];}),
  1471. 'i'),
  1472. can;
  1473. function deeper(spider) {
  1474. var c, l, n;
  1475. if (words.test(spider.innerText)) {
  1476. if (spider.nodeType === Node.TEXT_NODE) {
  1477. return true;
  1478. }
  1479. c = spider.childNodes;
  1480. l = c.length;
  1481. n = 0;
  1482. while(l--) {
  1483. if (deeper(c[l]), can) {
  1484. n++;
  1485. }
  1486. }
  1487. if (n > 0 && n === c.length && spider.offsetHeight < 750) {
  1488. can.push(spider);
  1489. }
  1490. return false;
  1491. }
  1492. return true;
  1493. }
  1494. function probe(){
  1495. if (words.test(document.body.innerText)) {
  1496. can = [];
  1497. deeper(document.body);
  1498. var i = can.length, j, spider;
  1499. while(i--) {
  1500. spider = can[i];
  1501. if (spider.offsetHeight > 10 && spider.offsetHeight < 750) {
  1502. spider.setAttribute('style', 'background:none!important');
  1503. }
  1504. }
  1505. }
  1506. }
  1507. var o = new MutationObserver(probe);
  1508. o.observe(document,{childList:true, subtree:true});
  1509. }
  1510. };
  1511. scripts['joyreactor.cc'] = scripts['reactor.cc'];
  1512. scripts['pornreactor.cc'] = scripts['reactor.cc'];
  1513.  
  1514. scripts['auto.ru'] = function() {
  1515. var words = /Реклама|Яндекс.Директ|yandex_ad_/;
  1516. var userAdsListAds = [
  1517. '.listing-list > .listing-item',
  1518. '.listing-item_type_fixed.listing-item'
  1519. ];
  1520. var catalogAds = [
  1521. 'div[class*="layout_catalog-inline"]',
  1522. 'div[class$="layout_horizontal"]'
  1523. ];
  1524. var otherAds = [
  1525. '.advt_auto',
  1526. '.sidebar-block',
  1527. '.pager-listing + div[class]',
  1528. '.card > div[class][style]',
  1529. '.sidebar > div[class]',
  1530. '.main-page__section + div[class]',
  1531. '.listing > tbody'];
  1532. gardener(userAdsListAds.join(','), words, {root:'.listing-wrap', observe:true});
  1533. gardener(catalogAds.join(','), words, {root:'.catalog__page,.content__wrapper', observe:true});
  1534. gardener(otherAds.join(','), words);
  1535. };
  1536.  
  1537. scripts['rsload.net'] = {
  1538. 'load': function() {
  1539. var dis = document.querySelector('.cb-disabless');
  1540. if (dis) {
  1541. dis.click();
  1542. }
  1543. },
  1544. 'click': function(e) {
  1545. var t = e.target;
  1546. if (t && t.href && (/:\/\/\d+\.\d+\.\d+\.\d+\//.test(t.href))) {
  1547. t.href = t.href.replace('://','://rsload.net:rsload.net@');
  1548. }
  1549. }
  1550. };
  1551.  
  1552. var domain = document.domain, name;
  1553. while (domain.indexOf('.') !== -1) {
  1554. if (scripts.hasOwnProperty(domain)) {
  1555. if (typeof scripts[domain] === 'function') {
  1556. document.addEventListener ('DOMContentLoaded', scripts[domain], false);
  1557. }
  1558. for (name in scripts[domain]) {
  1559. if (name !== 'now') {
  1560. (name === 'load' ? window : document)
  1561. .addEventListener (name, scripts[domain][name], false);
  1562. } else {
  1563. scripts[domain][name]();
  1564. }
  1565. }
  1566. }
  1567. domain = domain.slice(domain.indexOf('.') + 1);
  1568. }
  1569. })();