RU AdList JS Fixes

try to take over the world!

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

  1. // ==UserScript==
  2. // @name RU AdList JS Fixes
  3. // @namespace ruadlist_js_fixes
  4. // @version 20170303.0
  5. // @description try to take over the world!
  6. // @author lainverse & dimisa
  7. // @match *://*/*
  8. // @grant unsafeWindow
  9. // @grant window.close
  10. // @grant GM_getValue
  11. // @grant GM_setValue
  12. // @run-at document-start
  13. // ==/UserScript==
  14.  
  15. (function() {
  16. 'use strict';
  17. var win = (unsafeWindow || window),
  18. // http://stackoverflow.com/questions/9847580/how-to-detect-safari-chrome-ie-firefox-and-opera-browser
  19. isOpera = (!!window.opr && !!opr.addons) || !!window.opera || navigator.userAgent.indexOf(' OPR/') >= 0,
  20. isChrome = !!window.chrome && !!window.chrome.webstore,
  21. isSafari = (Object.prototype.toString.call(window.HTMLElement).indexOf('Constructor') > 0 ||
  22. (function (p) { return p.toString() === "[object SafariRemoteNotification]"; })(!window.safari || safari.pushNotification)),
  23. isFirefox = typeof InstallTrigger !== 'undefined';
  24.  
  25. // NodeList iterator polyfill (mostly for Safari)
  26. // https://jakearchibald.com/2014/iterators-gonna-iterate/
  27. if (!NodeList.prototype[Symbol.iterator]) {
  28. NodeList.prototype[Symbol.iterator] = Array.prototype[Symbol.iterator];
  29. }
  30.  
  31. // Options
  32. var opts = {
  33. 'useWSIFunc': useWSI
  34. };
  35. (function(){
  36. function optsCall(callback) {
  37. // Register event listener
  38. var key = "optsCallEvent_" + Math.random().toString(36).substr(2),
  39. cb = callback.func.bind(callback.name);
  40. window.addEventListener(key, cb, false);
  41. // Generate and dispatch synthetic event
  42. var ev = document.createEvent("HTMLEvents");
  43. ev.initEvent(key, true, false);
  44. window.dispatchEvent(ev);
  45. // Remove listener
  46. window.removeEventListener(key, cb, false);
  47. }
  48. function initOptsHandler() {
  49. /*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. function forbidShadowRoot() {
  981. var cloneNode = Element.prototype.cloneNode,
  982. skipTags = ['HTML', 'STYLE', 'SCRIPT'];
  983. function replacer(func) {
  984. return function() {
  985. if (skipTags.indexOf(this.tagName)>-1) {
  986. return func.apply(this, arguments);
  987. }
  988. console.log('Prevented', func.name, 'on', this);
  989. return func.apply(cloneNode.call(this), arguments);
  990. };
  991. }
  992. for (var func of ['createShadowRoot', 'attachShadow']) {
  993. if (func in Element.prototype) {
  994. Element.prototype[func] = replacer(Element.prototype[func]);
  995. }
  996. }
  997. }
  998.  
  999. function errorAndLoadEventsFilter() {
  1000. var toString = Function.prototype.toString,
  1001. addEventListener = Element.prototype.addEventListener,
  1002. removeEventListener = Element.prototype.removeEventListener,
  1003. hasAttribute = Element.prototype.hasAttribute,
  1004. evtMap = new WeakMap();
  1005. Element.prototype.addEventListener = function(evt, func, capt) {
  1006. if (evt === 'error' || evt === 'load') {
  1007. if (!evtMap.get(func)) {
  1008. evtMap.set(func, function() {
  1009. if (hasAttribute.call(this, 'src')) {
  1010. func.apply(this, arguments);
  1011. } else {
  1012. console.log('Blocked', evt, 'handler', toString.call(func), 'on', this);
  1013. };
  1014. });
  1015. }
  1016. }
  1017. addEventListener.call(this, evt, (evtMap.get(func) ? evtMap.get(func) : func), capt)
  1018. };
  1019. Element.prototype.removeEventListener = function(evt, func, capt) {
  1020. removeEventListener.call(this, evt, (evtMap.get(func) ? evtMap.get(func) : func), capt);
  1021. }
  1022. Object.defineProperty(HTMLElement.prototype, 'onload', {
  1023. set: function(func) {
  1024. if (this.loadHandler) {
  1025. removeEventListener.call(this, 'load', this.loadHandler, false);
  1026. }
  1027. this.loadHandler = func;
  1028. if (func) {
  1029. addEventListener.call(this, 'load', func, false);
  1030. }
  1031. return func;
  1032. },
  1033. get: function() {
  1034. return this.loadHandler;
  1035. }
  1036. });
  1037. Object.defineProperty(HTMLElement.prototype, 'onerror', {
  1038. set: function(func) {
  1039. this.errorHandler = func;
  1040. console.log('Blocked error handler', toString.call(func), 'on', this);
  1041. return func;
  1042. },
  1043. get: function() {
  1044. return this.errorHandler;
  1045. }
  1046. });
  1047. }
  1048.  
  1049. var scripts = {};
  1050. // prevent popups and redirects block
  1051. var preventPopupsNow = { 'now': preventPopups },
  1052. preventBackgroundRedirectNow = { 'now': preventBackgroundRedirect },
  1053. apiBreaker = {
  1054. 'now': function() {
  1055. // prevents site from using Shadow DOM
  1056. forbidShadowRoot();
  1057. // prevents site from using error events and blocks load events without src
  1058. errorAndLoadEventsFilter();
  1059. console.log('API breaker applied.');
  1060. }
  1061. };
  1062. // Popups
  1063. scripts['chaturbate.com'] = preventPopupsNow;
  1064. scripts['mirrorcreator.com'] = preventPopupsNow;
  1065. scripts['openload.co'] = preventPopupsNow;
  1066. scripts['radikal.ru'] = preventPopupsNow;
  1067. scripts['tapochek.net'] = preventPopupsNow;
  1068. scripts['thepiratebay.org'] = preventPopupsNow;
  1069. scripts['zippyshare.com'] = preventPopupsNow;
  1070. // Background redirects
  1071. scripts['mediafire.com'] = preventBackgroundRedirectNow;
  1072. scripts['megapeer.org'] = preventBackgroundRedirectNow;
  1073. scripts['megapeer.ru'] = preventBackgroundRedirectNow;
  1074. scripts['turbobit.net'] = preventBackgroundRedirectNow;
  1075. // API breaker
  1076. scripts['24tv.ua'] = apiBreaker;
  1077. scripts['football24.ua'] = apiBreaker;
  1078. scripts['sinoptik.com.ru'] = apiBreaker;
  1079. scripts['sinoptik.ua'] = apiBreaker;
  1080.  
  1081. // other
  1082. scripts['4pda.ru'] = {
  1083. 'now': function() {
  1084. // https://gf.qytechs.cn/en/scripts/14470-4pda-unbrender
  1085. var isForum = document.location.href.search('/forum/') !== -1,
  1086. hStyle;
  1087.  
  1088. function remove(n) {
  1089. if (n) {
  1090. n.parentNode.removeChild(n);
  1091. }
  1092. }
  1093.  
  1094. function afterClean() {
  1095. hStyle.disabled = true;
  1096. remove(hStyle);
  1097. }
  1098.  
  1099. function beforeClean() {
  1100. // attach styles before document displayed
  1101. hStyle = createStyle([
  1102. 'html { overflow-y: scroll }',
  1103. 'section[id] {'+(
  1104. 'position: absolute;'+
  1105. 'width: 100%'
  1106. )+'}',
  1107. 'article + aside * { display: none !important }',
  1108. '#header + div:after {'+(
  1109. 'content: "";'+
  1110. 'position: fixed;'+
  1111. 'top: 0;'+
  1112. 'left: 0;'+
  1113. 'width: 100%;'+
  1114. 'height: 100%;'+
  1115. 'background-color: #E6E7E9'
  1116. )+'}',
  1117. // http://codepen.io/Beaugust/pen/DByiE
  1118. '@keyframes spin { 100% { transform: rotate(360deg) } }',
  1119. 'article + aside:after {'+(
  1120. 'content: "";'+
  1121. 'position: absolute;'+
  1122. 'width: 150px;'+
  1123. 'height: 150px;'+
  1124. 'top: 150px;'+
  1125. 'left: 50%;'+
  1126. 'margin-top: -75px;'+
  1127. 'margin-left: -75px;'+
  1128. 'box-sizing: border-box;'+
  1129. 'border-radius: 100%;'+
  1130. 'border: 10px solid rgba(0, 0, 0, 0.2);'+
  1131. 'border-top-color: rgba(0, 0, 0, 0.6);'+
  1132. 'animation: spin 2s infinite linear'
  1133. )+'}'
  1134. ], {id:'ubrHider'}, true);
  1135.  
  1136. // display content of a page if time to load a page is more than 2 seconds to avoid
  1137. // blocking access to a page if it is loading for too long or stuck in a loading state
  1138. setTimeout(2000, afterClean);
  1139. }
  1140.  
  1141. createStyle([
  1142. '#nav .use-ad { display: block !important }',
  1143. 'article:not(.post) + article:not(#id), a[target="_blank"] img[height="90"] { display: none !important }'
  1144. ]);
  1145.  
  1146. if (!isForum) {
  1147. beforeClean();
  1148. }
  1149.  
  1150. // save links to non-overridden functions to use later
  1151. var oGA = Element.prototype.getAttribute,
  1152. oSA = Element.prototype.setAttribute,
  1153. protectedElems;
  1154. // protect/hide changed attributes in case site attempt to restore them
  1155. function styleProtector(eventMode) {
  1156. var oRAN = Element.prototype.removeAttributeNode,
  1157. isStyleText = function(t){ return t === 'style'; },
  1158. isStyleAttr = function(a){ return a instanceof Attr && a.nodeName === 'style'; },
  1159. returnUndefined = function(){},
  1160. protectedElems = new WeakMap();
  1161. function protoOverride(element, functionName, isStyleCheck, returnIfProtected) {
  1162. var oF = element.prototype[functionName], r;
  1163. element.prototype[functionName] = function(){
  1164. if (protectedElems.get(this) !== undefined && isStyleCheck(arguments[0])) {
  1165. return returnIfProtected(protectedElems.get(this), arguments, this);
  1166. }
  1167. r = oF.apply(this, arguments);
  1168. return r;
  1169. };
  1170. }
  1171. protoOverride(Element, 'removeAttribute', isStyleText, returnUndefined);
  1172. protoOverride(Element, 'hasAttribute', isStyleText, function(o) {
  1173. return o.oldStyle !== null;
  1174. });
  1175. protoOverride(Element, 'setAttribute', isStyleText, function(o, args) {
  1176. o.oldStyle = args[1];
  1177. });
  1178. protoOverride(Element, 'getAttribute', isStyleText, function(o) {
  1179. return o.oldStyle;
  1180. });
  1181. if (eventMode) {
  1182. var e = document.createEvent('Event');
  1183. e.initEvent('protoOverride', false, false);
  1184. window.protectedElems = protectedElems;
  1185. window.dispatchEvent(e);
  1186. } else {
  1187. return protectedElems;
  1188. }
  1189. }
  1190. if (isFirefox) {
  1191. var s = document.createElement('script');
  1192. s.textContent = '(' + styleProtector.toString() + ')(true);' +
  1193. 'var s = document.currentScript; if (s) {s.parentNode.removeChild(s);}';
  1194. window.addEventListener('protoOverride', function protoOverrideCallback(e){
  1195. if (win.protectedElems) {
  1196. protectedElems = win.protectedElems;
  1197. delete win.protectedElems;
  1198. }
  1199. document.removeEventListener('protoOverride', protoOverrideCallback, true);
  1200. }, true);
  1201. document.documentElement.appendChild(s);
  1202. } else {
  1203. protectedElems = styleProtector(false);
  1204. }
  1205.  
  1206. // clean a page
  1207. window.addEventListener('DOMContentLoaded', function(){
  1208. var rem, si, itm;
  1209. function width(){ return window.innerWidth||document.documentElement.clientWidth||document.body.clientWidth||0; }
  1210. function height(){ return window.innerHeight||document.documentElement.clientHeight||document.body.clientHeight||0; }
  1211.  
  1212.  
  1213. if (isForum) {
  1214. si = document.querySelector('#logostrip');
  1215. if (si) {
  1216. remove(si.parentNode.nextSibling);
  1217. }
  1218. }
  1219.  
  1220. if (document.location.href.search('/forum/dl/') !== -1) {
  1221. document.body.setAttribute('style', (document.body.getAttribute('style')||'')+
  1222. ';background-color:black!important');
  1223. for (itm of document.querySelectorAll('body>div')) {
  1224. if (!itm.querySelector('.dw-fdwlink')) {
  1225. remove(itm);
  1226. }
  1227. }
  1228. }
  1229.  
  1230. if (isForum) { // Do not continue if it's a forum
  1231. return;
  1232. }
  1233.  
  1234. si = document.querySelector('#header');
  1235. if (si) {
  1236. rem = si.previousSibling;
  1237. while (rem) {
  1238. si = rem.previousSibling;
  1239. remove(rem);
  1240. rem = si;
  1241. }
  1242. }
  1243.  
  1244. for (itm of document.querySelectorAll('#nav li[class]')) {
  1245. if (itm && itm.querySelector('a[href^="/tag/"]')) {
  1246. remove(itm);
  1247. }
  1248. }
  1249.  
  1250. var style, result;
  1251. for (itm of document.querySelectorAll('DIV, A')) {
  1252. if (itm.tagName ==='DIV' && itm.offsetWidth > 0.95 * width() && itm.offsetHeight > 0.85 * height()) {
  1253. style = window.getComputedStyle(itm, null);
  1254. result = [];
  1255. if (style.backgroundImage !== 'none') {
  1256. result.push('background-image:none!important');
  1257. }
  1258. if (style.backgroundColor !== 'transparent' &&
  1259. style.backgroundColor !== 'rgba(0, 0, 0, 0)') {
  1260. result.push('background-color:transparent!important');
  1261. }
  1262. if (result.length) {
  1263. if (itm.getAttribute('style')) {
  1264. result.unshift(itm.getAttribute('style'));
  1265. }
  1266. (function(){
  1267. var fakeStyle = {
  1268. 'backgroundImage': itm.style.backgroundImage,
  1269. 'backgroundColor': itm.style.backgroundColor
  1270. };
  1271. try {
  1272. Object.defineProperty(itm, 'style', {
  1273. value: new Proxy(itm.style, {
  1274. get: function(target, prop){
  1275. if (fakeStyle.hasOwnProperty(prop)) {
  1276. return fakeStyle[prop];
  1277. } else {
  1278. return target[prop];
  1279. }
  1280. },
  1281. set: function(target, prop, value){
  1282. if (fakeStyle.hasOwnProperty(prop)) {
  1283. fakeStyle[prop] = value;
  1284. } else {
  1285. target[prop] = value;
  1286. }
  1287. return value;
  1288. }
  1289. }),
  1290. enumerable: true
  1291. });
  1292. } catch (e) {
  1293. console.log('Unable to protect style property.', e);
  1294. }
  1295. })();
  1296. if (protectedElems) {
  1297. protectedElems.set(itm, {oldStyle: oGA.call(itm, 'style')});
  1298. }
  1299. oSA.call(itm, 'style', result.join(';'));
  1300. }
  1301. }
  1302. if (itm.tagName ==='A' && (itm.offsetWidth > 0.95 * width() || itm.offsetHeight > 0.85 * height())) {
  1303. if (protectedElems) {
  1304. protectedElems.set(itm, {oldStyle: oGA.call(itm, 'style')});
  1305. }
  1306. oSA.call(itm, 'style', 'display:none!important');
  1307. }
  1308. }
  1309.  
  1310. for (itm of document.querySelectorAll('ASIDE>DIV')) {
  1311. if ( ((itm.querySelector('script, iframe, a[href*="/ad/www/"]') ||
  1312. itm.querySelector('img[src$=".gif"]:not([height="0"]), img[height="400"]')) &&
  1313. !itm.classList.contains('post') ) || !itm.childNodes.length ) {
  1314. remove(itm);
  1315. }
  1316. }
  1317.  
  1318. document.body.setAttribute('style', (document.body.getAttribute('style')||'')+';background-color:#E6E7E9!important');
  1319.  
  1320. // display content of the page
  1321. afterClean();
  1322. });
  1323. }
  1324. };
  1325.  
  1326. scripts['allmovie.pro'] = function() {
  1327. // pretend to be Android to make site use different played for ads
  1328. if (isSafari) {
  1329. return;
  1330. }
  1331. Object.defineProperty(navigator, 'userAgent', {
  1332. 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'; },
  1333. enumerable: true
  1334. });
  1335. };
  1336. scripts['rufilmtv.org'] = scripts['allmovie.pro'];
  1337.  
  1338. scripts['anidub-online.ru'] = function() {
  1339. var script = document.createElement('script');
  1340. script.type = "text/javascript";
  1341. script.innerHTML = "function ogonekstart1() {}";
  1342. document.getElementsByTagName('head')[0].appendChild(script);
  1343.  
  1344. var style = document.createElement('style');
  1345. style.type = 'text/css';
  1346. style.appendChild(document.createTextNode('.background {background: none!important;}'));
  1347. style.appendChild(document.createTextNode('.background > script + div, .background > script ~ div:not([id]):not([class]) + div[id][class] {display:none!important}'));
  1348. document.head.appendChild(style);
  1349. };
  1350. scripts['online.anidub.com'] = scripts['anidub-online.ru'];
  1351.  
  1352. scripts['fs.to'] = function() {
  1353. function skipClicker(i) {
  1354. if (!i) {
  1355. return;
  1356. }
  1357. var skip = document.querySelector('.b-aplayer-banners__close');
  1358. if (skip) {
  1359. skip.click();
  1360. } else {
  1361. setTimeout(skipClicker, 100, i-1);
  1362. }
  1363. }
  1364. setTimeout(skipClicker, 100, 30);
  1365.  
  1366. createStyle([
  1367. '.l-body-branding *,'+
  1368. '.b-styled__item-central,'+
  1369. '.b-styled__content-right,'+
  1370. '.b-styled__section-central,'+
  1371. 'div[id^="adsProxy-"]'+
  1372. '{display:none!important}',
  1373. 'body {background-image:url(data:image/png;base64,'+
  1374. 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAACX'+
  1375. 'BIWXMAAC4jAAAuIwF4pT92AAAADUlEQVR42mOQUdL5DwACMgFq'+
  1376. 'BC3ttwAAAABJRU5ErkJggg==)!important}'
  1377. ]);
  1378.  
  1379. if (/\/(view_iframe|iframeplayer)\//i.test(document.location.pathname)) {
  1380. var p = document.querySelector('#player:not([preload="auto"])'),
  1381. m = document.querySelector('.main'),
  1382. adStepper = function(p) {
  1383. if (p.currentTime < p.duration) {
  1384. p.currentTime += 1;
  1385. }
  1386. },
  1387. adSkipper = function(f, p) {
  1388. f.click();
  1389. p.waitAfterSkip = false;
  1390. p.longerSkipper = false;
  1391. console.log('Пропустили.');
  1392. },
  1393. cl = function(p) {
  1394. var faster = document.querySelector('.b-aplayer__html5-desktop-skip'),
  1395. series = document.querySelector('.b-aplayer__actions-series');
  1396.  
  1397. function clickSelected() {
  1398. var s = document.querySelector('.b-aplayer__popup-series-episodes .selected a');
  1399. if (s) {
  1400. s.click();
  1401. }
  1402. }
  1403.  
  1404. if ((!faster || faster.style.display !== 'block') && series && !p.seriesClicked) {
  1405. series.click();
  1406. p.seriesClicked = true;
  1407. p.longerSkipper = true;
  1408. setTimeout(clickSelected, 1000);
  1409. p.pause();
  1410. }
  1411.  
  1412. function skipListener() {
  1413. if (p.waitAfterSkip) {
  1414. console.log('В процессе пропуска…');
  1415. return;
  1416. }
  1417. p.pause();
  1418. if (!p.classList.contains('m-hidden')) {
  1419. p.classList.add('m-hidden');
  1420. }
  1421. if (faster && p.currentTime &&
  1422. win.getComputedStyle(faster).display === 'block' &&
  1423. !faster.querySelector('.b-aplayer__html5-desktop-skip-timer')) {
  1424. p.waitAfterSkip = true;
  1425. setTimeout(adSkipper, (p.longerSkipper?3:1)*1000, faster, p);
  1426. console.log('Доступен быстрый пропуск…');
  1427. } else {
  1428. setTimeout(adStepper, 1000, p);
  1429. }
  1430. }
  1431.  
  1432. p.addEventListener('timeupdate', skipListener, false);
  1433. },
  1434. o = new MutationObserver(function (ms) {
  1435. var m, node;
  1436. for (m of ms) {
  1437. for (node of m.addedNodes) {
  1438. if (node.id === 'player' &&
  1439. node.nodeName === 'VIDEO' &&
  1440. node.getAttribute('preload') !== 'auto') {
  1441. cl(node);
  1442. }
  1443. }
  1444. }
  1445. });
  1446. if (p.nodeName === 'VIDEO') {
  1447. cl(p);
  1448. } else {
  1449. o.observe(m, {childList: true});
  1450. }
  1451. }
  1452. };
  1453. scripts['brb.to'] = scripts['fs.to'];
  1454. scripts['cxz.to'] = scripts['fs.to'];
  1455.  
  1456. scripts['drive2.ru'] = function() {
  1457. gardener('.c-block:not([data-metrika="recomm"]),.o-grid__item', />Реклама<\//i);
  1458. };
  1459.  
  1460. scripts['fishki.net'] = function() {
  1461. gardener('.main-post', /543769|Реклама/);
  1462. };
  1463.  
  1464. scripts['gidonline.club'] = {
  1465. 'now': function() {
  1466. createStyle('.tray > div[style] {display: none!important}');
  1467. }
  1468. };
  1469. scripts['gidonlinekino.com'] = scripts['gidonline.club'];
  1470.  
  1471. scripts['hdgo.cc'] = {
  1472. 'now': function(){
  1473. var o = new MutationObserver(function(ms) {
  1474. var m, node;
  1475. for (m of ms) {
  1476. for (node of m.addedNodes) {
  1477. if (node.tagName === 'SCRIPT' && node.getAttribute('onerror') !== null) {
  1478. node.removeAttribute('onerror');
  1479. }
  1480. }
  1481. }
  1482. });
  1483. o.observe(document, {childList:true, subtree: true});
  1484. }
  1485. };
  1486. scripts['couber.be'] = scripts['hdgo.cc'];
  1487. scripts['46.30.43.38'] = scripts['hdgo.cc'];
  1488.  
  1489. scripts['gismeteo.ru'] = {
  1490. 'DOMContentLoaded': function() {
  1491. gardener('div > a[target^="_"]', /Яндекс\.Директ/i, { root: 'body', observe: true, parent: 'div[class*="frame"]' });
  1492. }
  1493. };
  1494.  
  1495. scripts['hdrezka.me'] = {
  1496. 'now': function() {
  1497. Object.defineProperty(win, 'fuckAdBlock', {
  1498. value: {
  1499. onDetected: function() {
  1500. console.log('Pretending to be an ABP detector.');
  1501. }
  1502. }
  1503. });
  1504. Object.defineProperty(win, 'ab', {
  1505. value: false,
  1506. enumerable: true
  1507. });
  1508. },
  1509. 'DOMContentLoaded': function() {
  1510. gardener('div[id][onclick][onmouseup][onmousedown]', /onmouseout/i);
  1511. }
  1512. };
  1513.  
  1514. scripts['imageban.ru'] = {
  1515. 'now': preventBackgroundRedirect,
  1516. 'DOMContentLoaded': function() {
  1517. win.addEventListener('unload', function() {
  1518. if (!window.location.hash) {
  1519. window.location.replace(window.location+'#');
  1520. } else {
  1521. window.location.hash = '';
  1522. }
  1523. }, true);
  1524. }
  1525. };
  1526.  
  1527. scripts['megogo.net'] = {
  1528. 'now': function() {
  1529. Object.defineProperty(win, "adBlock", {
  1530. value : false,
  1531. enumerable : true
  1532. });
  1533. Object.defineProperty(win, "showAdBlockMessage", {
  1534. value : function () {},
  1535. enumerable : true
  1536. });
  1537. }
  1538. };
  1539.  
  1540. scripts['naruto-base.su'] = function() {
  1541. gardener('div[id^="entryID"],.block', /href="http.*?target="_blank"/i);
  1542. };
  1543.  
  1544. scripts['overclockers.ru'] = {
  1545. 'now': function() {
  1546. createStyle('.fixoldhtml {display:block!important}');
  1547. if (!isChrome && !isOpera) {
  1548. return; // Looks like my code works only in Chrome-like browsers
  1549. }
  1550. var noContentYet = true;
  1551. function jWrap() {
  1552. var _$ = win.$, _e = _$.extend;
  1553. win.$ = function() {
  1554. var _ret = _$.apply(window, arguments);
  1555. if (_ret[0] === document.body) {
  1556. _ret.html = function() {
  1557. console.log('Anti-adblock prevented.');
  1558. };
  1559. }
  1560. return _ret;
  1561. };
  1562. win.$.extend = function() {
  1563. return _e.apply(_$, arguments);
  1564. };
  1565. win.jQuery = win.$;
  1566. }
  1567. (function jReady() {
  1568. if (!win.$ && noContentYet) {
  1569. setTimeout(jReady, 0);
  1570. } else {
  1571. jWrap();
  1572. }
  1573. })();
  1574. document.addEventListener ('DOMContentLoaded', function(){
  1575. noContentYet = false;
  1576. }, false);
  1577. }
  1578. };
  1579. scripts['forums.overclockers.ru'] = {
  1580. 'now': function() {
  1581. createStyle('.needblock {position: fixed; left: -10000px}');
  1582. Object.defineProperty(win, 'adblck', {
  1583. value: 'no',
  1584. enumerable: true
  1585. });
  1586. }
  1587. };
  1588.  
  1589. scripts['pb.wtf'] = function() {
  1590. createStyle('.reques,#result,tbody.row1:not([id]) {display: none !important}');
  1591. // image in the slider in the header
  1592. gardener('a[href$="=="]', /img/i, {root:'.release-navbar', observe:true, parent:'div'});
  1593. // ads in blocks on the page
  1594. gardener('a[href^="/"]', /<img\s.*<br>/i, {root:'#main_content', observe:true, parent:'div[class]'});
  1595. // line above topic content
  1596. gardener('.re_top1', /./, {root:'#main_content', parent:'.hidden-sm'});
  1597. };
  1598. scripts['piratbit.org'] = scripts['pb.wtf'];
  1599. scripts['piratbit.ru'] = scripts['pb.wtf'];
  1600.  
  1601. scripts['pesnik.su'] = {
  1602. 'now': function() {
  1603. win.Worker = function(){
  1604. console.log('Site attempted to create a WebWorker:', arguments);
  1605. return {postMessage:function(){}};
  1606. };
  1607. }
  1608. };
  1609.  
  1610. scripts['pikabu.ru'] = function() {
  1611. gardener('.story', /story__sponsor|story__gag|profile\/ads"/i, {root: '.inner_wrap', observe: true});
  1612. };
  1613.  
  1614. scripts['rp5.ru'] = function() {
  1615. createStyle('#bannerBottom {display: none!important}');
  1616. var co = document.querySelector('#content'), i, nodes;
  1617. if (!co) {
  1618. return;
  1619. }
  1620. nodes = co.parentNode.childNodes;
  1621. i = nodes.length;
  1622. while (i--) {
  1623. if (nodes[i] !== co) {
  1624. nodes[i].parentNode.removeChild(nodes[i]);
  1625. }
  1626. }
  1627. };
  1628. scripts['rp5.by'] = scripts['rp5.ru'];
  1629. scripts['rp5.ua'] = scripts['rp5.ru'];
  1630.  
  1631. scripts['rustorka.com'] = {
  1632. 'now': function() {
  1633. createStyle('.header > div:not(.head-block) a, #sidebar1 img, #logo img {opacity:0!important}', {
  1634. id: 'tempHidingStyles'
  1635. }, true);
  1636. preventPopups();
  1637. },
  1638. 'DOMContentLoaded': function() {
  1639. for (var o of document.querySelectorAll('IMG, A')) {
  1640. if ((o.clientWidth === 728 && o.clientHeight === 90) ||
  1641. (o.clientWidth === 300 && o.clientHeight === 250)) {
  1642. while (o && o.tagName !== 'A') {
  1643. o = o.parentNode;
  1644. }
  1645. if (o) {
  1646. o.setAttribute('style', 'display: none !important');
  1647. }
  1648. }
  1649. }
  1650. var s = document.querySelector('#tempHidingStyles');
  1651. s.parentNode.removeChild(s);
  1652. }
  1653. };
  1654. scripts['rumedia.ws'] = scripts['rustorka.com'];
  1655.  
  1656. scripts['sport-express.ru'] = function() {
  1657. gardener('.js-relap__item',/>Реклама\s+<\//, {root:'.container', observe: true});
  1658. };
  1659.  
  1660. scripts['sports.ru'] = function() {
  1661. gardener('.aside-news-list__item', /aside-news-list__advert/i, {root:'.aside-news-block'});
  1662. gardener('.material-list__item', /Реклама/i, {root:'.columns-layout', observe: true});
  1663. // extra functionality: shows/hides panel at the top depending on scroll direction
  1664. createStyle([
  1665. '.user-panel__fixed { transition: top 0.2s ease-in-out!important; }',
  1666. '.user-panel-up { top: -40px!important }'
  1667. ], {id: 'userPanelSlide'}, false);
  1668. (function lookForPanel() {
  1669. var panel = document.querySelector('.user-panel__fixed');
  1670. if (!panel) {
  1671. setTimeout(lookForPanel, 100);
  1672. } else {
  1673. window.addEventListener('wheel', function(e){
  1674. if (e.deltaY > 0 && !panel.classList.contains('user-panel-up')) {
  1675. panel.classList.add('user-panel-up');
  1676. } else
  1677. if (e.deltaY < 0 && panel.classList.contains('user-panel-up')) {
  1678. panel.classList.remove('user-panel-up');
  1679. }
  1680. }, false);
  1681. }
  1682. })();
  1683. };
  1684.  
  1685. scripts['www.ukr.net'] = scripts['sinoptik.com.ru'];
  1686.  
  1687. scripts['vk.com'] = function() {
  1688. gardener('div[data-post-id]', /wall_marked_as_ads/, {root: '#page_wall_posts', observe: true});
  1689. };
  1690.  
  1691. scripts['yap.ru'] = function() {
  1692. var words = /member1438|Administration/;
  1693. gardener('form > table[id^="p_row_"]', words);
  1694. gardener('tr > .holder.newsbottom', words, {parent:'tr', siblings:-2});
  1695. };
  1696. scripts['yaplakal.com'] = scripts['yap.ru'];
  1697.  
  1698. scripts['reactor.cc'] = {
  1699. 'now': function() {
  1700. win.open = (function(){ throw new Error('Redirect prevention.'); }).bind(window);
  1701. },
  1702. 'click': function(e) {
  1703. var node = e.target;
  1704. if (node.nodeType === Node.ELEMENT_NODE &&
  1705. node.style.position === 'absolute' &&
  1706. node.style.zIndex > 0)
  1707. node.parentNode.removeChild(node);
  1708. },
  1709. 'DOMContentLoaded': function() {
  1710. var words = new RegExp(
  1711. 'блокировщика рекламы'
  1712. .split('')
  1713. .map(function(e){return e+'[\u200b\u200c\u200d]*';})
  1714. .join('')
  1715. .replace(' ', '\\s*')
  1716. .replace(/[аоре]/g, function(e){return ['[аa]','[оo]','[рp]','[еe]']['аоре'.indexOf(e)];}),
  1717. 'i'),
  1718. can;
  1719. function deeper(spider) {
  1720. var c, l, n;
  1721. if (words.test(spider.innerText)) {
  1722. if (spider.nodeType === Node.TEXT_NODE) {
  1723. return true;
  1724. }
  1725. c = spider.childNodes;
  1726. l = c.length;
  1727. n = 0;
  1728. while(l--) {
  1729. if (deeper(c[l]), can) {
  1730. n++;
  1731. }
  1732. }
  1733. if (n > 0 && n === c.length && spider.offsetHeight < 750) {
  1734. can.push(spider);
  1735. }
  1736. return false;
  1737. }
  1738. return true;
  1739. }
  1740. function probe(){
  1741. if (words.test(document.body.innerText)) {
  1742. can = [];
  1743. deeper(document.body);
  1744. var i = can.length, j, spider;
  1745. while(i--) {
  1746. spider = can[i];
  1747. if (spider.offsetHeight > 10 && spider.offsetHeight < 750) {
  1748. spider.setAttribute('style', 'background:none!important');
  1749. }
  1750. }
  1751. }
  1752. }
  1753. var o = new MutationObserver(probe);
  1754. o.observe(document,{childList:true, subtree:true});
  1755. }
  1756. };
  1757. scripts['joyreactor.cc'] = scripts['reactor.cc'];
  1758. scripts['pornreactor.cc'] = scripts['reactor.cc'];
  1759.  
  1760. scripts['auto.ru'] = function() {
  1761. var words = /Реклама|Яндекс.Директ|yandex_ad_/;
  1762. var userAdsListAds = [
  1763. '.listing-list > .listing-item',
  1764. '.listing-item_type_fixed.listing-item'
  1765. ];
  1766. var catalogAds = [
  1767. 'div[class*="layout_catalog-inline"]',
  1768. 'div[class$="layout_horizontal"]'
  1769. ];
  1770. var otherAds = [
  1771. '.advt_auto',
  1772. '.sidebar-block',
  1773. '.pager-listing + div[class]',
  1774. '.card > div[class][style]',
  1775. '.sidebar > div[class]',
  1776. '.main-page__section + div[class]',
  1777. '.listing > tbody'];
  1778. gardener(userAdsListAds.join(','), words, {root:'.listing-wrap', observe:true});
  1779. gardener(catalogAds.join(','), words, {root:'.catalog__page,.content__wrapper', observe:true});
  1780. gardener(otherAds.join(','), words);
  1781. };
  1782.  
  1783. scripts['rsload.net'] = {
  1784. 'load': function() {
  1785. var dis = document.querySelector('.cb-disabless');
  1786. if (dis) {
  1787. dis.click();
  1788. }
  1789. },
  1790. 'click': function(e) {
  1791. var t = e.target;
  1792. if (t && t.href && (/:\/\/\d+\.\d+\.\d+\.\d+\//.test(t.href))) {
  1793. t.href = t.href.replace('://','://rsload.net:rsload.net@');
  1794. }
  1795. }
  1796. };
  1797.  
  1798. var domain = document.domain, name;
  1799. while (domain.indexOf('.') !== -1) {
  1800. if (scripts.hasOwnProperty(domain)) {
  1801. if (typeof scripts[domain] === 'function') {
  1802. document.addEventListener ('DOMContentLoaded', scripts[domain], false);
  1803. }
  1804. for (name in scripts[domain]) {
  1805. if (name !== 'now') {
  1806. (name === 'load' ? window : document)
  1807. .addEventListener (name, scripts[domain][name], false);
  1808. } else {
  1809. scripts[domain][name]();
  1810. }
  1811. }
  1812. }
  1813. domain = domain.slice(domain.indexOf('.') + 1);
  1814. }
  1815. })();

QingJ © 2025

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