RU AdList JS Fixes

try to take over the world!

当前为 2017-05-24 提交的版本,查看 最新版本

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

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址