RU AdList JS Fixes

try to take over the world!

当前为 2017-01-10 提交的版本,查看 最新版本

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