colori random con pulsante

pulsante per cambio colori

Versione datata 15/07/2022. Vedi la nuova versione l'ultima versione.

// ==UserScript==
// @name           colori random con pulsante
// @author         figuccio
// @namespace      https://greasyfork.org/users/237458
// @description    pulsante per cambio colori
// @version        0.8
// @match          *://*/*
// @grant          GM_registerMenuCommand
// @noframes
// @require        http://code.jquery.com/jquery-latest.js
// @require        https://code.jquery.com/ui/1.12.1/jquery-ui.js
// @grant          GM_addStyle
// @grant          GM_setValue
// @grant          GM_getValue
// @license        MIT
// ==/UserScript==
(function() {
    'use strict';
let $ = window.jQuery;
var j3 = $.noConflict();
const body=document.body
var Button = document.createElement('button');
let btn_style = "position:absolute;text-align:center;border:3px solid green;font-size:19px;top:300px;right:;z-index:9999999999999999999999;background-color:aquamarine;color:red;padding:5px;border-radius:5px;";
let box=document.createElement("div");
                                 //document.body.style.backgroundColor = '# + randomColor';
                               box.innerHTML = "&nbsp;cambio colore <br/>&nbsp";'#+randomColor';

box.style=btn_style;
j3(box).draggable();
body.append(box);
          //////////////////////////test
   if(localStorage.getItem("bg")!==null){
   body.style.background=localStorage.getItem("bg");
}

             //random
function randomThing(type){
    if(type=="color"){
        return '#'+Math.floor(Math.random()*16777215).toString(16);

    }

}
//cambio colore al click
        box.addEventListener("click",function(){
        body.style=`background:${randomThing("color")};color:${randomThing("color")};transition:.6s;`;
          localStorage.setItem("bg",body.style.background)
        })
    //////////////////////////
    /*
  const setBg = () => {
  const randomColor = Math.floor(Math.random()*16777215).toString(16);
  document.body.style.backgroundColor = "#" + randomColor;
  box.innerHTML = "&nbsp;cambio colore <br/>&nbsp;#"+ randomColor;
}
setBg();
box.addEventListener("click", setBg);
*/
})();