Greasy Fork 还支持 简体中文。

RU AdList JS Fixes

try to take over the world!

目前為 2017-05-31 提交的版本,檢視 最新版本

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