Custom Profile Backgrounds

KoGaMa Custom Profile Background Support.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey, το Greasemonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

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

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Userscripts για να εγκαταστήσετε αυτόν τον κώδικα.

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

Θα χρειαστεί να εγκαταστήσετε μια επέκταση διαχείρισης κώδικα χρήστη για να εγκαταστήσετε αυτόν τον κώδικα.

(Έχω ήδη έναν διαχειριστή κώδικα χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Έχω ήδη έναν διαχειριστή στυλ χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

// ==UserScript==
// @name         Custom Profile Backgrounds
// @version      0.3
// @author       Devork
// @description  KoGaMa Custom Profile Background Support.
// @namespace    https://github.com/Devorkk/
// @match        https://www.kogama.com/profile/*
// @match        https://kogama.com.br/profile/*
// @match        https://friends.kogama.com/profile/*
// @run-at       document-start
// @grant        none
// ==/UserScript==

const InsertBeforeLoad = async () => {
	const DESCRIPTION_TEXT = document.querySelector('#description-extend > div > div.text').innerHTML;
	const BACKGROUND_AVATAR = document.querySelector('.background-avatar')
	const BACKGROUND_SECTION = document.querySelector('.section-top-background')
	const BACKGROUND_REGEXP = /background:\s*(\d+)(?:,\s*filter:\s*(light|dark|blur|none))?;/i
	const BACKGROUND_DETAILS = BACKGROUND_REGEXP.exec(DESCRIPTION_TEXT)

	if (typeof BACKGROUND_DETAILS == 'object') {
		const FETCH = (await (await fetch(`/game/published/?q=${BACKGROUND_DETAILS[1]}`)).json())
		const IMAGE = FETCH.images.large.replace('cache', 'images').replace('_600x240.jpg', '.png')

		BACKGROUND_AVATAR.style.backgroundImage = `url(${IMAGE})`;

		switch (BACKGROUND_DETAILS[2]) {
			case 'blur':
				BACKGROUND_AVATAR.style.opacity = 'unset';
				BACKGROUND_SECTION.style.backgroundImage = 'none';
				break;
			case 'none':
				BACKGROUND_AVATAR.style.opacity = 'unset';
				BACKGROUND_AVATAR.style.filter = 'none';
				BACKGROUND_SECTION.style.backgroundImage = 'none';
				break;
			case 'dark':
				BACKGROUND_SECTION.style.backgroundImage = 'none';
				break;
		}
	}
};

document.addEventListener('DOMContentLoaded', InsertBeforeLoad);