RU AdList JS Fixes

try to take over the world!

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

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