random color menu comand

cambio colore dal pulsante e dal menu

2022-08-29 يوللانغان نەشرى. ئەڭ يېڭى نەشرىنى كۆرۈش.

// ==UserScript==
// @name           random color menu comand
// @namespace      https://greasyfork.dpdns.org/users/237458
// @version        0.5
// @description    cambio colore dal pulsante e dal menu
// @author         figuccio
// @match          *://*/*
// @icon           https://www.google.com/s2/favicons?sz=64&domain=stackoverflow.com
// @grant          GM_addStyle
// @grant          GM_setValue
// @grant          GM_getValue
// @grant          GM_registerMenuCommand
// @require        https://code.jquery.com/jquery-1.11.0.min.js
// @noframes
// @license        MIT
// ==/UserScript==
(function() {
    'use strict';
    var Button = document.createElement('button');
    document.getElementsByTagName('body')[0].appendChild(Button);
    Button.setAttribute ('id', 'prova');
    Button.setAttribute ('title', 'cambio colore');
    Button.style = "position:absolute;top:370px;right:0px;z-index:9999999999999999999999;background-color:green;color:red;padding:3px;border-radius: 5px;border-color:black;";
    Button.innerHTML = "cambia colore random";

     /////////////////////////////////
     if(GM_getValue("bg")!==null){
  document.body.style.background=GM_getValue("bg");
}
    ///////////////////////////////
function changeColor(){
        var color = '#'+Math.floor(Math.random()*16777215).toString(16);
       document.body.style.background = color;
        Button.innerHTML = "&nbsp;cambio colore <br/>&nbsp;"+ color;
                      //colore button dello stesso colore della pagina
        Button.style.backgroundColor = color;
         //colore testo button
        Button.style.color = 'white';
    }

Button.addEventListener("click",function(){
       document.body.style.background=`background:${changeColor("color")};color:${changeColor("color")};transition:.6s;`;
        GM_setValue("bg",document.body.style.background)
       })

//GM_registerMenuCommand("genera color",changeColor);
    ///////////////////////////////////
    GM_registerMenuCommand("genera color",function(){
       document.body.style.background=`background:${changeColor("color")};color:${changeColor("color")};transition:.6s;`;
        GM_setValue("bg",document.body.style.background)
       })
})();

  function myFunctionnasc() {
 if(prova.style.display = (prova.style.display!='none') ? 'none' : 'block');}

GM_registerMenuCommand("mostra pulsante/nascondi",myFunctionnasc);
长期地址
遇到问题?请前往 GitHub 提 Issues,或加Q群1031348184

赞助商

Fishcpy

广告

Rainyun

一年攒够 12 元