Florr.io Random Retexture

Retexture images in florr.io with a random image when button is clicked

当前为 2024-07-11 提交的版本,查看 最新版本

// ==UserScript==
// @name         Florr.io Random Retexture
// @namespace    http://tampermonkey.net/
// @version      0.4
// @description  Retexture images in florr.io with a random image when button is clicked
// @author       Your Name
// @match        *://florr.io/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    // Function to get a random image URL from picsum.photos
    function getRandomImage(width, height) {
        return `https://picsum.photos/${width}/${height}?random=${Math.floor(Math.random() * 1000)}`;
    }

    // Add the retexture button
    const retextureButton = document.createElement('button');
    retextureButton.innerHTML = 'Retexture!';
    retextureButton.style.position = 'fixed';
    retextureButton.style.top = '10px';
    retextureButton.style.right = '10px';
    retextureButton.style.zIndex = '9999';
    retextureButton.style.border = '2px solid black';
    retextureButton.style.backgroundColor = 'white';
    retextureButton.style.color = 'black';
    retextureButton.style.padding = '10px';
    retextureButton.style.cursor = 'pointer';
    document.body.appendChild(retextureButton);

    // Add click event listener to the button
    retextureButton.addEventListener('click', () => {
        // Get all images on the page
        const images = document.querySelectorAll('img');
        
        // Loop through each image and change its texture to a random image
        images.forEach(img => {
            const width = img.width;
            const height = img.height;
            img.src = getRandomImage(width, height);
        });

        // You can also change the background image of certain elements
        const elementsWithBackgroundImage = document.querySelectorAll('[style*="background-image"]');
        elementsWithBackgroundImage.forEach(element => {
            const computedStyle = window.getComputedStyle(element);
            const backgroundImageUrl = computedStyle.backgroundImage;
            const width = element.clientWidth;
            const height = element.clientHeight;
            if (backgroundImageUrl && width && height) {
                element.style.backgroundImage = `url(${getRandomImage(width, height)})`;
            }
        });
    });
})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址