RU AdList JS Fixes

try to take over the world!

当前为 2017-02-28 提交的版本,查看 最新版本

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

QingJ © 2025

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