random color menu comand

cambio colore dal pulsante e dal menu

当前为 2022-07-21 提交的版本,查看 最新版本

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

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

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name           random color menu comand
// @namespace      https://greasyfork.org/users/237458
// @version        0.3
// @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(localStorage.getItem("bg")!==null){
  document. body.style.background=localStorage.getItem("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;
    }

Button.addEventListener("click",function(){
       document. body.style.background=`background:${changeColor("color")};color:${changeColor("color")};transition:.6s;`;
        localStorage.setItem("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;`;
        localStorage.setItem("bg",document.body.style.background)
       })
})();
/*
 function myFunctionnasc() {
 if (prova.style.display === 'none') {prova.style.display = 'block';} else { prova.style.display = 'none';}}
GM_registerMenuCommand("mostra pulsante/nascondi",myFunctionnasc);
*/
  function myFunctionnasc() {
 if(prova.style.display = (prova.style.display!='none') ? 'none' : 'block');}

GM_registerMenuCommand("mostra pulsante/nascondi",myFunctionnasc);