RU AdList JS Fixes

try to take over the world!

目前為 2017-02-17 提交的版本,檢視 最新版本

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