RU AdList JS Fixes

try to take over the world!

当前为 2017-06-11 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name RU AdList JS Fixes
  3. // @namespace ruadlist_js_fixes
  4. // @version 20170611.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://gf.qytechs.cn/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. '||185.87.50.147^',
  271. '||10root25.website^', '||24video.xxx^',
  272. '||adlabs.ru^', '||adspayformymortgage.win^', '||aviabay.ru^',
  273. '||bgrndi.com^', '||brokeloy.com^',
  274. '||cnamerutor.ru^',
  275. '||docfilms.info^', '||dreadfula.ru^',
  276. '||et-code.ru^',
  277. '||franecki.net^', '||film-doma.ru^',
  278. '||free-torrent.org^', '||free-torrent.pw^',
  279. '||free-torrents.org^', '||free-torrents.pw^',
  280. '||game-torrent.info^', '||gocdn.ru^',
  281. '||hdkinoshka.com^', '||hghit.com^', '||hindcine.net^',
  282. '||kiev.ua^', '||kinotochka.net^',
  283. '||kinott.com^', '||kinott.ru^', '||kuveres.com^',
  284. '||lepubs.com^', '||luxadv.com^', '||luxup.ru^', '||luxupcdna.com^',
  285. '||mail.ru^', '||marketgid.com^', '||mixadvert.com^', '||mxtads.com^',
  286. '||nickhel.com^',
  287. '||oconner.biz^', '||oconner.link^', '||octoclick.net^', '||octozoon.org^',
  288. '||pkpojhc.com^',
  289. '||psma01.com^', '||psma02.com^', '||psma03.com^',
  290. '||recreativ.ru^', '||redtram.com^', '||regpole.com^', '||rootmedia.ws^', '||ruttwind.com^',
  291. '||skidl.ru^',
  292. '||torvind.com^', '||traffic-media.co^', '||trafmag.com^',
  293. '||webadvert-gid.ru^', '||webadvertgid.ru^',
  294. '||xxuhter.ru^',
  295. '||yuiout.online^',
  296. '||zoom-film.ru^'
  297. ]) {
  298. masks.push(new RegExp(
  299. filter.replace(/([\\\/\[\].*+?(){}$])/g, '\\$1')
  300. .replace(/\^(?!$)/g,'\\.?[^\\w%._-]')
  301. .replace(/\^$/,'\\.?([^\\w%._-]|$)')
  302. .replace(/^\|\|/,'^(ws|http)s?:\\/+([^\/.]+\\.)*'),
  303. 'i'));
  304. }
  305.  
  306. function isBlocked(url) {
  307. for (var mask of masks) {
  308. if (mask.test(url)) {
  309. return true;
  310. }
  311. }
  312. return false;
  313. }
  314.  
  315. var realWebSocket = win.WebSocket;
  316. function wsGetter (target, name) {
  317. try {
  318. if (typeof realWebSocket.prototype[name] === 'function') {
  319. if (name === 'close' || name === 'send') { // send also closes connection
  320. target.readyState = realWebSocket.CLOSED;
  321. }
  322. return (
  323. function fake() {
  324. console.log('[WSI] Invoked function "'+name+'"', '| Tracing', (new Error()));
  325. return;
  326. }
  327. );
  328. }
  329. if (typeof realWebSocket.prototype[name] === 'number') {
  330. return realWebSocket[name];
  331. }
  332. } catch(ignore) {}
  333. return target[name];
  334. }
  335.  
  336. function createWebSocketWrapper(target) {
  337. return new Proxy(realWebSocket, {
  338. construct: function (target, args) {
  339. var url = args[0];
  340. console.log('[WSI] Opening socket on ' + url + ' \u2026');
  341. if (isBlocked(url)) {
  342. console.log("[WSI] Blocked.");
  343. return new Proxy({
  344. url: url,
  345. readyState: realWebSocket.OPEN
  346. }, {
  347. get: wsGetter
  348. });
  349. }
  350. return new target(args[0], args[1]);
  351. }
  352. });
  353. }
  354.  
  355. function WorkerWrapper() {
  356. var realWorker = win.Worker;
  357. function wrappedWorker(resourceURI) {
  358. var isBlobURL = /^blob:/i,
  359. xhr = null,
  360. _callbacks = new WeakMap(),
  361. _worker = null,
  362. _terminate = false,
  363. _onerror = null,
  364. _onmessage = null,
  365. _messages = [],
  366. _events = [],
  367. /*jshint validthis:true */
  368. _self = this;
  369.  
  370. function callbackWrapper(func) {
  371. if (typeof func !== 'function') {
  372. return undefined;
  373. }
  374. return (
  375. function callback() {
  376. func.apply(_self, arguments);
  377. }
  378. );
  379. }
  380.  
  381. _self.terminate = function(){
  382. _terminate = true;
  383. if (_worker) {
  384. _worker.terminate();
  385. }
  386. };
  387. Object.defineProperty(_self, 'onmessage', {
  388. get: function() {
  389. return _onmessage;
  390. },
  391. set: function(val) {
  392. _onmessage = val;
  393. if (_worker) {
  394. _worker.onmessage = callbackWrapper(val);
  395. }
  396. }
  397. });
  398. Object.defineProperty(_self, 'onerror', {
  399. get: function() {
  400. return _onerror;
  401. },
  402. set: function(val) {
  403. _onerror = val;
  404. if (_worker) {
  405. _worker.onerror = callbackWrapper(val);
  406. }
  407. }
  408. });
  409. _self.postMessage = function(message){
  410. if (_worker) {
  411. _worker.postMessage(message);
  412. } else {
  413. _messages.push(message);
  414. }
  415. };
  416. _self.terminate = function() {
  417. _terminate = true;
  418. if (_worker) {
  419. _worker.terminate();
  420. }
  421. };
  422. _self.addEventListener = function(){
  423. if (typeof arguments[1] !== 'function') {
  424. return;
  425. }
  426. if (!_callbacks.has(arguments[1])) {
  427. _callbacks.set(arguments[1], callbackWrapper(arguments[1]));
  428. }
  429. arguments[1] = _callbacks.get(arguments[1]);
  430. if (_worker) {
  431. _worker.addEventListener.apply(_worker, arguments);
  432. } else {
  433. _events.push(['addEventListener', arguments]);
  434. }
  435. };
  436. _self.removeEventListener = function(){
  437. if (typeof arguments[1] !== 'function' || !_callbacks.has(arguments[1])) {
  438. return;
  439. }
  440. arguments[1] = _callbacks.get(arguments[1]);
  441. _callbacks.delete(arguments[1]);
  442. if (_worker) {
  443. _worker.removeEventListener.apply(_worker, arguments);
  444. } else {
  445. _events.push(['removeEventListener', arguments]);
  446. }
  447. };
  448.  
  449. if (!isBlobURL.test(resourceURI)) {
  450. _worker = new realWorker(resourceURI);
  451. return; // not a blob, no need to wrap
  452. }
  453.  
  454. xhr = new XMLHttpRequest();
  455. xhr.responseType = 'blob';
  456. try {
  457. xhr.open('GET', resourceURI, true);
  458. } catch(ignore) {
  459. _worker = new realWorker(resourceURI);
  460. return; // failed to open connection, unable to continue wrapping procedure
  461. }
  462. (new Promise(function(resolve, reject){
  463. if (xhr.readyState !== XMLHttpRequest.OPENED) {
  464. // connection wasn't opened, unable to continue wrapping procedure
  465. return reject();
  466. }
  467. xhr.onload = function(){
  468. if (this.status === 200) {
  469. var reader = new FileReader();
  470. reader.addEventListener("loadend", function() {
  471. resolve(new realWorker(URL.createObjectURL(
  472. new Blob([getWrappedCode(false)+this.result])
  473. )));
  474. });
  475. reader.readAsText(this.response);
  476. }
  477. };
  478. xhr.send();
  479. })).then(function(val) {
  480. _worker = val;
  481. _worker.onerror = callbackWrapper(_onerror);
  482. _worker.onmessage = callbackWrapper(_onmessage);
  483. var _e;
  484. while(_events.length) {
  485. _e = _events.shift();
  486. _worker[_e[0]].apply(_worker, _e[1]);
  487. }
  488. while(_messages.length) {
  489. _worker.postMessage(_messages.shift());
  490. }
  491. if (_terminate) {
  492. _worker.terminate();
  493. }
  494. }).catch(function(){});
  495.  
  496. }
  497. win.Worker = wrappedWorker.bind(safeWin);
  498. }
  499.  
  500. function CreateElementWrapper() {
  501. var realCreateElement = Document.prototype.createElement,
  502. _addEventListener = Element.prototype.addEventListener,
  503. code = encodeURIComponent('<scr'+'ipt>'+getWrappedCode(true)+'</scr'+'ipt>\n'),
  504. isDataURL = /^data:/i,
  505. isBlobURL = /^blob:/i;
  506.  
  507. function frameRewrite(e) {
  508. var f = e.target,
  509. w = f.contentWindow;
  510. if (!f.src || (w && isBlobURL.test(f.src))) {
  511. w.WebSocket = createWebSocketWrapper();
  512. }
  513. if (isDataURL.test(f.src) && f.src.indexOf(code) < 0) {
  514. f.src = f.src.replace(',',',' + code);
  515. }
  516. }
  517.  
  518. var scriptMap = new WeakMap();
  519. scriptMap.isBlocked = isBlocked;
  520. var onErrorWrapper = {
  521. set: function(val) {
  522. if (scriptMap.has(this)) {
  523. this.removeEventListener('error', scriptMap.get(this).wrp, false);
  524. scriptMap.delete(this);
  525. }
  526. if (!val || typeof val !== 'function') {
  527. return val;
  528. }
  529. scriptMap.set(this, {
  530. org: val,
  531. wrp: function() {
  532. if (scriptMap.isBlocked(this.src)) {
  533. console.log('[WSI] Blocked "onerror" callback from', this);
  534. return;
  535. }
  536. scriptMap.get(this).org.apply(this, arguments);
  537. }
  538. });
  539. this.addEventListener('error', scriptMap.get(this).wrp, false);
  540. return val;
  541. },
  542. get: function() {
  543. return scriptMap.has(this) ? scriptMap.get(this).org : null;
  544. },
  545. enumerable: true
  546. };
  547. function wrappedCreateElement(name) {
  548. /*jshint validthis:true */
  549. var el = realCreateElement.apply(this, arguments);
  550. if (el.tagName === 'IFRAME') {
  551. _addEventListener.call(el, 'load', frameRewrite, false);
  552. }
  553. if (el.tagName === 'SCRIPT') {
  554. Object.defineProperty(el, 'onerror', onErrorWrapper);
  555. }
  556. return el;
  557. }
  558. Document.prototype.createElement = wrappedCreateElement;
  559.  
  560. document.addEventListener('DOMContentLoaded', function(){
  561. for (var ifr of document.querySelectorAll('IFRAME')) {
  562. _addEventListener.call(ifr, 'load', frameRewrite, false);
  563. }
  564. }, false);
  565. }
  566.  
  567. this.init = function() {
  568. win.WebSocket = createWebSocketWrapper();
  569. if (!(/firefox/i.test(navigator.userAgent))) {
  570. WorkerWrapper(); // skip WorkerWrapper in Firefox
  571. }
  572. if (typeof document !== 'undefined') {
  573. CreateElementWrapper();
  574. }
  575. };
  576. }
  577.  
  578. if (isFirefox) {
  579. var script = document.createElement('script');
  580. script.appendChild(document.createTextNode(getWrappedCode(true)));
  581. document.head.insertBefore(script, document.head.firstChild);
  582. return; //we don't want to call functions on page from here in Fx, so exit
  583. }
  584.  
  585. (new WSI((unsafeWindow||self||window),(self||window))).init();
  586. }
  587.  
  588. if (!isFirefox) { // scripts for non-Firefox browsers
  589.  
  590. // https://gf.qytechs.cn/scripts/14720-it-s-not-important
  591. (function(){
  592. var imptt = /((display|(margin|padding)(-top|-bottom)?)\s*:[^;!]*)!\s*important/ig,
  593. ret_b = function(a,b){return b;},
  594. _toLowerCase = String.prototype.toLowerCase,
  595. protectedNodes = new WeakSet();
  596.  
  597. function unimportanter(node) {
  598. var style = (node.nodeType === Node.ELEMENT_NODE) ?
  599. _getAttribute.call(node, 'style') : null;
  600. if (!style || !imptt.test(style) || node.style.display === 'none') {
  601. return false; // get out if we have nothing to do here
  602. }
  603. if (node.nodeName === 'IFRAME' && node.src &&
  604. node.src.slice(0,17) === 'chrome-extension:') {
  605. return false; // Web of Trust uses this method to add their frame
  606. }
  607. protectedNodes.add(node);
  608. _setAttribute.call(node, 'style',
  609. style.replace(imptt, ret_b));
  610. return true;
  611. }
  612.  
  613. function logger(log) {
  614. if (log) {
  615. console.log('Some page elements became a bit less important.');
  616. }
  617. }
  618.  
  619. (new MutationObserver(function(mutations) {
  620. setTimeout(function(ms) {
  621. var log = false, m, node;
  622. for (m of ms) {
  623. for (node of m.addedNodes) {
  624. log = unimportanter(node) | log;
  625. }
  626. }
  627. logger(log);
  628. }, 0, mutations);
  629. })).observe(document, {
  630. childList : true,
  631. subtree : true
  632. });
  633.  
  634. Element.prototype.setAttribute = function setAttribute(name, value) {
  635. "[native code]";
  636. var replaced = value;
  637. if (_toLowerCase.call(name) === 'style' && protectedNodes.has(this)) {
  638. replaced = value.replace(imptt, ret_b);
  639. logger(replaced !== value);
  640. }
  641. return _setAttribute.call(this, name, replaced);
  642. };
  643.  
  644. win.addEventListener ("load", function(){
  645. var log = false, imp;
  646. for (imp of document.querySelectorAll('[style*="!"]')) {
  647. log = unimportanter(imp) | log;
  648. }
  649. logger(log);
  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://gf.qytechs.cn/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://gf.qytechs.cn/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://gf.qytechs.cn/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://gf.qytechs.cn/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.kz'] = scripts['rp5.ru'];
  1903. scripts['rp5.ua'] = scripts['rp5.ru'];
  1904.  
  1905. scripts['rustorka.com'] = {
  1906. 'now': function() {
  1907. createStyle('.header > div:not(.head-block) a, #sidebar1 img, #logo img {opacity:0!important}', {
  1908. id: 'tempHidingStyles'
  1909. }, true);
  1910. preventPopups();
  1911. },
  1912. 'DOMContentLoaded': function() {
  1913. for (var o of document.querySelectorAll('IMG, A')) {
  1914. if ((o.clientWidth === 728 && o.clientHeight === 90) ||
  1915. (o.clientWidth === 300 && o.clientHeight === 250)) {
  1916. while (o && o.tagName !== 'A') {
  1917. o = o.parentNode;
  1918. }
  1919. if (o) {
  1920. _setAttribute.call(o, 'style', 'display: none !important');
  1921. }
  1922. }
  1923. }
  1924. var s = document.querySelector('#tempHidingStyles');
  1925. s.parentNode.removeChild(s);
  1926. }
  1927. };
  1928. scripts['rumedia.ws'] = scripts['rustorka.com'];
  1929.  
  1930. scripts['sport-express.ru'] = function() {
  1931. gardener('.js-relap__item',/>Реклама\s+<\//, {root:'.container', observe: true});
  1932. };
  1933.  
  1934. scripts['sports.ru'] = function() {
  1935. gardener('.aside-news-list__item', /aside-news-list__advert/i, {root:'.columns-layout__left', observe: true});
  1936. gardener('.material-list__item', /Реклама/i, {root:'.columns-layout', observe: true});
  1937. // extra functionality: shows/hides panel at the top depending on scroll direction
  1938. createStyle([
  1939. '.user-panel__fixed { transition: top 0.2s ease-in-out!important; }',
  1940. '.user-panel-up { top: -40px!important }'
  1941. ], {id: 'userPanelSlide'}, false);
  1942. (function lookForPanel() {
  1943. var panel = document.querySelector('.user-panel__fixed');
  1944. if (!panel) {
  1945. setTimeout(lookForPanel, 100);
  1946. } else {
  1947. window.addEventListener('wheel', function(e){
  1948. if (e.deltaY > 0 && !panel.classList.contains('user-panel-up')) {
  1949. panel.classList.add('user-panel-up');
  1950. } else
  1951. if (e.deltaY < 0 && panel.classList.contains('user-panel-up')) {
  1952. panel.classList.remove('user-panel-up');
  1953. }
  1954. }, false);
  1955. }
  1956. })();
  1957. };
  1958.  
  1959. scripts['www.ukr.net'] = scripts['sinoptik.com.ru'];
  1960.  
  1961. scripts['vk.com'] = function() {
  1962. gardener('div[data-post-id]', /wall_marked_as_ads/, {root: '#page_wall_posts', observe: true});
  1963. };
  1964.  
  1965. scripts['yap.ru'] = function() {
  1966. gardener('form > table[id^="p_row_"]:nth-of-type(2)', /member1438|Administration/);
  1967. gardener('.icon-comments', /member1438|Administration|\/go\/\?http/, {parent:'tr', siblings:-2});
  1968. };
  1969. scripts['yaplakal.com'] = scripts['yap.ru'];
  1970.  
  1971. scripts['rambler.ru'] = {
  1972. 'now': function() {
  1973. scriptLander(function() {
  1974. var _createElement = Document.prototype.createElement,
  1975. loadMap = new WeakMap();
  1976. Document.prototype.createElement = function createElement(name) {
  1977. /*jshint validthis:true */
  1978. var el = _createElement.apply(this, arguments);
  1979. if (el.tagName === 'LINK') {
  1980. Object.defineProperty(el, 'onload', {
  1981. get: function() {
  1982. return loadMap.get(loadMap.get(this));
  1983. },
  1984. set: function(func) {
  1985. var wrap = loadMap.get(this),
  1986. isContent = /\{\s*content\s*:\s*"[^"]+"/i;
  1987. if (wrap) {
  1988. this.removeEventListener('load', wrap, false);
  1989. loadMap.remove(wrap);
  1990. loadMap.remove(this);
  1991. }
  1992. wrap = function(e) {
  1993. if (e.target && e.target.sheet && e.target.sheet.cssRules &&
  1994. e.target.sheet.cssRules[0] && e.target.sheet.cssRules[0].cssText &&
  1995. isContent.test(e.target.sheet.cssRules[0].cssText)) {
  1996. console.log('Blocked "onload" for', e.target.href);
  1997. return false;
  1998. }
  1999. return func.apply(this, arguments);
  2000. };
  2001. loadMap.set(this, wrap);
  2002. loadMap.set(wrap, func);
  2003. this.addEventListener('load', wrap, false);
  2004. },
  2005. enumberable: true
  2006. });
  2007. }
  2008. return el;
  2009. };
  2010. });
  2011. }
  2012. };
  2013.  
  2014. scripts['reactor.cc'] = {
  2015. 'now': function() {
  2016. win.open = (function(){ throw new Error('Redirect prevention.'); }).bind(window);
  2017. },
  2018. 'click': function(e) {
  2019. var node = e.target;
  2020. if (node.nodeType === Node.ELEMENT_NODE &&
  2021. node.style.position === 'absolute' &&
  2022. node.style.zIndex > 0)
  2023. node.parentNode.removeChild(node);
  2024. },
  2025. 'DOMContentLoaded': function() {
  2026. var words = new RegExp(
  2027. 'блокировщика рекламы'
  2028. .split('')
  2029. .map(function(e){return e+'[\u200b\u200c\u200d]*';})
  2030. .join('')
  2031. .replace(' ', '\\s*')
  2032. .replace(/[аоре]/g, function(e){return ['[аa]','[оo]','[рp]','[еe]']['аоре'.indexOf(e)];}),
  2033. 'i'),
  2034. can;
  2035. function deeper(spider) {
  2036. var c, l, n;
  2037. if (words.test(spider.innerText)) {
  2038. if (spider.nodeType === Node.TEXT_NODE) {
  2039. return true;
  2040. }
  2041. c = spider.childNodes;
  2042. l = c.length;
  2043. n = 0;
  2044. while(l--) {
  2045. if (deeper(c[l]), can) {
  2046. n++;
  2047. }
  2048. }
  2049. if (n > 0 && n === c.length && spider.offsetHeight < 750) {
  2050. can.push(spider);
  2051. }
  2052. return false;
  2053. }
  2054. return true;
  2055. }
  2056. function probe(){
  2057. if (words.test(document.body.innerText)) {
  2058. can = [];
  2059. deeper(document.body);
  2060. var i = can.length, spider;
  2061. while(i--) {
  2062. spider = can[i];
  2063. if (spider.offsetHeight > 10 && spider.offsetHeight < 750) {
  2064. _setAttribute.call(spider, 'style', 'background:none!important');
  2065. }
  2066. }
  2067. }
  2068. }
  2069. (new MutationObserver(probe)).observe(document,{childList:true, subtree:true});
  2070. }
  2071. };
  2072. scripts['joyreactor.cc'] = scripts['reactor.cc'];
  2073. scripts['pornreactor.cc'] = scripts['reactor.cc'];
  2074.  
  2075. scripts['auto.ru'] = function() {
  2076. var words = /Реклама|Яндекс.Директ|yandex_ad_/;
  2077. var userAdsListAds = [
  2078. '.listing-list > .listing-item',
  2079. '.listing-item_type_fixed.listing-item'
  2080. ];
  2081. var catalogAds = [
  2082. 'div[class*="layout_catalog-inline"]',
  2083. 'div[class$="layout_horizontal"]'
  2084. ];
  2085. var otherAds = [
  2086. '.advt_auto',
  2087. '.sidebar-block',
  2088. '.pager-listing + div[class]',
  2089. '.card > div[class][style]',
  2090. '.sidebar > div[class]',
  2091. '.main-page__section + div[class]',
  2092. '.listing > tbody'];
  2093. gardener(userAdsListAds.join(','), words, {root:'.listing-wrap', observe:true});
  2094. gardener(catalogAds.join(','), words, {root:'.catalog__page,.content__wrapper', observe:true});
  2095. gardener(otherAds.join(','), words);
  2096. };
  2097.  
  2098. scripts['rsload.net'] = {
  2099. 'load': function() {
  2100. var dis = document.querySelector('label[class*="cb-disable"]');
  2101. if (dis) {
  2102. dis.click();
  2103. }
  2104. },
  2105. 'click': function(e) {
  2106. var t = e.target;
  2107. if (t && t.href && (/:\/\/\d+\.\d+\.\d+\.\d+\//.test(t.href))) {
  2108. t.href = t.href.replace('://','://rsload.net:rsload.net@');
  2109. }
  2110. }
  2111. };
  2112.  
  2113. var domain = document.domain, name;
  2114. while (domain.indexOf('.') !== -1) {
  2115. if (scripts.hasOwnProperty(domain)) {
  2116. if (typeof scripts[domain] === 'function') {
  2117. document.addEventListener ('DOMContentLoaded', scripts[domain], false);
  2118. }
  2119. for (name in scripts[domain]) {
  2120. if (name !== 'now') {
  2121. (name === 'load' ? window : document)
  2122. .addEventListener (name, scripts[domain][name], false);
  2123. } else {
  2124. scripts[domain][name]();
  2125. }
  2126. }
  2127. }
  2128. domain = domain.slice(domain.indexOf('.') + 1);
  2129. }
  2130. })();

QingJ © 2025

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