RU AdList JS Fixes

try to take over the world!

当前为 2016-10-18 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name RU AdList JS Fixes
  3. // @namespace ruadlist_js_fixes
  4. // @version 20161018.1
  5. // @description try to take over the world!
  6. // @author lainverse & dimisa
  7. // @match *://*/*
  8. // @grant unsafeWindow
  9. // @grant window.close
  10. // @run-at document-start
  11. // ==/UserScript==
  12.  
  13. (function() {
  14. 'use strict';
  15. var win = (unsafeWindow || window);
  16.  
  17. // NodeList iterator polyfill (mostly for Safari)
  18. // https://jakearchibald.com/2014/iterators-gonna-iterate/
  19. if (!NodeList.prototype[Symbol.iterator]) {
  20. NodeList.prototype[Symbol.iterator] = Array.prototype[Symbol.iterator];
  21. }
  22.  
  23. // Creates and return protected style (unless protection is manually disabled).
  24. // Protected style will re-add itself on removal and remaind enabled on attempt to disable it.
  25. function createStyle(rules, props, skip_protect) {
  26. var root = document.documentElement;
  27.  
  28. function _protect(style) {
  29. Object.defineProperty(style, 'sheet', {
  30. value: style.sheet,
  31. enumerable: true
  32. });
  33. Object.defineProperty(style, 'disabled', {
  34. get: function() {return true;}, //pretend to be disabled
  35. set: function() {},
  36. enumerable: true
  37. });
  38. }
  39.  
  40. function _create() {
  41. var style = root.appendChild(document.createElement('style')),
  42. prop, rule;
  43. style.type = 'text/css';
  44. for (prop in props) {
  45. if (style.hasOwnProperty(prop)) {
  46. style[prop] = props[prop];
  47. }
  48. }
  49. for (rule of rules) {
  50. try {
  51. style.sheet.insertRule(rule, 0);
  52. } catch (e) {
  53. console.error(e);
  54. }
  55. }
  56. if (!skip_protect) {
  57. _protect(style);
  58. }
  59. return style;
  60. }
  61.  
  62. var style = _create();
  63. if (skip_protect) {
  64. return style;
  65. }
  66.  
  67. var o = new MutationObserver(function(ms){
  68. var m, node, rule;
  69. for (m of ms) {
  70. for (node of m.removedNodes) {
  71. if (node === style) {
  72. (new Promise(function(resolve){
  73. setTimeout(function(resolve){
  74. resolve(_create());
  75. }, 0, resolve);
  76. })).then(function(st){
  77. style = st;
  78. })
  79. }
  80. }
  81. }
  82. });
  83. o.observe(root, {childList:true});
  84.  
  85. return style;
  86. }
  87.  
  88. // https://greasyfork.org/scripts/19144-websuckit/
  89. (function() {
  90. // check does browser support Proxy and WebSocket
  91. if (typeof Proxy !== 'function' ||
  92. typeof WebSocket !== 'function') {
  93. return;
  94. }
  95.  
  96. function getWrappedCode(removeSelf) {
  97. var text = getWrappedCode.toString()+WSI.toString();
  98. text = (
  99. '(function(){"use strict";'+
  100. text.replace(/\/\/[^\r\n]*/g,'').replace(/[\s\r\n]+/g,' ')+
  101. '(new WSI(self||window)).init();'+
  102. '})();\n'+
  103. (removeSelf?'var s = document.currentScript; if (s) {s.parentNode.removeChild(s);}':'')
  104. );
  105. return text;
  106. }
  107.  
  108. function WSI(win, safeWin) {
  109. safeWin = safeWin || win;
  110. var masks = [], filter;
  111. for (filter of [// blacklist
  112. '||24video.xxx^',
  113. '||adlabs.ru^', '||adspayformymortgage.win^', '||aviabay.ru^',
  114. '||bgrndi.com^', '||brokeloy.com^',
  115. '||cnamerutor.ru^',
  116. '||docfilms.info^', '||dreadfula.ru^',
  117. '||et-code.ru^',
  118. '||film-doma.ru^',
  119. '||free-torrent.org^', '||free-torrent.pw^',
  120. '||free-torrents.org^', '||free-torrents.pw^',
  121. '||game-torrent.info^', '||gocdn.ru^',
  122. '||hdkinoshka.com^', '||hghit.com^', '||hindcine.net^',
  123. '||kiev.ua^', '||kinotochka.net^',
  124. '||kinott.com^', '||kinott.ru^', '||kuveres.com^',
  125. '||lepubs.com^', '||luxadv.com^', '||luxup.ru^',
  126. '||mail.ru^', '||marketgid.com^', '||mxtads.com^',
  127. '||oconner.biz^',
  128. '||pkpojhc.com^',
  129. '||psma01.com^', '||psma02.com^', '||psma03.com^',
  130. '||recreativ.ru^', '||regpole.com^', '||ruttwind.com^',
  131. '||skidl.ru^',
  132. '||torvind.com^', '||trafmag.com^',
  133. '||webadvert-gid.ru^', '||webadvertgid.ru^',
  134. '||xxuhter.ru^',
  135. '||yuiout.online^',
  136. '||zoom-film.ru^'
  137. ]) {
  138. masks.push(new RegExp(
  139. filter.replace(/([\\\/\[\].*+?(){}$])/g, '\\$1')
  140. .replace(/\^(?!$)/g,'\\.?[^\\w%._-]')
  141. .replace(/\^$/,'\\.?([^\\w%._-]|$)')
  142. .replace(/^\|\|/,'^wss?:\\/+([^\/.]+\\.)*'),
  143. 'i'));
  144. }
  145.  
  146. function isBlocked(url) {
  147. for (var mask of masks) {
  148. if (mask.test(url)) {
  149. return true;
  150. }
  151. }
  152. return false;
  153. }
  154.  
  155. var realWebSocket = win.WebSocket;
  156. function wsGetter (target, name) {
  157. try {
  158. if (typeof realWebSocket.prototype[name] === 'function') {
  159. if (name === 'close' || name === 'send') { // send also closes connection
  160. target.readyState = realWebSocket.CLOSED;
  161. }
  162. return (
  163. function fake() {
  164. console.log('[WSI] Invoked function "'+name+'"', '| Tracing', (new Error()));
  165. return;
  166. }
  167. );
  168. }
  169. if (typeof realWebSocket.prototype[name] === 'number') {
  170. return realWebSocket[name];
  171. }
  172. } catch(ignore) {}
  173. return target[name];
  174. }
  175.  
  176. function createWebSocketWrapper(target) {
  177. return new Proxy(realWebSocket, {
  178. construct: function (target, args) {
  179. var url = args[0];
  180. console.log('[WSI] Opening socket on ' + url + ' \u2026');
  181. if (isBlocked(url)) {
  182. console.log("[WSI] Blocked.");
  183. return new Proxy({
  184. url: url,
  185. readyState: realWebSocket.OPEN
  186. }, {
  187. get: wsGetter
  188. });
  189. }
  190. return new target(args[0], args[1]);
  191. }
  192. });
  193. }
  194.  
  195. function WorkerWrapper() {
  196. var realWorker = win.Worker;
  197. function wrappedWorker(resourceURI) {
  198. var isBlobURL = /^blob:/i,
  199. _callbacks = new WeakMap(),
  200. _worker = null,
  201. _terminate = false,
  202. _onerror = null,
  203. _onmessage = null,
  204. _messages = [],
  205. _events = [],
  206. _self = this;
  207.  
  208. function callbackWrapper(func) {
  209. if (typeof func !== 'function') {
  210. return undefined;
  211. }
  212. return (
  213. function callback() {
  214. func.apply(_self, arguments);
  215. }
  216. );
  217. }
  218.  
  219. (new Promise(function(resolve, reject){
  220. if (!isBlobURL.test(resourceURI)) {
  221. return resolve(new realWorker(resourceURI));
  222. }
  223.  
  224. var xhr = new XMLHttpRequest();
  225. xhr.open('GET', resourceURI, true);
  226. xhr.responseType = 'blob';
  227. xhr.onload = function(){
  228. if (this.status === 200) {
  229. var reader = new FileReader();
  230. reader.addEventListener("loadend", function() {
  231. resolve(new realWorker(URL.createObjectURL(
  232. new Blob([getWrappedCode(false)+this.result])
  233. )));
  234. });
  235. reader.readAsText(this.response);
  236. }
  237. };
  238. xhr.send();
  239. })).then(function(val) {
  240. _worker = val;
  241. _worker.onerror = callbackWrapper(_onerror);
  242. _worker.onmessage = callbackWrapper(_onmessage);
  243. var _e;
  244. while(_events.length) {
  245. _e = _events.shift();
  246. _worker[_e[0]].apply(_worker, _e[1]);
  247. }
  248. while(_messages.length) {
  249. _worker.postMessage(_messages.shift());
  250. }
  251. if (_terminate) {
  252. _worker.terminate();
  253. }
  254. });
  255.  
  256. _self.terminate = function(){
  257. _terminate = true;
  258. if (_worker) {
  259. _worker.terminate();
  260. }
  261. };
  262. Object.defineProperty(_self, 'onmessage', {
  263. get: function() {
  264. return _onmessage;
  265. },
  266. set: function(val) {
  267. _onmessage = val;
  268. if (_worker) {
  269. _worker.onmessage = callbackWrapper(val);
  270. }
  271. }
  272. });
  273. Object.defineProperty(_self, 'onerror', {
  274. get: function() {
  275. return _onerror;
  276. },
  277. set: function(val) {
  278. _onerror = val;
  279. if (_worker) {
  280. _worker.onerror = callbackWrapper(val);
  281. }
  282. }
  283. });
  284. _self.postMessage = function(message){
  285. if (_worker) {
  286. _worker.postMessage(message);
  287. } else {
  288. _messages.push(message);
  289. }
  290. };
  291. _self.terminate = function() {
  292. _terminate = true;
  293. if (_worker) {
  294. _worker.terminate();
  295. }
  296. };
  297. _self.addEventListener = function(){
  298. if (typeof arguments[1] !== 'function') {
  299. return;
  300. }
  301. if (!_callbacks.has(arguments[1])) {
  302. _callbacks.set(arguments[1], callbackWrapper(arguments[1]));
  303. }
  304. arguments[1] = _callbacks.get(arguments[1]);
  305. if (_worker) {
  306. _worker.addEventListener.apply(_worker, arguments);
  307. } else {
  308. _events.push(['addEventListener', arguments]);
  309. }
  310. };
  311. _self.removeEventListener = function(){
  312. if (typeof arguments[1] !== 'function' || !_callbacks.has(arguments[1])) {
  313. return;
  314. }
  315. arguments[1] = _callbacks.get(arguments[1]);
  316. _callbacks.delete(arguments[1]);
  317. if (_worker) {
  318. _worker.removeEventListener.apply(_worker, arguments);
  319. } else {
  320. _events.push(['removeEventListener', arguments]);
  321. }
  322. };
  323. }
  324. win.Worker = wrappedWorker.bind(safeWin);
  325. }
  326.  
  327. function CreateElementWrapper() {
  328. var realCreateElement = document.createElement.bind(document),
  329. code = encodeURIComponent('<scr'+'ipt>'+getWrappedCode(true)+'</scr'+'ipt>\n'),
  330. isDataURL = /^data:/i,
  331. isBlobURL = /^blob:/i;
  332.  
  333. function frameRewrite(e) {
  334. var f = e.target,
  335. w = f.contentWindow;
  336. if (!f.src) {
  337. return; // nothing to do here if source is unknown
  338. }
  339. if (isDataURL.test(f.src) && f.src.indexOf(code) < 0) {
  340. f.src = f.src.replace(',',',' + code);
  341. }
  342. if (w && isBlobURL.test(f.src)) {
  343. w.WebSocket = createWebSocketWrapper();
  344. }
  345. }
  346.  
  347. function wrappedCreateElement(name) {
  348. if (name && name.toUpperCase &&
  349. name.toUpperCase() === 'IFRAME') {
  350. var ifr = realCreateElement.apply(document, arguments);
  351. ifr.addEventListener('load', frameRewrite, false);
  352. return ifr;
  353. }
  354. return realCreateElement.apply(document, arguments);
  355. }
  356. document.createElement = wrappedCreateElement.bind(document);
  357.  
  358. document.addEventListener('DOMContentLoaded', function(){
  359. for (var ifr of document.querySelectorAll('IFRAME')) {
  360. ifr.addEventListener('load', frameRewrite, false);
  361. }
  362. }, false);
  363. }
  364.  
  365. this.init = function() {
  366. win.WebSocket = createWebSocketWrapper();
  367. // TempFix: Skip WorkerWrapper on Twitter due to weird CPS which breaks their own Worker object (or my code instead)
  368. if (!/^([^.]*?\.)*?twitter.com$/.test(safeWin.location.hostname)) {
  369. WorkerWrapper();
  370. }
  371. if (typeof document !== 'undefined') {
  372. CreateElementWrapper();
  373. }
  374. };
  375. }
  376.  
  377. if (/firefox/i.test(navigator.userAgent)) {
  378. var script = document.createElement('script');
  379. script.appendChild(document.createTextNode(getWrappedCode()));
  380. document.head.insertBefore(script, document.head.firstChild);
  381. return; //we don't want to call functions on page from here in Fx, so exit
  382. }
  383.  
  384. (new WSI((unsafeWindow||self||window),(self||window))).init();
  385. })();
  386.  
  387. if (!(/firefox/i.test(navigator.userAgent))) { // scripts for non-Firefox browsers
  388.  
  389. // https://greasyfork.org/scripts/14720-it-s-not-important
  390. (function(){
  391. var imptt = /((display|(margin|padding)(-top|-bottom)?)\s*:[^;!]*)!\s*important/ig;
  392.  
  393. function unimportanter(el, si) {
  394. if (!imptt.test(si) || el.style.display === 'none') {
  395. return 0; // get out if we have nothing to do here
  396. }
  397. if (el.nodeName === 'IFRAME' && el.src &&
  398. el.src.slice(0,17) === 'chrome-extension:') {
  399. return 0; // Web of Trust uses this method to add their frame
  400. }
  401. var so = si.replace(imptt, function(){return arguments[1];}), ret = 0;
  402. if (si !== so) {
  403. ret = 1;
  404. el.setAttribute('style', so);
  405. }
  406. return ret;
  407. }
  408.  
  409. function logger(c) {
  410. if (c) {
  411. console.log('Some page elements became a bit less important.');
  412. }
  413. }
  414.  
  415. function checkTarget(node, cnt) {
  416. if (!(node && node.getAttribute)) {
  417. return 0;
  418. }
  419. var si = node.getAttribute('style');
  420. if (si && si.indexOf('!') > -1) {
  421. cnt += unimportanter(node, si);
  422. }
  423. return cnt;
  424. }
  425.  
  426. var observer = new MutationObserver(function(mutations) {
  427. setTimeout(function(ms) {
  428. var cnt = 0, m, node;
  429. for (m of ms) {
  430. cnt = checkTarget(m.target, cnt);
  431. for (node of m.addedNodes) {
  432. cnt += checkTarget(node, cnt);
  433. }
  434. }
  435. logger(cnt);
  436. }, 0, mutations);
  437. });
  438.  
  439. observer.observe(document, { childList : true, attributes : true, attributeFilter : ['style'], subtree : true });
  440.  
  441. win.addEventListener ("load", function(){
  442. var c = 0, imp;
  443. for (imp of document.querySelectorAll('[style*="!"]')) {
  444. c+= checkTarget(imp, c);
  445. }
  446. logger(c);
  447. }, false);
  448. })();
  449.  
  450. }
  451.  
  452. if (/^https?:\/\/(news\.yandex\.|(www\.)?yandex\.[^\/]+\/(yand)?search[\/?])/i.test(win.location.href)) {
  453. // https://greasyfork.org/en/scripts/809-no-yandex-ads
  454. (function(){
  455. var adWords = ['Яндекс.Директ','Реклама','Ad'];
  456. function remove(node) {
  457. node.parentNode.removeChild(node);
  458. }
  459. // Generic ads removal and fixes
  460. function removeGenericAds() {
  461. var s, i;
  462. s = document.querySelector('.serp-header');
  463. if (s) {
  464. s.style.marginTop='0';
  465. }
  466. for (s of document.querySelectorAll('.serp-adv__head + .serp-item, #adbanner, .serp-adv, .b-spec-adv, div[class*="serp-adv__"]')) {
  467. remove(s);
  468. }
  469. }
  470. // Search ads
  471. function removeSearchAds() {
  472. var s, item;
  473. for (s of document.querySelectorAll('.serp-block, .serp-item, .search-item')) {
  474. item = s.querySelector('.label, .serp-item__label, .document__provider-name');
  475. if (item && adWords.indexOf(item.textContent) > -1) {
  476. remove(s);
  477. console.log('Ads removed.');
  478. }
  479. }
  480. }
  481. // News ads
  482. function removeNewsAds() {
  483. var s;
  484. for (s of document.querySelectorAll('.page-content__left > *,.page-content__right > *:not(.page-content__col),.page-content__right > .page-content__col > *')) {
  485. if (s.textContent.indexOf(adWords[0]) > -1) {
  486. remove(s);
  487. console.log('Ads removed.');
  488. }
  489. }
  490. }
  491. // News fixes
  492. function removePageAdsClass() {
  493. if (document.body.classList.contains("b-page_ads_yes")){
  494. document.body.classList.remove("b-page_ads_yes");
  495. console.log('Page ads class removed.');
  496. }
  497. }
  498. // Function to attach an observer to monitor dynamic changes on the page
  499. function pageUpdateObserver(func, obj, params) {
  500. if (obj) {
  501. var o = new MutationObserver(func);
  502. o.observe(obj,(params || {childList:true, subtree:true}));
  503. }
  504. }
  505. // Cleaner
  506. document.addEventListener ('DOMContentLoaded', function() {
  507. removeGenericAds();
  508. if (win.location.hostname.search(/^news\./i) === 0) {
  509. pageUpdateObserver(removeNewsAds, document.querySelector('BODY'));
  510. pageUpdateObserver(removePageAdsClass, document.body, {attributes:true, attributesFilter:['class']});
  511. removeNewsAds();
  512. removePageAdsClass();
  513. } else {
  514. pageUpdateObserver(removeSearchAds, document.querySelector('.main__content'));
  515. removeSearchAds();
  516. }
  517. });
  518. })();
  519. return; //skip fixes for other sites
  520. }
  521.  
  522. // https://greasyfork.org/en/scripts/14470-4pda-unbrender
  523. if (/(^|\.)4pda\.ru$/i.test(window.location.hostname)) {
  524. (function() {
  525. var isForum = document.location.href.search('/forum/') !== -1,
  526. hStyle;
  527.  
  528. function remove(n) {
  529. if (n) {
  530. n.parentNode.removeChild(n);
  531. }
  532. }
  533.  
  534. function afterClean() {
  535. hStyle.disabled = true;
  536. remove(hStyle);
  537. }
  538.  
  539. function beforeClean() {
  540. // attach styles before document displayed
  541. hStyle = createStyle([
  542. 'html { overflow-y: scroll }',
  543. 'article + aside * { display: none !important }',
  544. '#header + div:after {'+(
  545. 'content: "";'+
  546. 'position: fixed;'+
  547. 'top: 0;'+
  548. 'left: 0;'+
  549. 'width: 100%;'+
  550. 'height: 100%;'+
  551. 'background-color: #E6E7E9'
  552. )+'}',
  553. // http://codepen.io/Beaugust/pen/DByiE
  554. '@keyframes spin { 100% { transform: rotate(360deg) } }',
  555. 'article + aside:after {'+(
  556. 'content: "";'+
  557. 'position: absolute;'+
  558. 'width: 150px;'+
  559. 'height: 150px;'+
  560. 'top: 150px;'+
  561. 'left: 50%;'+
  562. 'margin-top: -75px;'+
  563. 'margin-left: -75px;'+
  564. 'box-sizing: border-box;'+
  565. 'border-radius: 100%;'+
  566. 'border: 10px solid rgba(0, 0, 0, 0.2);'+
  567. 'border-top-color: rgba(0, 0, 0, 0.6);'+
  568. 'animation: spin 2s infinite linear'
  569. )+'}'
  570. ], {id:'ubrHider'}, true);
  571.  
  572. // display content of a page if time to load a page is more than 2 seconds to avoid
  573. // blocking access to a page if it is loading for too long or stuck in a loading state
  574. setTimeout(2000, afterClean);
  575. }
  576.  
  577. createStyle([
  578. '#nav .use-ad { display: block !important }',
  579. 'article:not(.post) + article:not(#id), a[target="_blank"] img[height="90"] { display: none !important }'
  580. ]);
  581.  
  582. if (!isForum) {
  583. beforeClean();
  584. }
  585.  
  586. // protect/hide changed attributes in case site attempt to restore them
  587. var oGA = Element.prototype.getAttribute,
  588. oSA = Element.prototype.setAttribute,
  589. oRAN = Element.prototype.removeAttributeNode,
  590. isStyleText = function(t){ return t === 'style'; },
  591. isStyleAttr = function(a){ return a instanceof Attr && a.nodeName === 'style' },
  592. returnUndefined = function(){},
  593. protectedElems = new WeakMap();
  594. function protoOverride(element, functionName, isStyleCheck, returnIfProtected) {
  595. var oF = element.prototype[functionName];
  596. element.prototype[functionName] = function(){
  597. if (protectedElems.get(this) !== undefined && isStyleCheck(arguments[0])) {
  598. return returnIfProtected(protectedElems.get(this), arguments, this);
  599. }
  600. return oF.apply(this, arguments);
  601. }
  602. }
  603. protoOverride(Element, 'removeAttribute', isStyleText, returnUndefined);
  604. protoOverride(Element, 'removeAttributeNS', isStyleText, returnUndefined);
  605. protoOverride(Element, 'removeAttributeNode', isStyleAttr, function(o, args, node) {
  606. if (args[0] instanceof Attr && args[0].ownerElement !== node) {
  607. // throw 'attribute of another element' error
  608. oRAN.call(node, document.createAttribute('style'));
  609. }
  610. if (o.oldStyle === null) {
  611. // throw 'not an Attr' error
  612. oRAN.call(node, null);
  613. }
  614. o.oldStyle = null;
  615. return args[0];
  616. });
  617. protoOverride(Element, 'hasAttribute', isStyleText, function(o) {
  618. return o.oldStyle !== null;
  619. });
  620. protoOverride(Element, 'hasAttributeNS', isStyleText, function(o) {
  621. return o.oldStyle !== null;
  622. });
  623. protoOverride(Element, 'setAttribute', isStyleText, function(o, args) {
  624. o.oldStyle = args[1];
  625. });
  626. protoOverride(Element, 'setAttributeNS', isStyleText, returnUndefined);
  627. protoOverride(Element, 'setAttributeNode', isStyleAttr, returnUndefined);
  628. protoOverride(Element, 'getAttribute', isStyleText, function(o) {
  629. return o.oldStyle;
  630. });
  631. protoOverride(Element, 'getAttributeNS', isStyleText, returnUndefined);
  632. protoOverride(Element, 'getAttributeNode', isStyleText, function(o){
  633. if (o.oldStyle === null) {
  634. return null;
  635. }
  636. var at = document.createAttribute('style');
  637. at.value = o.oldStyle;
  638. Object.defineProperty(at, 'ownerElement', {
  639. value: this,
  640. enumerable: true
  641. });
  642. return at;
  643. });
  644.  
  645. // clean a page
  646. window.addEventListener('DOMContentLoaded', function(){
  647. var rem, si, itm;
  648. function width(){ return window.innerWidth||document.documentElement.clientWidth||document.body.clientWidth||0; }
  649. function height(){ return window.innerHeight||document.documentElement.clientHeight||document.body.clientHeight||0; }
  650.  
  651.  
  652. if (isForum) {
  653. si = document.querySelector('#logostrip');
  654. if (si) {
  655. remove(si.parentNode.nextSibling);
  656. }
  657. }
  658.  
  659. if (document.location.href.search('/forum/dl/') !== -1) {
  660. document.body.setAttribute('style', (document.body.getAttribute('style')||'')+
  661. ';background-color:black!important');
  662. for (itm of document.querySelectorAll('body>div')) {
  663. if (!itm.querySelector('.dw-fdwlink')) {
  664. remove(itm);
  665. }
  666. }
  667. }
  668.  
  669. if (isForum) { // Do not continue if it's a forum
  670. return;
  671. }
  672.  
  673. si = document.querySelector('#header');
  674. if (si) {
  675. rem = si.previousSibling;
  676. while (rem) {
  677. si = rem.previousSibling;
  678. remove(rem);
  679. rem = si;
  680. }
  681. }
  682.  
  683. for (itm of document.querySelectorAll('#nav li[class]')) {
  684. if (itm && itm.querySelector('a[href^="/tag/"]')) {
  685. remove(itm);
  686. }
  687. }
  688.  
  689. var style, result;
  690. for (itm of document.querySelectorAll('DIV')) {
  691. if (itm.offsetWidth > 0.95 * width() && itm.offsetHeight > 0.8 * height()) {
  692. style = window.getComputedStyle(itm, null);
  693. result = [];
  694. if (style.backgroundImage !== 'none') {
  695. result.push('background-image:none!important');
  696. }
  697. if (style.backgroundColor !== 'transparent' &&
  698. style.backgroundColor !== 'rgba(0, 0, 0, 0)') {
  699. result.push('background-color:transparent!important');
  700. }
  701. if (result.length) {
  702. if (itm.getAttribute('style')) {
  703. result.unshift(itm.getAttribute('style'));
  704. }
  705. (function(){
  706. var bgi = itm.style.backgroundImage,
  707. bgc = itm.style.backgroundColor;
  708. Object.defineProperty(itm.style, 'backgroundImage', {
  709. get: function(){return bgi;},
  710. set: function(){}
  711. });
  712. Object.defineProperty(itm.style, 'backgroundColor', {
  713. get: function(){return bgc;},
  714. set: function(){}
  715. });
  716. Object.defineProperty(itm, 'style', {value: itm.style});
  717. })();
  718. protectedElems.set(itm, {oldStyle: oGA.call(itm, 'style')});
  719. oSA.call(itm, 'style', result.join(';'));
  720. }
  721. }
  722. }
  723.  
  724. for (itm of document.querySelectorAll('ASIDE>DIV')) {
  725. if ( ((itm.querySelector('script, iframe, a[href*="/ad/www/"]') ||
  726. itm.querySelector('img[src$=".gif"]:not([height="0"]), img[height="400"]')) &&
  727. !itm.classList.contains('post') ) || !itm.childNodes.length ) {
  728. remove(itm);
  729. }
  730. }
  731.  
  732. document.body.setAttribute('style', (document.body.getAttribute('style')||'')+';background-color:#E6E7E9!important');
  733.  
  734. // display content of the page
  735. afterClean();
  736. });
  737. })();
  738. return;
  739. }
  740.  
  741. // https://greasyfork.org/en/scripts/21937-moonwalk-hdgo-kodik-fix v0.7+ (adapted & fixed)
  742. document.addEventListener ('DOMContentLoaded', function() {
  743. var tmp, t;1
  744. function log (e) {
  745. console.log('Moonwalk&HDGo&Kodik FIX: ' + e + ' player in ' + win.location.href);
  746. }
  747. if (win.adv_enabled !== undefined && win.condition_detected !== undefined) { // moonwalk
  748. log('Moonwalk');
  749. win.adv_enabled = false;
  750. win.condition_detected = false;
  751. if (win.MXoverrollCallback) {
  752. document.addEventListener('click', function catcher(e){
  753. e.stopPropagation();
  754. win.MXoverrollCallback.call(window);
  755. document.removeEventListener('click', catcher, true);
  756. }, true);
  757. }
  758. } else if (win.banner_second !== undefined && win.$banner_ads !== undefined) { // hdgo
  759. log('HDGo');
  760. tmp = document.querySelector('#swtf');
  761. if (tmp) {
  762. tmp.style.display = 'none';
  763. }
  764. win.banner_second = 0;
  765. win.$banner_ads = false;
  766. if (win.$new_ads !== undefined) {
  767. win.$new_ads = false;
  768. }
  769. if (win.canRunAds !== undefined && win.canRunAds !== true) {
  770. win.canRunAds = true;
  771. }
  772. } else if (win.MXoverrollCallback && win.iframeSearch !== undefined) { // kodik
  773. log('Kodik');
  774. tmp = document.querySelector('.play_button');
  775. if (tmp) {
  776. tmp.onclick = win.MXoverrollCallback.bind(window);
  777. }
  778. win.IsAdBlock = false;
  779. }
  780. }, false);
  781.  
  782. // function to search and remove nodes by content
  783. // selector - standard CSS selector to define set of nodes to check
  784. // words - regular expression to check content of the suspicious nodes
  785. // params - object with multiple extra parameters:
  786. // .hide - set display to none instead of removing from the page
  787. // .parent - parent node to remove if content is found in the child node
  788. // .siblings - number of simling nodes to remove (excluding text nodes)
  789. function scRemove(e) {e.parentNode.removeChild(e);}
  790. function scHide(e) {
  791. var s = e.getAttribute('style')||'',
  792. h = ';display:none!important;';
  793. if (s.indexOf(h) < 0) {
  794. e.setAttribute('style', s+h);
  795. }
  796. }
  797. function scissors (selector, words, scope, params) {
  798. var remFunc = (params.hide ? scHide : scRemove),
  799. iterFunc = (params.siblings > 0 ?
  800. 'nextSibling' :
  801. 'previousSibling'),
  802. toRemove = [],
  803. siblings,
  804. node;
  805. for (node of scope.querySelectorAll(selector)) {
  806. if (words.test(node.innerHTML) || !node.childNodes.length) {
  807. // drill up to the specified parent node if required
  808. if (params.parent) {
  809. while(node !== scope && !(node.matches(params.parent))) {
  810. node = node.parentNode;
  811. }
  812. }
  813. if (node === scope) {
  814. break;
  815. }
  816. toRemove.push(node);
  817. // add multiple nodes if defined more than one sibling
  818. siblings = Math.abs(params.siblings) || 0;
  819. while (siblings) {
  820. node = node[iterFunc];
  821. toRemove.push(node);
  822. if (node.nodeType === Node.ELEMENT_NODE) {
  823. siblings -= 1; //count only element nodes
  824. }
  825. }
  826. }
  827. }
  828. for (node of toRemove) {
  829. remFunc(node);
  830. }
  831. return toRemove.length;
  832. }
  833.  
  834. // function to perform multiple checks if ads inserted with a delay
  835. // by default does 30 checks withing a 3 seconds unless nonstop mode specified
  836. // also does 1 extra check when a page completely loads
  837. // selector and words - passed dow to scissors
  838. // params - object with multiple extra parameters:
  839. // .root - selector to narrow down scope to scan;
  840. // .observe - if true then check will be performed continuously;
  841. // Other parameters passed down to scissors.
  842. function gardener(selector, words, params) {
  843. params = params || {};
  844. var scope = document.body,
  845. nonstop = false;
  846. // narrow down scope to a specific element
  847. if (params.root) {
  848. scope = scope.querySelector(params.root);
  849. if (!scope) {// exit if the root element is not present on the page
  850. return 0;
  851. }
  852. }
  853. // add observe mode if required
  854. if (params.observe) {
  855. if (typeof MutationObserver === 'function') {
  856. var o = new MutationObserver(function(ms){
  857. for (var m of ms) {
  858. if (m.addedNodes.length) {
  859. scissors(selector, words, scope, params);
  860. }
  861. }
  862. });
  863. o.observe(scope, {childList:true, subtree: true});
  864. } else {
  865. nonstop = true;
  866. }
  867. }
  868. // wait for a full page load to do one extra cut
  869. win.addEventListener('load',function(){
  870. scissors(selector, words, scope, params);
  871. });
  872. // do multiple cuts until ads removed
  873. function cut(sci, s, w, sc, p, i) {
  874. if (i > 0) {
  875. i -= 1;
  876. }
  877. if (i && !sci(s, w, sc, p)) {
  878. setTimeout(cut, 100, sci, s, w, sc, p, i);
  879. }
  880. }
  881. cut(scissors, selector, words, scope, params, (nonstop ? -1 : 30));
  882. }
  883.  
  884. function preventBackgroundRedirect() {
  885. // create "cose_me" event to call high-level window.close()
  886. var key = Math.random().toString(36).substr(2);
  887. window.addEventListener('close_me_'+key, function(e) {
  888. window.close();
  889. });
  890.  
  891. // window.open wrapper
  892. function pbrLander() {
  893. var orgOpen = window.open.bind(window);
  894. function closeWindow(){
  895. // site went to a new tab and attempts to unload
  896. // call for high-level close through event
  897. var event = new CustomEvent("close_me_%key%", {});
  898. window.dispatchEvent(event);
  899. }
  900. function open(){
  901. var idx = String.prototype.indexOf;
  902. if (arguments[0] &&
  903. (idx.call(arguments[0], window.location.host) > -1 ||
  904. idx.call(arguments[0], '://') === -1)) {
  905. window.addEventListener('unload', closeWindow, true);
  906. }
  907. orgOpen.apply(window, arguments);
  908. }
  909. window.open = open.bind(window);
  910. var s = document.currentScript;
  911. if (s) {s.parentNode.removeChild(s);}
  912. }
  913.  
  914. // land wrapper on the page
  915. var script = document.createElement('script');
  916. script.appendChild(document.createTextNode('('+pbrLander.toString().replace(/%key%/g,key)+')();'));
  917. document.head.insertBefore(script,document.head.firstChild);
  918. console.log("Background redirect prevention enabled.");
  919. }
  920.  
  921. function forbidServiceWorker() {
  922. if (!("serviceWorker" in navigator)) {
  923. return;
  924. }
  925. var svr = navigator.serviceWorker.ready;
  926. Object.defineProperty(navigator, 'serviceWorker', {
  927. value: {
  928. register: function(){
  929. console.log('Registration of serviceWorker ' + arguments[0] + ' blocked.');
  930. return new Promise(function(){});
  931. },
  932. ready: new Promise(function(){}),
  933. addEventListener:function(){}
  934. }
  935. });
  936. document.addEventListener('DOMContentLoaded', function() {
  937. if (!svr) {
  938. return;
  939. }
  940. svr.then(function(sw) {
  941. console.log('Found existing serviceWorker:', sw);
  942. console.log('Attempting to unregister...');
  943. sw.unregister().then(function() {
  944. console.log('Unregistered! :)');
  945. }).catch(function(err) {
  946. console.log('Unregistration failed. :(', err);
  947. console.log('Try to remove it manually:');
  948. console.log(' 1. Open: chrome://serviceworker-internals/ (Google Chrome and alike) or about:serviceworkers (Mozilla Firefox) in a new tab.');
  949. console.log(' 2. Search there for one with "'+document.domain+'" in the name.');
  950. console.log(' 3. Use buttons in the same block with service you found to stop it and uninstall/unregister.');
  951. });
  952. }).catch(function(err) {
  953. console.log("Lol, it failed on it's own. -_-", err);
  954. });
  955. }, false);
  956. }
  957.  
  958. var scripts = {};
  959. scripts['fs.to'] = function() {
  960. function skipClicker(i) {
  961. if (!i) {
  962. return;
  963. }
  964. var skip = document.querySelector('.b-aplayer-banners__close');
  965. if (skip) {
  966. skip.click();
  967. } else {
  968. setTimeout(skipClicker, 100, i-1);
  969. }
  970. }
  971. setTimeout(skipClicker, 100, 30);
  972.  
  973. createStyle([
  974. '.l-body-branding *,'+
  975. '.b-styled__item-central,'+
  976. '.b-styled__content-right,'+
  977. '.b-styled__section-central,'+
  978. 'div[id^="adsProxy-"]'+
  979. '{display:none!important}',
  980. 'body {background-image:url(data:image/png;base64,'+
  981. 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAACX'+
  982. 'BIWXMAAC4jAAAuIwF4pT92AAAADUlEQVR42mOQUdL5DwACMgFq'+
  983. 'BC3ttwAAAABJRU5ErkJggg==)!important}'
  984. ]);
  985.  
  986. if (/\/(view_iframe|iframeplayer)\//i.test(document.location.pathname)) {
  987. var p = document.querySelector('#player:not([preload="auto"])'),
  988. m = document.querySelector('.main'),
  989. adStepper = function(p) {
  990. if (p.currentTime < p.duration) {
  991. p.currentTime += 1;
  992. }
  993. },
  994. adSkipper = function(f, p) {
  995. f.click();
  996. p.waitAfterSkip = false;
  997. p.longerSkipper = false;
  998. console.log('Пропустили.');
  999. },
  1000. cl = function(p) {
  1001. var faster = document.querySelector('.b-aplayer__html5-desktop-skip'),
  1002. series = document.querySelector('.b-aplayer__actions-series');
  1003.  
  1004. function clickSelected() {
  1005. var s = document.querySelector('.b-aplayer__popup-series-episodes .selected a');
  1006. if (s) {
  1007. s.click();
  1008. }
  1009. }
  1010.  
  1011. if ((!faster || faster.style.display !== 'block') && series && !p.seriesClicked) {
  1012. series.click();
  1013. p.seriesClicked = true;
  1014. p.longerSkipper = true;
  1015. setTimeout(clickSelected, 1000);
  1016. p.pause();
  1017. }
  1018.  
  1019. function skipListener() {
  1020. if (p.waitAfterSkip) {
  1021. console.log('В процессе пропуска…');
  1022. return;
  1023. }
  1024. p.pause();
  1025. if (!p.classList.contains('m-hidden')) {
  1026. p.classList.add('m-hidden');
  1027. }
  1028. if (faster && p.currentTime &&
  1029. win.getComputedStyle(faster).display === 'block' &&
  1030. !faster.querySelector('.b-aplayer__html5-desktop-skip-timer')) {
  1031. p.waitAfterSkip = true;
  1032. setTimeout(adSkipper, (p.longerSkipper?3:1)*1000, faster, p);
  1033. console.log('Доступен быстрый пропуск…');
  1034. } else {
  1035. setTimeout(adStepper, 1000, p);
  1036. }
  1037. }
  1038.  
  1039. p.addEventListener('timeupdate', skipListener, false);
  1040. },
  1041. o = new MutationObserver(function (ms) {
  1042. var m, node;
  1043. for (m of ms) {
  1044. for (node of m.addedNodes) {
  1045. if (node.id === 'player' &&
  1046. node.nodeName === 'VIDEO' &&
  1047. node.getAttribute('preload') !== 'auto') {
  1048. cl(node);
  1049. }
  1050. }
  1051. }
  1052. });
  1053. if (p.nodeName === 'VIDEO') {
  1054. cl(p);
  1055. } else {
  1056. o.observe(m, {childList: true});
  1057. }
  1058. }
  1059. };
  1060. scripts['brb.to'] = scripts['fs.to'];
  1061. scripts['cxz.to'] = scripts['fs.to'];
  1062.  
  1063. scripts['drive2.ru'] = function() {
  1064. gardener('.c-block:not(.js-recommendations),.o-grid__item', />Реклама<\//i);
  1065. };
  1066.  
  1067. scripts['fishki.net'] = function() {
  1068. gardener('.main-post', /543769|Реклама/);
  1069. };
  1070.  
  1071. scripts['hdgo.cc'] = {
  1072. 'now': function(){
  1073. var o = new MutationObserver(function(ms) {
  1074. var m, node;
  1075. for (m of ms) {
  1076. for (node of m.addedNodes) {
  1077. if (node.tagName === 'SCRIPT' && node.getAttribute('onerror') !== null) {
  1078. node.removeAttribute('onerror');
  1079. }
  1080. }
  1081. }
  1082. });
  1083. o.observe(document, {childList:true, subtree: true});
  1084. }
  1085. };
  1086. scripts['couber.be'] = scripts['hdgo.cc'];
  1087. scripts['46.30.43.38'] = scripts['hdgo.cc'];
  1088.  
  1089. scripts['hdrezka.me'] = {
  1090. 'now': function() {
  1091. Object.defineProperty(win, 'fuckAdBlock', {
  1092. value: {
  1093. onDetected: function() {
  1094. console.log('Pretending to be an ABP detector.');
  1095. }
  1096. }
  1097. });
  1098. Object.defineProperty(win, 'ab', {
  1099. value: false,
  1100. enumerable: true
  1101. });
  1102. },
  1103. 'DOMContentLoaded': function() {
  1104. gardener('div[id][onclick][onmouseup][onmousedown]', /onmouseout/i);
  1105. }
  1106. };
  1107.  
  1108. scripts['naruto-base.su'] = function() {
  1109. gardener('div[id^="entryID"],.block', /href="http.*?target="_blank"/i);
  1110. };
  1111.  
  1112. scripts['forums.overclockers.ru'] = {
  1113. 'now': function() {
  1114. createStyle(['.needblock {position: fixed; left: -10000px}']);
  1115. Object.defineProperty(win, 'adblck', {
  1116. value: 'no',
  1117. enumerable: true
  1118. });
  1119. // Following code inspired by:
  1120. // https://greasyfork.org/en/scripts/23922-anti-adblock-killer-for-overclockers-ru
  1121. function antiAntiABP() {
  1122. var o = new MutationObserver(function(ms) {
  1123. var triggered = false, m, node;
  1124. for (m of ms) {
  1125. for (node of m.addedNodes) {
  1126. if (node.nodeType === Node.ELEMENT_NODE &&
  1127. typeof node.onerror === 'function' &&
  1128. (node.tagName === 'SCRIPT' || node.tagName === 'IMG')) {
  1129. node.onerror = null;
  1130. triggered = true;
  1131. }
  1132. }
  1133. }
  1134. if (triggered) {
  1135. console.log('Disabled script.onerror ABP detection.');
  1136. }
  1137. });
  1138. o.observe(document, {childList: true, subtree: true});
  1139. var s = document.currentScript;
  1140. s.parentNode.removeChild(s);
  1141. }
  1142. var s = document.createElement('script');
  1143. s.textContent = '(' + antiAntiABP.toString() + ')();';
  1144. document.documentElement.appendChild(s);
  1145. }
  1146. };
  1147.  
  1148. scripts['pb.wtf'] = function() {
  1149. createStyle(['.reques,#result,tbody.row1:not([id]) {display: none !important}']);
  1150. // image in the slider in the header
  1151. gardener('a[href$="=="]', /img/i, {root:'.release-navbar', observe:true, parent:'div'});
  1152. // ads in blocks on the page
  1153. gardener('a[href^="/"]', /<img\s.*<br>/i, {root:'#main_content', observe:true, parent:'div[class]'});
  1154. // line above topic content
  1155. gardener('.re_top1', /./, {root:'#main_content', parent:'.hidden-sm'});
  1156. };
  1157. scripts['piratbit.org'] = scripts['pb.wtf'];
  1158. scripts['piratbit.ru'] = scripts['pb.wtf'];
  1159.  
  1160. scripts['pikabu.ru'] = function() {
  1161. gardener('.story', /story__sponsor|story__gag|profile\/ads"/i, {root: '.inner_wrap', observe: true});
  1162. };
  1163.  
  1164. scripts['rp5.ru'] = function() {
  1165. var co = document.querySelector('#content'), i, nodes;
  1166. if (!co) {
  1167. return;
  1168. }
  1169. nodes = co.parentNode.childNodes;
  1170. i = nodes.length;
  1171. while (i--) {
  1172. if (nodes[i] !== co) {
  1173. nodes[i].parentNode.removeChild(nodes[i]);
  1174. }
  1175. }
  1176. };
  1177.  
  1178. scripts['rustorka.com'] = function() {
  1179. var s = document.head.childNodes, node;
  1180. if (s.length < 5) {
  1181. for (node of s) {
  1182. if (node.httpEquiv === 'refresh') {
  1183. window.close();
  1184. }
  1185. }
  1186. }
  1187. gardener('span[class],ul[class],span[id],ul[id]', /\/\d{12,}\.php/i, {root:'#sidebar1', observe:true});
  1188. gardener('div[id][style*="!important"]', /!important/i);
  1189. };
  1190. scripts['rumedia.ws'] = scripts['rustorka.com'];
  1191.  
  1192. scripts['sport-express.ru'] = function() {
  1193. gardener('.js-relap__item',/>Реклама\s+<\//, {root:'.container', observe: true});
  1194. };
  1195.  
  1196. scripts['sports.ru'] = function() {
  1197. gardener('.aside-news-list__item', /aside-news-list__advert/i, {root:'.aside-news-block'});
  1198. };
  1199.  
  1200. scripts['turbobit.net'] = {'now': preventBackgroundRedirect};
  1201.  
  1202. scripts['yap.ru'] = function() {
  1203. var words = /member1438|Administration/;
  1204. gardener('form > table[id^="p_row_"]', words);
  1205. gardener('tr > .holder.newsbottom', words, {parent:'tr', siblings:-2});
  1206. };
  1207. scripts['yaplakal.com'] = scripts['yap.ru'];
  1208.  
  1209. scripts['reactor.cc'] = {
  1210. 'now': function() {
  1211. win.open = (function(){ throw new Error('Redirect prevention.'); }).bind(window);
  1212. },
  1213. 'click': function(e) {
  1214. var node = e.target;
  1215. if (node.nodeType === Node.ELEMENT_NODE &&
  1216. node.style.position === 'absolute' &&
  1217. node.style.zIndex > 0)
  1218. node.parentNode.removeChild(node);
  1219. },
  1220. 'DOMContentLoaded': function() {
  1221. var words = new RegExp(
  1222. 'блокировщика рекламы'
  1223. .split('')
  1224. .map(function(e){return e+'[\u200b\u200c\u200d]*';})
  1225. .join('')
  1226. .replace(' ', '\\s*')
  1227. .replace(/[аоре]/g, function(e){return ['[аa]','[оo]','[рp]','[еe]']['аоре'.indexOf(e)];}),
  1228. 'i'),
  1229. can;
  1230. function deeper(spider) {
  1231. var c, l, n;
  1232. if (words.test(spider.innerText)) {
  1233. if (spider.nodeType === Node.TEXT_NODE) {
  1234. return true;
  1235. }
  1236. c = spider.childNodes;
  1237. l = c.length;
  1238. n = 0;
  1239. while(l--) {
  1240. if (deeper(c[l]), can) {
  1241. n++;
  1242. }
  1243. }
  1244. if (n > 0 && n === c.length && spider.offsetHeight < 750) {
  1245. can.push(spider);
  1246. }
  1247. return false;
  1248. }
  1249. return true;
  1250. }
  1251. function probe(){
  1252. if (words.test(document.body.innerText)) {
  1253. can = [];
  1254. deeper(document.body);
  1255. var i = can.length, j, spider;
  1256. while(i--) {
  1257. spider = can[i];
  1258. if (spider.offsetHeight > 10 && spider.offsetHeight < 750) {
  1259. spider.setAttribute('style', 'background:none!important');
  1260. }
  1261. }
  1262. }
  1263. }
  1264. var o = new MutationObserver(probe);
  1265. o.observe(document,{childList:true, subtree:true});
  1266. }
  1267. };
  1268. scripts['joyreactor.cc'] = scripts['reactor.cc'];
  1269. scripts['pornreactor.cc'] = scripts['reactor.cc'];
  1270.  
  1271. scripts['auto.ru'] = function() {
  1272. var words = /Реклама|Яндекс.Директ|yandex_ad_/;
  1273. var userAdsListAds = [
  1274. '.listing-list > .listing-item',
  1275. '.listing-item_type_fixed.listing-item'
  1276. ];
  1277. var catalogAds = [
  1278. 'div[class*="layout_catalog-inline"]',
  1279. 'div[class$="layout_horizontal"]'
  1280. ];
  1281. var otherAds = [
  1282. '.advt_auto',
  1283. '.sidebar-block',
  1284. '.pager-listing + div[class]',
  1285. '.card > div[class][style]',
  1286. '.sidebar > div[class]',
  1287. '.main-page__section + div[class]',
  1288. '.listing > tbody'];
  1289. gardener(userAdsListAds.join(','), words, {root:'.listing-wrap', observe:true});
  1290. gardener(catalogAds.join(','), words, {root:'.catalog__page,.content__wrapper', observe:true});
  1291. gardener(otherAds.join(','), words);
  1292. };
  1293.  
  1294. scripts['online.anidub.com'] = function() {
  1295. var script = document.createElement('script');
  1296. script.type = "text/javascript";
  1297. script.innerHTML = "function ogonekstart1() {}";
  1298. document.getElementsByTagName('head')[0].appendChild(script);
  1299.  
  1300. var style = document.createElement('style');
  1301. style.type = 'text/css';
  1302. style.appendChild(document.createTextNode('.background {background: none!important;}'));
  1303. style.appendChild(document.createTextNode('.background > script + div, .background > script ~ div:not([id]):not([class]) + div[id][class] {display:none!important}'));
  1304. document.head.appendChild(style);
  1305. };
  1306.  
  1307. scripts['rsload.net'] = {
  1308. 'load': function() {
  1309. var dis = document.querySelector('.cb-disable');
  1310. if (dis) {
  1311. dis.click();
  1312. }
  1313. },
  1314. 'click': function(e) {
  1315. var t = e.target;
  1316. if (t && t.href && (/:\/\/\d+\.\d+\.\d+\.\d+\//.test(t.href))) {
  1317. t.href = t.href.replace('://','://rsload.net:rsload.net@');
  1318. }
  1319. }
  1320. };
  1321.  
  1322. scripts['imageban.ru'] = {
  1323. 'now': preventBackgroundRedirect,
  1324. 'DOMContentLoaded': function() {
  1325. win.addEventListener('unload', function() {
  1326. if (!window.location.hash) {
  1327. window.location.replace(window.location+'#');
  1328. } else {
  1329. window.location.hash = '';
  1330. }
  1331. }, true);
  1332. }
  1333. };
  1334.  
  1335. var domain = document.domain, name;
  1336. while (domain.indexOf('.') !== -1) {
  1337. if (scripts.hasOwnProperty(domain)) {
  1338. if (typeof scripts[domain] === 'function') {
  1339. document.addEventListener ('DOMContentLoaded', scripts[domain], false);
  1340. }
  1341. for (name in scripts[domain]) {
  1342. if (name !== 'now') {
  1343. (name === 'load' ? window : document)
  1344. .addEventListener (name, scripts[domain][name], false);
  1345. } else {
  1346. scripts[domain][name]();
  1347. }
  1348. }
  1349. }
  1350. domain = domain.slice(domain.indexOf('.') + 1);
  1351. }
  1352. })();