shin-neo-lyrical-tokarev/public/pages/neocities-lyricaltokarev/deus/6.js

108 lines
2.5 KiB
JavaScript
Raw Permalink Normal View History

2024-11-16 02:11:07 -05:00
let bgs = [
"369ac084d3ace24c4d606058cf82885a.jpg",
"al.jpg",
"alkuro.jpg",
"aya.jpg",
"ayana.jpg",
"ayana2.jpg",
"bbb.jpeg",
"dmd.jpg",
"dmd2.jpeg",
"dmtscan.jpg",
"dmtsk.jpg",
"hkaguya.jpg",
"kohakusanisgaming.jpg",
"meiya.jpg",
"milfillie.jpg",
"pcbmenu.jpg",
"pmiss.jpg",
"pu.jpg",
"reimilia.jpg",
"reimu.jpg",
"reisen.jpg",
"ritual.jpg",
"saya.jpg",
"saya2.jpg",
"screenshot-131.png",
"shiondb.jpg",
"suba.jpeg",
"th.jpg",
"tohear2.jpeg",
"xpnanami.jpg",
"yuyuko.jpg",
"z.jpg"
]
const lyrical = document.getElementById('lyrical')
const doorpath = 'door'
async function wrapper(){
changeBgImg(getRandomBg())
await changeBgAndBlink()
}
const changeBgImg = (bg) => {
console.log(bg)
lyrical.style.background = `url(${doorpath}/${bg}) no-repeat center center fixed`
lyrical.style.backgroundColor = `black`
lyrical.style.backgroundSize = '100% 100%'
}
const getRandomBg = () =>{
const randomIndex = Math.floor(Math.random()*bgs.length)
return bgs[randomIndex];
}
const blink = async (bg, i, duration) => {
let blinkDuration = duration || randomInt(111, 999)
if(probability(0.50, i)){
lyrical.style.background = `black`
lyrical.style.backgroundSize = '100% 100%'
}
else if(probability(0.50, i)){
blinkDuration = 433
changeBgImg('../Vpo.gif', '')
}else if(probability(0.50) || i % 3 === 0){
blinkDuration = 407
changeBgImg(getRandomBg())
}
else{
blinkDuration = 213
changeBgImg('door/ayana.jpg')
}
await sleep(changeBgImg, blinkDuration, [bg])
}
function randomInt(min, max) {
return (Math.floor(Math.random() * (max - min + 1) + min))
}
function timeout(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
async function sleep(fn, time, params = []) {
await timeout(time);
return fn(...params);
}
const probability = function(n, i = 1) {
const random = Math.random()
return (!!n && random <= n) && i % 3 !== 0;
};
const changeBgAndBlink = async () => {
let bg = getRandomBg()
changeBgImg(bg)
for(let i = 1; i < randomInt(9, 13); i++){
const blinkWaitTime = randomInt(444, 1555)
await sleep(blink, blinkWaitTime, [bg, i])
}
changeBgImg('../Vpo.gif', '')
await sleep(changeBgAndBlink, randomInt(1007, 2777))
}
wrapper()