moneymuseum.by: PDP: add button to copy a title without spaces

This is bad to have spaces in file names

Versione datata 21/08/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        moneymuseum.by: PDP: add button to copy a title without spaces
// @namespace   Violentmonkey Scripts
// @match       https://moneymuseum.by/*
// @version     1.1
// @author      Vitaly Zdanevich
// @description This is bad to have spaces in file names
// @supportURL  https://gitlab.com/vitaly-zdanevich-userscripts/copy-title-without-spaces
// @license     MIT 
// ==/UserScript==


(function() {
	if (document.querySelector('.product-item-detail-slider-image').length === 0) {
		return // This is not a PDP
	}

	const h1 = document.querySelector('h1')

	const span = document.createElement('span')
	span.style='margin:10px; font-style:italic; color:green; cursor:pointer'
	span.onclick=function() {
		this.remove()
		const text = h1.innerText
			.replace(/%/g, 'percent')
			.replace(/\s/g, '_')
			.replaceAll(',', '')
		navigator.clipboard.writeText(text)
	}
	span.innerText = 'copy'

	h1.append(span)
})()