RU AdList JS Fixes

try to take over the world!

目前为 2016-10-17 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name RU AdList JS Fixes
  3. // @namespace ruadlist_js_fixes
  4. // @version 20161017.3
  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. // clean a page
  587. window.addEventListener('DOMContentLoaded', function(){
  588. var rem, si, itm;
  589. function width(){ return window.innerWidth||document.documentElement.clientWidth||document.body.clientWidth||0; }
  590. function height(){ return window.innerHeight||document.documentElement.clientHeight||document.body.clientHeight||0; }
  591.  
  592.  
  593. if (isForum) {
  594. si = document.querySelector('#logostrip');
  595. if (si) {
  596. remove(si.parentNode.nextSibling);
  597. }
  598. }
  599.  
  600. if (document.location.href.search('/forum/dl/') !== -1) {
  601. document.body.setAttribute('style', (document.body.getAttribute('style')||'')+
  602. ';background-color:black!important');
  603. for (itm of document.querySelectorAll('body>div')) {
  604. if (!itm.querySelector('.dw-fdwlink')) {
  605. remove(itm);
  606. }
  607. }
  608. }
  609.  
  610. if (isForum) { // Do not continue if it's a forum
  611. return;
  612. }
  613.  
  614. si = document.querySelector('#header');
  615. if (si) {
  616. rem = si.previousSibling;
  617. while (rem) {
  618. si = rem.previousSibling;
  619. remove(rem);
  620. rem = si;
  621. }
  622. }
  623.  
  624. for (itm of document.querySelectorAll('#nav li[class]')) {
  625. if (itm && itm.querySelector('a[href^="/tag/"]')) {
  626. remove(itm);
  627. }
  628. }
  629.  
  630. var oRA = HTMLElement.prototype.removeAttribute,
  631. oRANS = HTMLElement.prototype.removeAttributeNS,
  632. oRN = HTMLElement.prototype.removeAttributeNode,
  633. oRNNS = HTMLElement.prototype.removeAttributeNodeNS,
  634. oSA = HTMLElement.prototype.setAttribute,
  635. oSANS = HTMLElement.prototype.setAttributeNS,
  636. oGA = HTMLElement.prototype.getAttribute,
  637. oGANS = HTMLElement.prototype.getAttributeNS,
  638. protectedElems = new WeakMap();
  639. HTMLElement.prototype.removeAttribute = function removeAttribute() {
  640. if (protectedElems.get(this) !== undefined) {
  641. return undefined;
  642. }
  643. oRA.apply(this, arguments);
  644. };
  645. HTMLElement.prototype.removeAttributeNS = function removeAttributeNS() {
  646. if (protectedElems.get(this) !== undefined) {
  647. return undefined;
  648. }
  649. oRANS.apply(this, arguments);
  650. };
  651. HTMLElement.prototype.removeAttributeNode = function removeAttributeNode() {
  652. console.log(protectedElems.get(this), protectedElems.get(this) !== undefined);
  653. if (protectedElems.get(this) !== undefined) {
  654. return HTMLElement.prototype.getAttributeNode.apply(this, arguments);
  655. }
  656. return oRN.apply(this, arguments);
  657. };
  658. HTMLElement.prototype.removeAttributeNodeNS = function removeAttributeNodeNS() {
  659. console.log(protectedElems.get(this), protectedElems.get(this) !== undefined);
  660. if (protectedElems.get(this) !== undefined) {
  661. return HTMLElement.prototype.getAttributeNode.apply(this, arguments);
  662. }
  663. return oRNNS.apply(this, arguments);
  664. };
  665. HTMLElement.prototype.setAttribute = function setAttribute() {
  666. if (protectedElems.get(this) !== undefined) {
  667. return undefined;
  668. }
  669. oSA.apply(this, arguments);
  670. };
  671. HTMLElement.prototype.setAttributeNS = function setAttributeNS() {
  672. if (protectedElems.get(this) !== undefined) {
  673. return undefined;
  674. }
  675. oSANS.apply(this, arguments);
  676. };
  677. HTMLElement.prototype.getAttribute = function getAttribute() {
  678. if (protectedElems.get(this) !== undefined && /style/i.test(arguments[0])) {
  679. return protectedElems.get(this).oldStyle;
  680. }
  681. oGA.apply(this, arguments);
  682. };
  683. HTMLElement.prototype.getAttributeNS = function getAttributeNS() {
  684. if (protectedElems.get(this) !== undefined && /style/i.test(arguments[0])) {
  685. return protectedElems.get(this).oldStyle;
  686. }
  687. oGANS.apply(this, arguments);
  688. };
  689. var style, result, oldStyle;
  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. oldStyle = oGA.call(itm, 'style');
  719. itm.setAttribute('style', result.join(';'));
  720. protectedElems.set(itm, {oldStyle: oldStyle});
  721. }
  722. }
  723. }
  724.  
  725. for (itm of document.querySelectorAll('ASIDE>DIV')) {
  726. if ( ((itm.querySelector('script, iframe, a[href*="/ad/www/"]') ||
  727. itm.querySelector('img[src$=".gif"]:not([height="0"]), img[height="400"]')) &&
  728. !itm.classList.contains('post') ) || !itm.childNodes.length ) {
  729. remove(itm);
  730. }
  731. }
  732.  
  733. document.body.setAttribute('style', (document.body.getAttribute('style')||'')+';background-color:#E6E7E9!important');
  734.  
  735. // display content of the page
  736. afterClean();
  737. });
  738. })();
  739. return;
  740. }
  741.  
  742. // https://greasyfork.org/en/scripts/21937-moonwalk-hdgo-kodik-fix v0.7+ (adapted & fixed)
  743. document.addEventListener ('DOMContentLoaded', function() {
  744. var tmp, t;1
  745. function log (e) {
  746. console.log('Moonwalk&HDGo&Kodik FIX: ' + e + ' player in ' + win.location.href);
  747. }
  748. if (win.adv_enabled !== undefined && win.condition_detected !== undefined) { // moonwalk
  749. log('Moonwalk');
  750. win.adv_enabled = false;
  751. win.condition_detected = false;
  752. if (win.MXoverrollCallback) {
  753. document.addEventListener('click', function catcher(e){
  754. e.stopPropagation();
  755. win.MXoverrollCallback.call(window);
  756. document.removeEventListener('click', catcher, true);
  757. }, true);
  758. }
  759. } else if (win.banner_second !== undefined && win.$banner_ads !== undefined) { // hdgo
  760. log('HDGo');
  761. tmp = document.querySelector('#swtf');
  762. if (tmp) {
  763. tmp.style.display = 'none';
  764. }
  765. win.banner_second = 0;
  766. win.$banner_ads = false;
  767. if (win.$new_ads !== undefined) {
  768. win.$new_ads = false;
  769. }
  770. if (win.canRunAds !== undefined && win.canRunAds !== true) {
  771. win.canRunAds = true;
  772. }
  773. } else if (win.MXoverrollCallback && win.iframeSearch !== undefined) { // kodik
  774. log('Kodik');
  775. tmp = document.querySelector('.play_button');
  776. if (tmp) {
  777. tmp.onclick = win.MXoverrollCallback.bind(window);
  778. }
  779. win.IsAdBlock = false;
  780. }
  781. }, false);
  782.  
  783. // function to search and remove nodes by content
  784. // selector - standard CSS selector to define set of nodes to check
  785. // words - regular expression to check content of the suspicious nodes
  786. // params - object with multiple extra parameters:
  787. // .hide - set display to none instead of removing from the page
  788. // .parent - parent node to remove if content is found in the child node
  789. // .siblings - number of simling nodes to remove (excluding text nodes)
  790. function scRemove(e) {e.parentNode.removeChild(e);}
  791. function scHide(e) {
  792. var s = e.getAttribute('style')||'',
  793. h = ';display:none!important;';
  794. if (s.indexOf(h) < 0) {
  795. e.setAttribute('style', s+h);
  796. }
  797. }
  798. function scissors (selector, words, scope, params) {
  799. var remFunc = (params.hide ? scHide : scRemove),
  800. iterFunc = (params.siblings > 0 ?
  801. 'nextSibling' :
  802. 'previousSibling'),
  803. toRemove = [],
  804. siblings,
  805. node;
  806. for (node of scope.querySelectorAll(selector)) {
  807. if (words.test(node.innerHTML) || !node.childNodes.length) {
  808. // drill up to the specified parent node if required
  809. if (params.parent) {
  810. while(node !== scope && !(node.matches(params.parent))) {
  811. node = node.parentNode;
  812. }
  813. }
  814. if (node === scope) {
  815. break;
  816. }
  817. toRemove.push(node);
  818. // add multiple nodes if defined more than one sibling
  819. siblings = Math.abs(params.siblings) || 0;
  820. while (siblings) {
  821. node = node[iterFunc];
  822. toRemove.push(node);
  823. if (node.nodeType === Node.ELEMENT_NODE) {
  824. siblings -= 1; //count only element nodes
  825. }
  826. }
  827. }
  828. }
  829. for (node of toRemove) {
  830. remFunc(node);
  831. }
  832. return toRemove.length;
  833. }
  834.  
  835. // function to perform multiple checks if ads inserted with a delay
  836. // by default does 30 checks withing a 3 seconds unless nonstop mode specified
  837. // also does 1 extra check when a page completely loads
  838. // selector and words - passed dow to scissors
  839. // params - object with multiple extra parameters:
  840. // .root - selector to narrow down scope to scan;
  841. // .observe - if true then check will be performed continuously;
  842. // Other parameters passed down to scissors.
  843. function gardener(selector, words, params) {
  844. params = params || {};
  845. var scope = document.body,
  846. nonstop = false;
  847. // narrow down scope to a specific element
  848. if (params.root) {
  849. scope = scope.querySelector(params.root);
  850. if (!scope) {// exit if the root element is not present on the page
  851. return 0;
  852. }
  853. }
  854. // add observe mode if required
  855. if (params.observe) {
  856. if (typeof MutationObserver === 'function') {
  857. var o = new MutationObserver(function(ms){
  858. for (var m of ms) {
  859. if (m.addedNodes.length) {
  860. scissors(selector, words, scope, params);
  861. }
  862. }
  863. });
  864. o.observe(scope, {childList:true, subtree: true});
  865. } else {
  866. nonstop = true;
  867. }
  868. }
  869. // wait for a full page load to do one extra cut
  870. win.addEventListener('load',function(){
  871. scissors(selector, words, scope, params);
  872. });
  873. // do multiple cuts until ads removed
  874. function cut(sci, s, w, sc, p, i) {
  875. if (i > 0) {
  876. i -= 1;
  877. }
  878. if (i && !sci(s, w, sc, p)) {
  879. setTimeout(cut, 100, sci, s, w, sc, p, i);
  880. }
  881. }
  882. cut(scissors, selector, words, scope, params, (nonstop ? -1 : 30));
  883. }
  884.  
  885. function preventBackgroundRedirect() {
  886. // create "cose_me" event to call high-level window.close()
  887. var key = Math.random().toString(36).substr(2);
  888. window.addEventListener('close_me_'+key, function(e) {
  889. window.close();
  890. });
  891.  
  892. // window.open wrapper
  893. function pbrLander() {
  894. var orgOpen = window.open.bind(window);
  895. function closeWindow(){
  896. // site went to a new tab and attempts to unload
  897. // call for high-level close through event
  898. var event = new CustomEvent("close_me_%key%", {});
  899. window.dispatchEvent(event);
  900. }
  901. function open(){
  902. var idx = String.prototype.indexOf;
  903. if (arguments[0] &&
  904. (idx.call(arguments[0], window.location.host) > -1 ||
  905. idx.call(arguments[0], '://') === -1)) {
  906. window.addEventListener('unload', closeWindow, true);
  907. }
  908. orgOpen.apply(window, arguments);
  909. }
  910. window.open = open.bind(window);
  911. var s = document.currentScript;
  912. if (s) {s.parentNode.removeChild(s);}
  913. }
  914.  
  915. // land wrapper on the page
  916. var script = document.createElement('script');
  917. script.appendChild(document.createTextNode('('+pbrLander.toString().replace(/%key%/g,key)+')();'));
  918. document.head.insertBefore(script,document.head.firstChild);
  919. console.log("Background redirect prevention enabled.");
  920. }
  921.  
  922. function forbidServiceWorker() {
  923. if (!("serviceWorker" in navigator)) {
  924. return;
  925. }
  926. var svr = navigator.serviceWorker.ready;
  927. Object.defineProperty(navigator, 'serviceWorker', {
  928. value: {
  929. register: function(){
  930. console.log('Registration of serviceWorker ' + arguments[0] + ' blocked.');
  931. return new Promise(function(){});
  932. },
  933. ready: new Promise(function(){}),
  934. addEventListener:function(){}
  935. }
  936. });
  937. document.addEventListener('DOMContentLoaded', function() {
  938. if (!svr) {
  939. return;
  940. }
  941. svr.then(function(sw) {
  942. console.log('Found existing serviceWorker:', sw);
  943. console.log('Attempting to unregister...');
  944. sw.unregister().then(function() {
  945. console.log('Unregistered! :)');
  946. }).catch(function(err) {
  947. console.log('Unregistration failed. :(', err);
  948. console.log('Try to remove it manually:');
  949. console.log(' 1. Open: chrome://serviceworker-internals/ (Google Chrome and alike) or about:serviceworkers (Mozilla Firefox) in a new tab.');
  950. console.log(' 2. Search there for one with "'+document.domain+'" in the name.');
  951. console.log(' 3. Use buttons in the same block with service you found to stop it and uninstall/unregister.');
  952. });
  953. }).catch(function(err) {
  954. console.log("Lol, it failed on it's own. -_-", err);
  955. });
  956. }, false);
  957. }
  958.  
  959. var scripts = {};
  960. scripts['fs.to'] = function() {
  961. function skipClicker(i) {
  962. if (!i) {
  963. return;
  964. }
  965. var skip = document.querySelector('.b-aplayer-banners__close');
  966. if (skip) {
  967. skip.click();
  968. } else {
  969. setTimeout(skipClicker, 100, i-1);
  970. }
  971. }
  972. setTimeout(skipClicker, 100, 30);
  973.  
  974. createStyle([
  975. '.l-body-branding *,'+
  976. '.b-styled__item-central,'+
  977. '.b-styled__content-right,'+
  978. '.b-styled__section-central,'+
  979. 'div[id^="adsProxy-"]'+
  980. '{display:none!important}',
  981. 'body {background-image:url(data:image/png;base64,'+
  982. 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAACX'+
  983. 'BIWXMAAC4jAAAuIwF4pT92AAAADUlEQVR42mOQUdL5DwACMgFq'+
  984. 'BC3ttwAAAABJRU5ErkJggg==)!important}'
  985. ]);
  986.  
  987. if (/\/(view_iframe|iframeplayer)\//i.test(document.location.pathname)) {
  988. var p = document.querySelector('#player:not([preload="auto"])'),
  989. m = document.querySelector('.main'),
  990. adStepper = function(p) {
  991. if (p.currentTime < p.duration) {
  992. p.currentTime += 1;
  993. }
  994. },
  995. adSkipper = function(f, p) {
  996. f.click();
  997. p.waitAfterSkip = false;
  998. p.longerSkipper = false;
  999. console.log('Пропустили.');
  1000. },
  1001. cl = function(p) {
  1002. var faster = document.querySelector('.b-aplayer__html5-desktop-skip'),
  1003. series = document.querySelector('.b-aplayer__actions-series');
  1004.  
  1005. function clickSelected() {
  1006. var s = document.querySelector('.b-aplayer__popup-series-episodes .selected a');
  1007. if (s) {
  1008. s.click();
  1009. }
  1010. }
  1011.  
  1012. if ((!faster || faster.style.display !== 'block') && series && !p.seriesClicked) {
  1013. series.click();
  1014. p.seriesClicked = true;
  1015. p.longerSkipper = true;
  1016. setTimeout(clickSelected, 1000);
  1017. p.pause();
  1018. }
  1019.  
  1020. function skipListener() {
  1021. if (p.waitAfterSkip) {
  1022. console.log('В процессе пропуска…');
  1023. return;
  1024. }
  1025. p.pause();
  1026. if (!p.classList.contains('m-hidden')) {
  1027. p.classList.add('m-hidden');
  1028. }
  1029. if (faster && p.currentTime &&
  1030. win.getComputedStyle(faster).display === 'block' &&
  1031. !faster.querySelector('.b-aplayer__html5-desktop-skip-timer')) {
  1032. p.waitAfterSkip = true;
  1033. setTimeout(adSkipper, (p.longerSkipper?3:1)*1000, faster, p);
  1034. console.log('Доступен быстрый пропуск…');
  1035. } else {
  1036. setTimeout(adStepper, 1000, p);
  1037. }
  1038. }
  1039.  
  1040. p.addEventListener('timeupdate', skipListener, false);
  1041. },
  1042. o = new MutationObserver(function (ms) {
  1043. var m, node;
  1044. for (m of ms) {
  1045. for (node of m.addedNodes) {
  1046. if (node.id === 'player' &&
  1047. node.nodeName === 'VIDEO' &&
  1048. node.getAttribute('preload') !== 'auto') {
  1049. cl(node);
  1050. }
  1051. }
  1052. }
  1053. });
  1054. if (p.nodeName === 'VIDEO') {
  1055. cl(p);
  1056. } else {
  1057. o.observe(m, {childList: true});
  1058. }
  1059. }
  1060. };
  1061. scripts['brb.to'] = scripts['fs.to'];
  1062. scripts['cxz.to'] = scripts['fs.to'];
  1063.  
  1064. scripts['drive2.ru'] = function() {
  1065. gardener('.c-block:not(.js-recommendations),.o-grid__item', />Реклама<\//i);
  1066. };
  1067.  
  1068. scripts['fishki.net'] = function() {
  1069. gardener('.main-post', /543769|Реклама/);
  1070. };
  1071.  
  1072. scripts['hdgo.cc'] = {
  1073. 'now': function(){
  1074. var o = new MutationObserver(function(ms) {
  1075. var m, node;
  1076. for (m of ms) {
  1077. for (node of m.addedNodes) {
  1078. if (node.tagName === 'SCRIPT' && node.getAttribute('onerror') !== null) {
  1079. node.removeAttribute('onerror');
  1080. }
  1081. }
  1082. }
  1083. });
  1084. o.observe(document, {childList:true, subtree: true});
  1085. }
  1086. };
  1087. scripts['couber.be'] = scripts['hdgo.cc'];
  1088. scripts['46.30.43.38'] = scripts['hdgo.cc'];
  1089.  
  1090. scripts['hdrezka.me'] = {
  1091. 'now': function() {
  1092. Object.defineProperty(win, 'fuckAdBlock', {
  1093. value: {
  1094. onDetected: function() {
  1095. console.log('Pretending to be an ABP detector.');
  1096. }
  1097. }
  1098. });
  1099. Object.defineProperty(win, 'ab', {
  1100. value: false,
  1101. enumerable: true
  1102. });
  1103. },
  1104. 'DOMContentLoaded': function() {
  1105. gardener('div[id][onclick][onmouseup][onmousedown]', /onmouseout/i);
  1106. }
  1107. };
  1108.  
  1109. scripts['naruto-base.su'] = function() {
  1110. gardener('div[id^="entryID"],.block', /href="http.*?target="_blank"/i);
  1111. };
  1112.  
  1113. scripts['forums.overclockers.ru'] = {
  1114. 'now': function() {
  1115. createStyle(['.needblock {position: fixed; left: -10000px}']);
  1116. Object.defineProperty(win, 'adblck', {
  1117. value: 'no',
  1118. enumerable: true
  1119. });
  1120. // Following code inspired by:
  1121. // https://greasyfork.org/en/scripts/23922-anti-adblock-killer-for-overclockers-ru
  1122. function antiAntiABP() {
  1123. var o = new MutationObserver(function(ms) {
  1124. var triggered = false, m, node;
  1125. for (m of ms) {
  1126. for (node of m.addedNodes) {
  1127. if (node.nodeType === Node.ELEMENT_NODE &&
  1128. typeof node.onerror === 'function' &&
  1129. (node.tagName === 'SCRIPT' || node.tagName === 'IMG')) {
  1130. node.onerror = null;
  1131. triggered = true;
  1132. }
  1133. }
  1134. }
  1135. if (triggered) {
  1136. console.log('Disabled script.onerror ABP detection.');
  1137. }
  1138. });
  1139. o.observe(document, {childList: true, subtree: true});
  1140. var s = document.currentScript;
  1141. s.parentNode.removeChild(s);
  1142. }
  1143. var s = document.createElement('script');
  1144. s.textContent = '(' + antiAntiABP.toString() + ')();';
  1145. document.documentElement.appendChild(s);
  1146. }
  1147. };
  1148.  
  1149. scripts['pb.wtf'] = function() {
  1150. createStyle(['.reques,#result,tbody.row1:not([id]) {display: none !important}']);
  1151. // image in the slider in the header
  1152. gardener('a[href$="=="]', /img/i, {root:'.release-navbar', observe:true, parent:'div'});
  1153. // ads in blocks on the page
  1154. gardener('a[href^="/"]', /<img\s.*<br>/i, {root:'#main_content', observe:true, parent:'div[class]'});
  1155. // line above topic content
  1156. gardener('.re_top1', /./, {root:'#main_content', parent:'.hidden-sm'});
  1157. };
  1158. scripts['piratbit.org'] = scripts['pb.wtf'];
  1159. scripts['piratbit.ru'] = scripts['pb.wtf'];
  1160.  
  1161. scripts['pikabu.ru'] = function() {
  1162. gardener('.story', /story__sponsor|story__gag|profile\/ads"/i, {root: '.inner_wrap', observe: true});
  1163. };
  1164.  
  1165. scripts['rp5.ru'] = function() {
  1166. var co = document.querySelector('#content'), i, nodes;
  1167. if (!co) {
  1168. return;
  1169. }
  1170. nodes = co.parentNode.childNodes;
  1171. i = nodes.length;
  1172. while (i--) {
  1173. if (nodes[i] !== co) {
  1174. nodes[i].parentNode.removeChild(nodes[i]);
  1175. }
  1176. }
  1177. };
  1178.  
  1179. scripts['rustorka.com'] = function() {
  1180. var s = document.head.childNodes, node;
  1181. if (s.length < 5) {
  1182. for (node of s) {
  1183. if (node.httpEquiv === 'refresh') {
  1184. window.close();
  1185. }
  1186. }
  1187. }
  1188. gardener('span[class],ul[class],span[id],ul[id]', /\/\d{12,}\.php/i, {root:'#sidebar1', observe:true});
  1189. gardener('div[id][style*="!important"]', /!important/i);
  1190. };
  1191. scripts['rumedia.ws'] = scripts['rustorka.com'];
  1192.  
  1193. scripts['sport-express.ru'] = function() {
  1194. gardener('.js-relap__item',/>Реклама\s+<\//, {root:'.container', observe: true});
  1195. };
  1196.  
  1197. scripts['sports.ru'] = function() {
  1198. gardener('.aside-news-list__item', /aside-news-list__advert/i, {root:'.aside-news-block'});
  1199. };
  1200.  
  1201. scripts['turbobit.net'] = {'now': preventBackgroundRedirect};
  1202.  
  1203. scripts['yap.ru'] = function() {
  1204. var words = /member1438|Administration/;
  1205. gardener('form > table[id^="p_row_"]', words);
  1206. gardener('tr > .holder.newsbottom', words, {parent:'tr', siblings:-2});
  1207. };
  1208. scripts['yaplakal.com'] = scripts['yap.ru'];
  1209.  
  1210. scripts['reactor.cc'] = {
  1211. 'now': function() {
  1212. win.open = (function(){ throw new Error('Redirect prevention.'); }).bind(window);
  1213. },
  1214. 'click': function(e) {
  1215. var node = e.target;
  1216. if (node.nodeType === Node.ELEMENT_NODE &&
  1217. node.style.position === 'absolute' &&
  1218. node.style.zIndex > 0)
  1219. node.parentNode.removeChild(node);
  1220. },
  1221. 'DOMContentLoaded': function() {
  1222. var words = new RegExp(
  1223. 'блокировщика рекламы'
  1224. .split('')
  1225. .map(function(e){return e+'[\u200b\u200c\u200d]*';})
  1226. .join('')
  1227. .replace(' ', '\\s*')
  1228. .replace(/[аоре]/g, function(e){return ['[аa]','[оo]','[рp]','[еe]']['аоре'.indexOf(e)];}),
  1229. 'i'),
  1230. can;
  1231. function deeper(spider) {
  1232. var c, l, n;
  1233. if (words.test(spider.innerText)) {
  1234. if (spider.nodeType === Node.TEXT_NODE) {
  1235. return true;
  1236. }
  1237. c = spider.childNodes;
  1238. l = c.length;
  1239. n = 0;
  1240. while(l--) {
  1241. if (deeper(c[l]), can) {
  1242. n++;
  1243. }
  1244. }
  1245. if (n > 0 && n === c.length && spider.offsetHeight < 750) {
  1246. can.push(spider);
  1247. }
  1248. return false;
  1249. }
  1250. return true;
  1251. }
  1252. function probe(){
  1253. if (words.test(document.body.innerText)) {
  1254. can = [];
  1255. deeper(document.body);
  1256. var i = can.length, j, spider;
  1257. while(i--) {
  1258. spider = can[i];
  1259. if (spider.offsetHeight > 10 && spider.offsetHeight < 750) {
  1260. spider.setAttribute('style', 'background:none!important');
  1261. }
  1262. }
  1263. }
  1264. }
  1265. var o = new MutationObserver(probe);
  1266. o.observe(document,{childList:true, subtree:true});
  1267. }
  1268. };
  1269. scripts['joyreactor.cc'] = scripts['reactor.cc'];
  1270. scripts['pornreactor.cc'] = scripts['reactor.cc'];
  1271.  
  1272. scripts['auto.ru'] = function() {
  1273. var words = /Реклама|Яндекс.Директ|yandex_ad_/;
  1274. var userAdsListAds = [
  1275. '.listing-list > .listing-item',
  1276. '.listing-item_type_fixed.listing-item'
  1277. ];
  1278. var catalogAds = [
  1279. 'div[class*="layout_catalog-inline"]',
  1280. 'div[class$="layout_horizontal"]'
  1281. ];
  1282. var otherAds = [
  1283. '.advt_auto',
  1284. '.sidebar-block',
  1285. '.pager-listing + div[class]',
  1286. '.card > div[class][style]',
  1287. '.sidebar > div[class]',
  1288. '.main-page__section + div[class]',
  1289. '.listing > tbody'];
  1290. gardener(userAdsListAds.join(','), words, {root:'.listing-wrap', observe:true});
  1291. gardener(catalogAds.join(','), words, {root:'.catalog__page,.content__wrapper', observe:true});
  1292. gardener(otherAds.join(','), words);
  1293. };
  1294.  
  1295. scripts['online.anidub.com'] = function() {
  1296. var script = document.createElement('script');
  1297. script.type = "text/javascript";
  1298. script.innerHTML = "function ogonekstart1() {}";
  1299. document.getElementsByTagName('head')[0].appendChild(script);
  1300.  
  1301. var style = document.createElement('style');
  1302. style.type = 'text/css';
  1303. style.appendChild(document.createTextNode('.background {background: none!important;}'));
  1304. style.appendChild(document.createTextNode('.background > script + div, .background > script ~ div:not([id]):not([class]) + div[id][class] {display:none!important}'));
  1305. document.head.appendChild(style);
  1306. };
  1307.  
  1308. scripts['rsload.net'] = {
  1309. 'load': function() {
  1310. var dis = document.querySelector('.cb-disable');
  1311. if (dis) {
  1312. dis.click();
  1313. }
  1314. },
  1315. 'click': function(e) {
  1316. var t = e.target;
  1317. if (t && t.href && (/:\/\/\d+\.\d+\.\d+\.\d+\//.test(t.href))) {
  1318. t.href = t.href.replace('://','://rsload.net:rsload.net@');
  1319. }
  1320. }
  1321. };
  1322.  
  1323. scripts['imageban.ru'] = {
  1324. 'now': preventBackgroundRedirect,
  1325. 'DOMContentLoaded': function() {
  1326. win.addEventListener('unload', function() {
  1327. if (!window.location.hash) {
  1328. window.location.replace(window.location+'#');
  1329. } else {
  1330. window.location.hash = '';
  1331. }
  1332. }, true);
  1333. }
  1334. };
  1335.  
  1336. var domain = document.domain, name;
  1337. while (domain.indexOf('.') !== -1) {
  1338. if (scripts.hasOwnProperty(domain)) {
  1339. if (typeof scripts[domain] === 'function') {
  1340. document.addEventListener ('DOMContentLoaded', scripts[domain], false);
  1341. }
  1342. for (name in scripts[domain]) {
  1343. if (name !== 'now') {
  1344. (name === 'load' ? window : document)
  1345. .addEventListener (name, scripts[domain][name], false);
  1346. } else {
  1347. scripts[domain][name]();
  1348. }
  1349. }
  1350. }
  1351. domain = domain.slice(domain.indexOf('.') + 1);
  1352. }
  1353. })();