• We've moved. Our community is now at ownd.sh — latest discussions and updates live there.

ownd.sh CHRISTMAS THEME - AMAZING TAMPERMONKEY SCRIPT - MOUSE INTERACTIVE

lguesslmlose

Divine
Divine
Rep
0
0
0
Rep
1307
Vouches
26
0
0
Vouches
26
Posts
2,855
Likes
1,868
Bits
5 YEARS
5 YEARS OF SERVICE
image.png
If you'd like to add it as well, I'm including this great Tampermonkey script below.

When you move your mouse cursor close to the snow, it interacts with the snow and then moves away!

Script:

Code:

Code:
// ==UserScript==

// @name         ownd.sh - Christmas Snow

// @namespace    http://tampermonkey.net/

// @version      3.0

// @description  Made by @Anakin

// @author       Anakin

// @match        https://ownd.sh/*

// @match        https://ownd.sh/*

// @grant        none

// @run-at       document-start

// ==/UserScript==

(function() {

    'use strict';

    const CONFIG = {

        count: 200,

        mouseZone: 120,

        repelForce: 2,

        minSpeed: 0.2,

        maxSpeed: 0.8,

        baseRadius: 2

    };

    const canvas = document.createElement('canvas');

    const ctx = canvas.getContext('2d');

    canvas.style.cssText = 'position:fixed; top:0; left:0; width:100%; height:100%; z-index:999999; pointer-events:none;';

    document.documentElement.appendChild(canvas);

    let width, height;

    let snowflakes = [];

    let mouse = { x: -9999, y: -9999 };

    let frameId;

    const resize = () => {

        width = canvas.width = window.innerWidth;

        height = canvas.height = window.innerHeight;

    };

    window.addEventListener('resize', resize);

    document.addEventListener('mousemove', e => {

        mouse.x = e.clientX;

        mouse.y = e.clientY;

    });

    resize();

    class Snowflake {

        constructor() {

            this.type = Math.floor(Math.random() * 3);

            this.swayOffset = Math.random() * Math.PI * 2;

            this.init(true);

        }

        init(randomY = false) {

            this.x = Math.random() * width;

            this.y = randomY ? Math.random() * height : -20;

            this.vy = Math.random() * (CONFIG.maxSpeed - CONFIG.minSpeed) + CONFIG.minSpeed;

            this.radius = Math.random() * CONFIG.baseRadius + 1;

            this.alpha = Math.random() * 0.4 + 0.4;

            this.dx = 0;

            this.dy = 0;

        }

        update() {

            this.swayOffset += 0.01;

            const sway = Math.sin(this.swayOffset) * (this.vy * 0.3);

            this.x += sway;

            this.y += this.vy;

            const dx = this.x - mouse.x;

            const dy = this.y - mouse.y;

            const distance = Math.sqrt(dx * dx + dy * dy);

            if (distance < CONFIG.mouseZone) {

                const force = (CONFIG.mouseZone - distance) / CONFIG.mouseZone;

                const smootherForce = force * force;

                const dirX = dx / distance;

                const dirY = dy / distance;

                this.dx += dirX * smootherForce * CONFIG.repelForce;

                this.dy += dirY * smootherForce * CONFIG.repelForce;

            }

            this.x += this.dx;

            this.y += this.dy;

            this.dx *= 0.92;

            this.dy *= 0.92;

            if (this.y > height + 20 || this.x > width + 20 || this.x < -20) {

                if (Math.abs(this.dx) < 0.1 && Math.abs(this.dy) < 0.1) {

                    this.init(false);

                }

            }

        }

        draw() {

            ctx.save();

            ctx.translate(this.x, this.y);

            const color = `rgba(255, 255, 255, ${this.alpha})`;

            ctx.fillStyle = color;

            ctx.strokeStyle = color;

            if (this.type === 0) {

                const gradient = ctx.createRadialGradient(0, 0, 0, 0, 0, this.radius * 1.5);

                gradient.addColorStop(0, color);

                gradient.addColorStop(1, 'rgba(255, 255, 255, 0)');

                ctx.fillStyle = gradient;

                ctx.beginPath();

                ctx.arc(0, 0, this.radius * 1.5, 0, Math.PI * 2);

                ctx.fill();

            } else if (this.type === 1) {

                ctx.lineWidth = this.radius / 2;

                ctx.beginPath();

                ctx.moveTo(-this.radius, 0); ctx.lineTo(this.radius, 0);

                ctx.moveTo(0, -this.radius); ctx.lineTo(0, this.radius);

                ctx.stroke();

            } else {

                const r = this.radius * 1.3;

                ctx.beginPath();

                ctx.moveTo(0, -r);

                ctx.lineTo(r, 0);

                ctx.lineTo(0, r);

                ctx.lineTo(-r, 0);

                ctx.closePath();

                ctx.fill();

            }

            ctx.restore();

        }

    }

    const initSnowflakes = () => {

        snowflakes = [];

        for (let i = 0; i < CONFIG.count; i++) {

            snowflakes.push(new Snowflake());

        }

    };

    const animate = () => {

        ctx.clearRect(0, 0, width, height);

        for (let i = 0; i < snowflakes.length; i++) {

            const flake = snowflakes[i];

            flake.update();

            flake.draw();

        }

        frameId = requestAnimationFrame(animate);

    };

    initSnowflakes();

    animate();

})();

Happy Using!

Merrrrrrrrrrrrry Christmas! 
smart.gif
smart.gif
smart.gif


Beware of scammers who impersonate me!

 

Attachments

  • smart.gif
    smart.gif
    33.1 KB · Views: 0
  • smart.gif
    smart.gif
    33.1 KB · Views: 0
  • smart.gif
    smart.gif
    33.1 KB · Views: 0

179,167

126,023

1,405,739

Top