User:TheAstorPastor/snowflake.js

From Test Wiki
Revision as of 10:11, 30 June 2024 by TheAstorPastor (talk | contribs) (Created page with "// Loading the CSS for snowflakes importStylesheet("User:TheAstorPastor/snowflake.css"); console.log("%c[Snowflake]%c The `snowflake` user script has been loaded successfully. Enjoy the snowflakes!", "color: aqua", ""); function createSnowflake() { const snowflake = document.createElement('div'); snowflake.classList.add('snowflake'); snowflake.textContent = '❄'; snowflake.style.left = Math.random() * 100 + 'vw'; snowflake.style.opacity = Math.random(); snowfla...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Note: After publishing, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Press Ctrl-F5.
// Loading the CSS for snowflakes
importStylesheet("User:TheAstorPastor/snowflake.css");
console.log("%c[Snowflake]%c The `snowflake` user script has been loaded successfully. Enjoy the snowflakes!", "color: aqua", "");

function createSnowflake() {
	const snowflake = document.createElement('div');
	snowflake.classList.add('snowflake');
	snowflake.textContent = '❄';
	
	snowflake.style.left = Math.random() * 100 + 'vw';
	snowflake.style.opacity = Math.random();
	snowflake.style.fontSize = Math.random() * 20 + 10 + 'px';
	snowflake.style.animationDuration = Math.random() * 3 + 2 + 's';
	
	document.body.appendChild(snowflake);
	
	// Remove snowflake after it falls
	setTimeout(() => {
		snowflake.remove();
	}, 10000);
}

setInterval(createSnowflake, 100);