uo-tashtagol.kemobl.ru
514 строк · 26.2 Кб
1// Help functions
2
3function waiting_block(selector, callback, cont = document.querySelector('html')) {4let node = document.querySelector(selector);5if (node) {6if (callback) { callback(node) } else { console.log(node) }7return8}9const observer = new MutationObserver((mutationsList, observer) => {10for (const mutation of mutationsList) {11let node = document.querySelector(selector);12if (node) {13if (callback) { callback(node) } else { console.log(node) };14observer.disconnect();15break16}17}18});19observer.observe(cont, { childList: true, subtree: true });20}
21
22async function goHeadRequest(url, timeout = 2000) {23try {24const response = await Promise.race([25fetch(url, {26method: 'HEAD'27}),28new Promise((_, reject) => setTimeout(() => reject(new Error('Timeout')), timeout))29]);30
31if (response.ok) {32return response;33} else {34throw new Error('HTTP error ' + response.status);35}36} catch (error) {37throw new Error('Error: ' + error.message);38}39}
40
41async function getDT() {42let timeServers = [43'/'44]45let err;46for (const url of timeServers) {47try {48// console.log('URL:' +url);49const head_response = await goHeadRequest(url);50const dt = new Date(head_response.headers.get('Date'));51return dt;52} catch (error) {53console.warn(error);54err = error;55}56}57return new Date();58}
59
60function run_events(events, currentDate = new Date()) {61for (let event in events) {62if (event === '-') continue;63const [start, end] = event.split('|');64let [startDay, startMonth] = start.split('-');65let [endDay, endMonth] = end.split('-');66
67startMonth = parseInt(startMonth, 10);68endMonth = parseInt(endMonth, 10);69
70let startYear = currentDate.getFullYear();71let endYear = startYear;72
73if (endMonth < startMonth) {74startYear--; // Увеличиваем текущий год, если конечный месяц меньше начального75}76
77const startDate = new Date(startYear, startMonth - 1, startDay);78const endDate = new Date(endYear, endMonth - 1, endDay);79
80if (currentDate >= startDate && currentDate <= endDate) {81events[event](event, currentDate);82}83}84}
85
86/* Snow script */
87async function snowInit(snowCollect = [], snowCont = 'body', snow_script_path = null, imgSrc = false) {88if (typeof snowCollect === 'string') {89document.querySelectorAll(snowCont).snowfall('clear');90return91}92if (!snow_script_path) { console.error('Snow script path requred!'); return; }93await loader.importJS(snow_script_path);94if (getCookie('SnowScript') == 'OFF') return;95snowCollect.forEach(e => {96e = document.querySelector(e);97e.style.position = 'relative';98e.insertAdjacentHTML('beforeEnd', '<div class="snowLine" style="position:absolute;bottom:0;width:100%;height:20px"></div>');99});100document.querySelector(snowCont).snowfall({101collection: '.snowLine',102flakeIndex: 999,103flakeCount: 10,104minSize: 13,105maxSize: 15,106minSpeed: 1,107maxSpeed: 2,108collectionHeight: 20,109flakeColor: '#ffffff00',110round: false,111image: imgSrc112/*flakeCount: 50, // Количество снежинок113flakeColor: '#e0e0ff', // Цвет снежинок
114flakeIndex: 999, // z-index снежинок
115minSize: 1, // Минимальный размер снежинки
116maxSize: 4, // Максимальный размер снежинки
117minSpeed: 1, // Минимальная скорость снежинки
118maxSpeed: 5, // Максимальная скорость снежинки
119round: true, // Закруглённые снежинки (true/false)
120shadow: true, // С тенью (true/false)
121collection: false, // Накапливаются ли снизу, образуя сугробы (false or selector)
122collectionHeight: 50, // Количество накапливаемого снега
123deviceorientation: true // Подстраиваться ли под устройство
124// Русификация от Apocalypse
125// apo-ucoz.com (c) 2013*/
126});127console.log('Snow script init');128// $('canvas[height=20]').css({ left: function (i, v) { return parseFloat(v) + 10 }, width: function (i, v) { return parseFloat(v) - 20 } });129}
130
131async function cheats(staticURL) {132function Random(min, max) {133if (typeof (min) === 'number') { min = min } else { min = 1 };134if (typeof (max) === 'number') { max = max } else { max = 10 };135return Math.floor(Math.random() * (max - min + 1)) + min;136}137let combo = {}, pA, MusicPl, alerts = { music: [] };138const139l = "ArrowLeft",//стрелка влево140r = "ArrowRight",//стрелка вправо141vn = "ArrowDown",//стрелка вниз142vv = "ArrowUp",//стрелка вверх,143d = "KeyD",//буква d144i = "KeyI",//буква i145t = "KeyT"146const Cheats = {147'Music': [1, l, r, vn, vn, vv, vv],148'Snow Script': [1, l, l, r, r,],149'UpToBoth': [1, vn, vv],150'DII': [1, l, l, d, i, i],151'NY': [1, vv, vv, vv]152//'Test':[1,t,t]153};//Имя чита : Вводится комбинация клавиш в keyCod'ах или определенных выше константах, при последовательном вводе которой произойдет действие. Нулевой элемент массива - счетчик.154document.body.addEventListener("keyup", async function (e) {155for (let k in Cheats) {156let c = k;157k = Cheats[k];158if (k[k[0]] == e.code) {159if (!combo[c]) combo[c] = []160combo[c].push(e.key);161console.log(combo);162if (k[0] == k.length - 1) {163//Далее выполнение действий для введенной комбинации164switch (c) {165case 'NY':166console.log('Cheat ' + c + ' activated!');167let dt = new Date();168let ny = await newYear(169staticURL,170`${dt.getFullYear()}/${dt.getMonth()}/01`,171`${dt.getFullYear()}/${dt.getMonth() + 1}/${dt.getDate()} ${dt.getHours()}:${dt.getMinutes() + 3 < 60 ? dt.getMinutes() + 3 : '03'}`,172dt
173);174if (typeof msg == 'function') {175msg(`Вы активировали секретный код: ${c}`, 999999, "", {176onClose: () => { ny.stop(); }177});178}179break;180case 'DII':181console.log('Cheat ' + c + ' activated!');182let cont = document.querySelector('#root');183cont.insertAdjacentHTML('beforeBegin', `<video id="DIIRes" src="${staticURL}/video/dII.mp4" autoplay loop mute></video>184<style>
185#DIIRes { position: fixed; width:100%; transition: all 1.5s ease-in; }
186body { transition: all 1.4s; }
187body::after {
188content: "";
189position: fixed;
190top:0; left:0; width: 100%; height: 100%;
191background: red;
192opacity: 0;
193z-index: 3;
194transition: inherit;
195}
196#DIIRes.DIIRes-hide {
197transform-origin: top;
198transform: scale(4) translateY(195px)
199}
200body.DIIRes-hide::after {
201opacity: 1;
202}
203</style>`);204let DII = document.querySelector('#DIIRes');205let d2m;206if (playSound) d2m = playSound(`${staticURL}/music/d2ost.mp3`);207cont.style.opacity = '0.2';208if (typeof msg == 'function') {209msg(`Вы активировали секретный код: ${c}`, 10000, "", {210onClose: () => {211document.querySelector('#DIIRes').classList.add('DIIRes-hide');212document.body.classList.add('DIIRes-hide');213setTimeout(() => {214document.querySelector('#DIIRes').remove();215document.querySelector('#root').style.opacity = 1;216document.body.style.transition = "all .3s";217document.querySelector('body').classList.remove('DIIRes-hide');218d2m.pause();219}, 1300);220}221});222}223break;224case 'Music':225alerts.music = alerts.music.filter(alert => alert.isOpen);226alerts.music.forEach(alert => alert.close());227if (!pA) { pA = new Audio(); } else { pA.pause(); }228if (!pA.canPlayType('audio/mp3')) return;229console.log('Cheat ' + c + ' activated!');230if (!MusicPl) {231MusicPl = {2321: ['Бетховен - Ангелы и Демоны', `${staticURL}/music/lvb_angels_and_demons.mp3`, 134],2332: ['Бетховен - Соната для ф-но №14, часть 3', `${staticURL}/music/blv_sonata_14_presto_agitato.mp3`, 432],2343: ['Вивальди Времена года - Лето', `${staticURL}/music/va_vremena_goda_leto.mp3`, 172],2354: ['Вагнер Рихард - Полет валькирий из оперы «Валькирия»', `${staticURL}/music/vr_polet_valkiriy.mp3`, 326],2365: ['Вивальди Антонио - Времена года. Весна', `${staticURL}/music/va_vremena_goda_vesna.mp3`, 204],2376: ['Бетховен - Соната для ф-но №14, часть 1', `${staticURL}/music/blv_sonata_14_adagio_sostenuto`, 335]238}239}240let Rnd = Random(1, 5);241pA.src = MusicPl[Rnd][1];242pA.play();243if (typeof msg == 'function') {244msg(`Вы активировали секретный код: ${c}<br><i>Комбинация:<i><br>${combo[c].toString()}`);245alerts.music.push(msg(`Играет композиция:<br>${MusicPl[Rnd][0]}`, MusicPl[Rnd][2]));246}247break;248
249case 'Test':250console.log('Cheat ' + c + ' activated!');251console.log('И понял Антоха, что поступил плохо!');252if (typeof msg == 'function') msg(`Вы активировали секретный код: ${c}<br>И понял Антоха, что поступил плохо!`);253break;254
255case 'Snow Script':256let SnowScript = getCookie('SnowScript');257let date = new Date(new Date().getTime() + 7776000 * 1000);258if ((!SnowScript) || (SnowScript == 'ON')) { SnowScript = 'OFF'; } else if (SnowScript == 'OFF') { SnowScript = 'ON'; }259document.cookie = "SnowScript=" + SnowScript + "; path=/; SameSite=Strict; expires=" + date.toUTCString();260switch (SnowScript) {261case 'OFF':262try { await snowInit('clear', '.site_header'); } catch (err) { return }263if (typeof msg == 'function') msg(`Вы активировали секретный код: ${c}<br><i>Комбинация:<i><br>${combo[c].toString()}<br>264Скрипт снега выключен.<br>Для включения повторите код.`);265break;266case 'ON':267try { snowInit(['.site_header'], '.site_header', `${staticURL}/js/snowfall.js`) } catch (err) { console.log(err) }268if (typeof msg == 'function') msg(`Вы активировали секретный код: ${c}<br><i>Комбинация:<i><br>${combo[c].toString()}<br>269Скрипт снега включен.<br>Для выключения повторите код.`);270break;271}272break;273case 'UpToBoth':274if (typeof msg == 'function') msg(`Вы активировали секретный код: ${c}<br><i>Комбинация:<i><br>${combo[c].toString()}`);275let cDeg = parseInt(document.body.dataset.rotateX);276cDeg = isNaN(cDeg) || cDeg == 180 ? 0 : 180;277document.body.dataset.rotateX = cDeg;278document.body.animate([{ transform: `rotate3d(1,0,0,${cDeg}deg)` }], { duration: 500, fill: "forwards" });279// console.log(cDeg);280break;281}282k[0] = 1;283combo[c] = [];284break;285}286k[0] = k[0] + 1;287} else {288k[0] = 1;289combo[c] = [];290}291}292}, combo, pA, MusicPl, alerts);293console.log('CheatCodes is loaded');294}
295
296function document_viewer(staticURL) {297function view() {298// console.time('View_doc');299if (this.hasAttribute('download')) return;300
301// document.querySelector('.fCont').click();302
303let layer = document.createElement('div');304layer.className = 'fCont';305layer.innerHTML = `<style>306.fCont {opacity: 0; position: fixed; background: rgba(0,0,0,.5); width: 100%; height: 100%; margin: auto; left: 0; right: 0; top: 0; bottom: 0; z-index: 9999}
307.fCont > div {margin: auto; transition: .3s; height: 100%; width: 80%; position: absolute; top: 0; right: 0; bottom: 0; left: 0; padding: 0 1px 0 0; z-index: 1000; background: #FFF;margin-top: -100vh;}
308.frame-control-panel {position: absolute; background-color: rgba(147,147,147,0.7);}
309.frame-control-panel a {display: inline-block; width: 50px; height: 47px; line-height: 47px; text-align: center; font-size: 17px; font-weight: bold; text-decoration: none; color: rgba(255,255,255,.87); text-shadow: 0 1px 0 rgba(0,0,0,0.8);}
310.frame-control-panel a:hover {background: #838383; color: rgba(255,255,255,.87); cursor: default}
311.frame-control-panel a:nth-of-type(2) > div {background: url(${staticURL}/img/icons/doc_viewer/v-sprite19.svg) no-repeat 0 -2467px; background-origin: content-box; padding: 0px 0px 0 15px; margin-right: -15px;}312</style>
313<div><div class='frame-control-panel'><a onclick="$('.fCont').trigger('click')">X</a><a href='${this.href}' download><div> </div></a></div>314<iframe name='doc' src='' style='width:100%;height:100%;padding:0;margin:0'></iframe></div></div>`;315
316let url = this.href;317url = 'https://docs.google.com/viewerng/viewer?url=' + url + '&embedded=true';318layer.querySelector('iframe').src = url;319
320// document.body.scrollTo(0, 0);321document.body.style.overflow = 'hidden';322document.body.appendChild(layer);323
324layer.querySelector('iframe').addEventListener('hover', function (event) { layer.querySelector('.frame-control-panel').animate([{ opacity: "1" }], { duration: 300, fill: "forwards" }) });325layer.querySelector('iframe').addEventListener('mouseout', function (event) { layer.querySelector('.frame-control-panel').animate([{ opacity: "0" }], { duration: 1000, fill: "forwards" }) });326setTimeout(() => document.querySelector('.frame-control-panel').animate([{ opacity: "0" }], { duration: 800, fill: "forwards" }), 3000);327
328document.querySelector('.fCont iframe').addEventListener('load', () => console.log('frame loaded'));329document.querySelector('.fCont').addEventListener('click', function (event) {330if (event.target.closest('.frame-control-panel') || event.target.closest('iframe')) return331document.querySelector('.fCont div').animate([{ marginTop: "100vh" }], { duration: 300, fill: "forwards" });332setTimeout(() => {333document.documentElement.style.overflow = 'auto';334let layer = document.querySelector('.fCont');335layer.style.display = 'none';336layer.remove()337}, 400);338});339
340layer.animate([{ opacity: "1" }], { duration: 500, fill: "forwards" });341layer.querySelector('div').animate([{ marginTop: "15px" }], { delay: 500, duration: 500, fill: "forwards" });342
343// console.timeEnd('View_doc');344return false;345}346
347function isDocFileType(el) {348const fileTypes = ['pdf', 'doc', 'docx', 'docx', 'xls', 'xlsx', 'ppt', 'pptx', 'rtf'];349if (el.href && fileTypes.includes(el.href.toLowerCase().split('.').pop())) return true;350return false;351}352
353document.body.classList.add('doc-viewer');354document.body.addEventListener('click', function (event) {355event.preventDefault();356let target = event.target.closest('a');357if (target && target.tagName === 'A' && isDocFileType(target)) {358view.call(target);359}360});361}
362
363function salute(parent = "body", id = null, size = ['500px', '200px'], pos = [0, 0, 'auto', 'auto'], staticURL = '/') {364document.querySelector(parent).insertAdjacentHTML('afterBegin', `365<div id='${id}' class='event_salute' style='width:${size[0]};height:${size[1]};padding:0;margin:0;position:absolute;z-index:9999;left:;${pos[0]};top:${pos[1]};right:${pos[2]};bottom:${pos[3]};'>366<img src='${staticURL}/img/saljut_prozrachnyj.gif' height='100%' width='100%'/>367</div>`);368return document.querySelector(`#${id}`);369}
370
371async function newYear(staticURL = '/',372startDate = `${(new Date()).getFullYear()}/11/01`,373endDate = `${((new Date()).getFullYear() + 1)}/01/01`,374currDate = new Date()) {375let NewYearTimer = new DTimer({376start: startDate,377finish: endDate,378relate: `${currDate.getFullYear()}/${currDate.getMonth() + 1}/${currDate.getDate()} ${currDate.getHours()}:${currDate.getMinutes()}:${currDate.getSeconds()}`//"2015/12/31 23:58:55"379});380let audio = null;381let nye = {}382let salutes = []383
384nye.stop = function () {385NewYearTimer.stop();386if (audio) audio.stop();387if (document.querySelector('.site_header__promo #timer-cont')) document.querySelector('.site_header__promo #timer-cont').remove();388salutes.forEach(el => el.remove());389}390
391NewYearTimer.start(async function (date) {392//update function393let Y, M, d, h, m, s, postfix_d;394//Y = this.fixTime(date.getYear());395//M = this.fixTime(date.getMonth());396d = this.fixTime(date.getDate());397h = this.fixTime(date.getHours());398m = this.fixTime(date.getMinutes());399s = this.fixTime(date.getSeconds());400d = d < 10 ? d.substr(1) : d;401postfix_d = ['2', '3', '4'].includes(('' + d).slice(-1)) ? " дня " : d !== 11 && ('' + d).slice(-1) == 1 ? " день " : " дней ";402document.querySelector('#timer-date').innerHTML = (d > 0 ? d + postfix_d : "") + h + ":" + m + ":" + s;403if (date.getDate() == 0 && date.getHours() == 0 && date.getMinutes() < 1) {404try {405if (PlaySoundWebApi && !getCookie('ny_kuranty')) {406audio = await PlaySoundWebApi(`${staticURL}/music/kuranty.mp3`, 60 - date.getSeconds());407audio.play();408}409} catch (e) { };410document.cookie = "ny_kuranty=play; path=/; SameSite=Strict; expires=" + date;411}412}, async function () {413//end time function414document.querySelector('#timer-date').animate({ 'opacity': '0' }, { duration: 3000, fill: "forwards" });415msg(`<span style='text-align:center;font-size:25pt;font-family:Nautilus Pompilius'>Счастливого нового ${currDate.getFullYear() + 1} года</span>`, 999999, '', {416onClose: () => { nye.stop() },417});418salutes.push(salute('body', 'sal1', ['45vw', 300], [0, 0, 'auto', 'auto'], staticURL));419salutes.push(salute('body', 'sal2', ['45vw', 300], ['auto', 0, 0, 'auto'], staticURL));420try {421if (PlaySoundWebApi) {422audio = await PlaySoundWebApi(`${staticURL}/music/gimn_rf.mp3`);423audio.play();424}425} catch (e) { };426});427
428if (NewYearTimer.start !== 0) {429if (document.querySelector('.site_header__promo #timer-cont')) document.querySelector('.site_header__promo #timer-cont').remove();430document.querySelector('.site_header__promo').insertAdjacentHTML('afterBegin', `431<style>
432.site_header__promo { display:flex;place-content:baseline;place-items:end; }
433#timer-cont { cursor:pointer;user-select:none;display:inline-block;position:relative;clear:right;color:#bb0000;font-size:1.1vw;font-weight:bold;font-family:LED;height:70px;marargin-top:-55px; }
434#timer-title { display:inline-block;position:relative;min-width:64px;bottom:-13%;left:-10px }
435#timer-date { font-size:calc(15px + .5vw);font-weight:normal;color:${localStorage.TimerColor || "rgb(127 2 137)"};transition:all 1s;background:#fff;padding:5px;margin-left:-30px; }436</style>
437<div id='timer-cont' title='Нажмите для изменения цвета таймера'>
438<span id='timer-title'><img src='${staticURL}/img/new_year_tree.png'></span>439<span id='timer-date'></span>
440</div>
441`);442document.querySelector('#timer-cont').addEventListener('click', function () {443localStorage.TimerColor = 'rgb(' + Random(0, 255) + ',' + Random(0, 255) + ',' + Random(0, 255) + ')';444document.querySelector('#timer-date').style.color = localStorage.TimerColor;445});446}447
448return nye;449}
450
451function app_icon(exts, cl, style) {452const iconsPath = 'https://ss.uooio.keenetic.pro:50005/static/uo-tashtagol.kemobl.ru/img/icons'453const icons_ext = {454'pdf': `${iconsPath}/pdf-icon.png`,455'doc': `${iconsPath}/doc-icon.png`,456'docx': `${iconsPath}/docx-icon.png`,457'xls': `${iconsPath}/xls-icon.png`,458'xlsx': `${iconsPath}/xlsx-icon.png`,459'ppt': `${iconsPath}/ppt-icon.png`,460'pptx': `${iconsPath}/ppt-icon.png`,461'zip': `${iconsPath}/zip-icon.png`,462'rar': `${iconsPath}/rar-icon.png`,463'rtf': `${iconsPath}/rtf-icon.png`464}465, links = document.querySelectorAll('a[href]');466if (typeof exts === 'string') {467exts = [exts]468} else if (!Array.isArray(exts)) {469console.warn('Нужно передать массив или строку!');470return471}472if (links) {473for (let i = 0; i < links.length; i++) {474for (let q = 0; q < exts.length; q++) {475if (check_link(links[i], exts[q])) {476if (icons_ext.hasOwnProperty(exts[q])) {477add_icon(links[i], get_icon_path(exts[q]), style, cl);478} else {479console.warn('Не найдена иконка для: ' + exts[q])480}481}482}483}484}485function add_icon(lnk, icon, style, cl = 'doc-icon') {486if (lnk && icon && !lnk.getElementsByClassName(cl).length) {487style = style !== '' && style !== undefined ? style : 'height:22px;width:22px;position:relative;top:4px;right:3px;vertical-align:middle';488icon = '<img class="' + cl + '" src="' + icon + '" style="' + style + '">';489
490lnk.insertAdjacentHTML('afterBegin', icon);491}492}493function check_link(lnk, ext) {494if (lnk.classList.contains('doc-icon-off')) return false;495return (lnk.href.toLowerCase().lastIndexOf('.' + ext.toLowerCase()) >= 0)496}497function get_icon_path(ext) {498for (let i_ext in icons_ext) {499if (i_ext == ext)500return icons_ext[i_ext];501}502}503}
504
505async function get_pdf_sign_info() {506let api_ver = 1.1,507baseURL = "https://pdfgsiapi.uooio.keenetic.pro:50001",508moduleURL = `${baseURL}/api/${api_ver}/PDF/sign-info/sign-info.js?ver=1.4`,509{ PDFGSI } = await import(moduleURL);510PDFGSI("constructor-documents-list-item__icon");511}
512
513console.log('functions module loaded');514export { waiting_block, goHeadRequest, getDT, run_events, snowInit, salute, cheats, document_viewer, app_icon, newYear, get_pdf_sign_info }