NERD Inserter

just enable it and see what happens

Versione datata 31/01/2024. Vedi la nuova versione l'ultima versione.

Dovrai installare un'estensione come Tampermonkey, Greasemonkey o Violentmonkey per installare questo script.

You will need to install an extension such as Tampermonkey to install this script.

Dovrai installare un'estensione come Tampermonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Userscripts per installare questo script.

Dovrai installare un'estensione come ad esempio Tampermonkey per installare questo script.

Dovrai installare un gestore di script utente per installare questo script.

(Ho già un gestore di script utente, lasciamelo installare!)

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

(Ho già un gestore di stile utente, lasciamelo installare!)

// ==UserScript==
// @name         NERD Inserter
// @namespace    nerd-inserter
// @homepageURL  https://c2g.at
// @description  just enable it and see what happens
// @author       c2g_at
// @match        *://*.wikipedia.org/*
// @match        *://*.google.com/search*
// @version 0.0.1.20240131233411
// ==/UserScript==
(function() {
    'use strict';

    var mouseX = 0;
    var mouseY = 0;
    document.addEventListener('mousemove', function(e) {
        mouseX = e.clientX;
        mouseY = e.clientY;
    });

    function applyMouseForce(img) {
        var imgRect = img.getBoundingClientRect();
        var imgX = imgRect.left + imgRect.width / 2;
        var imgY = imgRect.top + imgRect.height / 2;
        var distX = mouseX - imgX;
        var distY = mouseY - imgY;
        var distance = Math.sqrt(distX * distX + distY * distY);
        var maxDistance = 100; // Max distance for interaction

        if (distance < maxDistance) {
            var forceX = (maxDistance - distance) * (distX / distance);
            var forceY = (maxDistance - distance) * (distY / distance);

            img.style.left = img.offsetLeft - forceX + 'px';
            img.style.bottom = parseInt(img.style.bottom, 10) - forceY + 'px';
        }
    }

    function createFloatingImage(src) {
        var img = document.createElement('img');
        img.src = src;

        var size = Math.random() * (120 - 50) + 50; // Size between 50px and 120px
        img.style.width = size + 'px';
        img.style.height = 'auto';

        img.style.position = 'fixed';
        img.style.bottom = '-150px'; 
        img.style.left = Math.random() * window.innerWidth + 'px'; 
        img.style.zIndex = 9999; 
        img.style.pointerEvents = 'none'; 
        var bottomPosition = -150;
        var leftPosition = parseInt(img.style.left, 10);
        var sway = 50; 
        var swayDirection = 1;

        var interval = setInterval(function() {
            bottomPosition += 2; 
            img.style.bottom = bottomPosition + 'px';

            if (leftPosition > window.innerWidth - size || leftPosition < 0) {
                swayDirection *= -1; 
            }
            leftPosition += 0.5 * swayDirection; 
            img.style.left = leftPosition + 'px';

            if (bottomPosition > window.innerHeight + 150) {
                clearInterval(interval);
                img.remove();
            }
            applyMouseForce(img);

        }, 50); 

        document.body.appendChild(img);
    }

    var imageUrl = 'https://i.imgur.com/jXsXO6T.png';

    // Create 25 floating images at random intervals
    for (var i = 0; i < 50; i++) {
        // Random delay between 0 to 10 seconds
        var delay = Math.random() * 10000;
        setTimeout(function() {
            createFloatingImage(imageUrl);
        }, delay);
    }
})();