Greasy Fork is available in English.

Custom Profile Background

Style the profile section on PixelPlace

// ==UserScript==
// @name         Custom Profile Background
// @namespace    http://tampermonkey.net/
// @version      1
// @description  Style the profile section on PixelPlace
// @author       Ghost
// @match        https://pixelplace.io/*
// @grant        GM_addStyle
// @grant        GM_setValue
// @grant        GM_getValue
// ==/UserScript==

// Retrieve the last set background image URL from local storage
const lastBackgroundImage = GM_getValue('lastBackgroundImage', '');

// Add an event listener to handle Ctrl+M key press
document.addEventListener('keydown', function(event) {
    if (event.ctrlKey && event.key === 'm') {
        // Prompt the user to upload an image
        const input = document.createElement('input');
        input.type = 'file';
        input.accept = 'image/*';
        input.addEventListener('change', function() {
            const file = input.files[0];
            if (file) {
                // Read the image file as data URL
                const reader = new FileReader();
                reader.onload = function() {
                    const imageUrl = reader.result;
                    // Store the image URL in local storage
                    GM_setValue('lastBackgroundImage', imageUrl);
                    // Apply the image as background
                    applyBackgroundImage(imageUrl);
                };
                reader.readAsDataURL(file);
            }
        });
        input.click();
    }
});

// Function to apply the background image
function applyBackgroundImage(imageUrl) {
    GM_addStyle(`
        /* Styling for the profile section */
        .box-x {
            background-image: url('${imageUrl}');
            background-size: cover; /* Adjust as needed */
            background-position: center; /* Adjust as needed */
            background-repeat: no-repeat; /* Prevents the image from repeating */
        }
    `);
}

// Apply the last set background image on page load
if (lastBackgroundImage) {
    applyBackgroundImage(lastBackgroundImage);
}