Greasy Fork is available in English.

Genshin

Genshin minigame

// ==UserScript==
// @name		Genshin
// @namespace	https://genshin.gg/
// @version		0.2
// @description	Genshin minigame
// @author		V. H.
// @icon		https://rerollcdn.com/GENSHIN/Characters/Lisa.png
// @match		*://*/*
// @run-at		document-idle
// @grant		GM_addStyle
// @grant		unsafeWindow
// ==/UserScript==

"use strict";

void (async function troll(spawnDelay = 2500, baseSpawnDelay = 150) {
	
	if (document.readyState !== "complete") { setTimeout(troll, 1000); return; }
	
	GM_addStyle(`
		@keyframes spinn {
			from {
				transform: rotate(0deg);
			}
			
			50% {
				transform: rotate(180deg);
			}
			
			to {
				transform: rotate(360deg);
			}
		}
	`);
	
	GM_addStyle(`
		img {
			animation-name: spinn;
			animation-duration: 4s;
			animation-iteration-count: infinite;
			animation-fill-mode: forwards;
			animation-timing-function: linear;
		}
	`);
	
	GM_addStyle(`
		img.trolly {
			position: fixed;
			max-width: 8vw;
			max-height: 8vw;
			min-width: 3vw;
			min-height: 3vw;
			display: inline-block;
			object-fit: cover;
			object-position: 50% 50%;
			image-rendering: crisp-edges;
			box-sizing: border-box;
			border-radius: 30%;
			-webkit-user-drag: none;
			-khtml-user-drag: none;
			-moz-user-drag: none;
			-o-user-drag: none;
			user-drag: none;
			-webkit-user-select: none;
			-khtml-user-select: none;
			-moz-user-select: none;
			-o-user-select: none;
			user-select: none;
			touch-callout: none;
			opacity: .85;
			resize: none;
			margin: 0;
			padding: 0;
			cursor: crosshair;
			animation-play-state: running;
			z-index: 99999;
		}
		
		p.scorr {
			position: fixed;
			display: inline-block;
			box-sizing: border-box;
			-webkit-user-drag: none;
			-khtml-user-drag: none;
			-moz-user-drag: none;
			-o-user-drag: none;
			user-drag: none;
			-webkit-user-select: none;
			-khtml-user-select: none;
			-moz-user-select: none;
			-o-user-select: none;
			user-select: none;
			touch-callout: none;
			opacity: .9;
			z-index: 99999;
			top: 5px;
			left: 5px;
			width: 10vw;
			height: 5vw;
			font-size: 1.3em;
		}
	`);
	
	getPic.charlist = [
		"Amber", "Barbara", "Beidou", "Bennett", "Chongyun", "Diluc", "Diona", "Fischl", "Jean", "Kaeya",
		"Keqing", "Klee", "Lisa", "Mona", "Ningguang", "Noelle", "Qiqi", "Razor", "Sucrose", "Tartaglia", "Venti",
		"Xiangling", "Xiao", "Xingqiu", "Xinyan", "Zhongli"
	];
	trollier.score = 0;
	
	Array.from(document.getElementsByTagName("img")).forEach(i => { i.src = getPic()[0]; });
	
	const score = document.createElement("p");
	
	score.innerText = "Score: 0";
	score.classList.add("scorr");
	
	document.body.appendChild(score);
	
	trollier(spawnDelay, baseSpawnDelay);
	
	async function trollier(spawnDelay = 3000, baseSpawnDelay = 200) {
		const img = document.createElement("img");
		
		img.classList.add("trolly");
		
		img.style.left = Math.floor(unsafeWindow.innerWidth * Math.random()) + "px";
		img.style.top = Math.floor(unsafeWindow.innerHeight * Math.random()) + "px";
		img.width = img.height = Math.ceil(Math.random() * 10) * unsafeWindow.innerWidth / 100;
		
		const pic = getPic();
		
		img.src = pic[0];
		img.alt = pic[1];
		img.crossorigin = "anonymous";
		img.title = "Genshin: " + pic[1];
		img.type = "image/png";
		img.draggable = false;
		img.ondragstart = img.onmousedown = e => { e.preventDefault(); return false; };
		
		img.onclick = () => { img.parentNode.removeChild(img); update(); };
		
		document.body.appendChild(img);
		
		return setTimeout(trollier, Math.floor(Math.random() * spawnDelay) + baseSpawnDelay, spawnDelay, baseSpawnDelay);
	} //trollier
	
	function getPic() {
		const pic = getPic.charlist[Math.floor(Math.random() * getPic.charlist.length)];
		
		return [ `https://rerollcdn.com/GENSHIN/Characters/${pic}.png`, pic ];
	} //getPic
	
	function update() {
		return (score.innerText = "Score: " + ++trollier.score);
	} //refresh
	
 })(2000, 100);