random color menu comand

cambio colore dal pulsante e dal menu

目前为 2022-09-14 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name random color menu comand
  3. // @namespace https://greasyfork.org/users/237458
  4. // @version 0.6
  5. // @description cambio colore dal pulsante e dal menu
  6. // @author figuccio
  7. // @match *://*/*
  8. // @icon https://www.google.com/s2/favicons?sz=64&domain=stackoverflow.com
  9. // @grant GM_addStyle
  10. // @grant GM_setValue
  11. // @grant GM_getValue
  12. // @grant GM_registerMenuCommand
  13. // @require http://code.jquery.com/jquery-latest.js
  14. // @require https://code.jquery.com/ui/1.12.1/jquery-ui.js
  15. // @noframes
  16. // @license MIT
  17. // ==/UserScript==
  18. let $ = window.jQuery;
  19. var j = $.noConflict();
  20. const body=document.body;
  21. let btn_style="position:fixed;top:370px;left:0px;z-index:9999999999999999999999;border:1px solid green;background-color:green;color:red;padding:3px;border-radius: 5px;border-color:black;";
  22. let box=document.createElement("div");
  23. box.innerText="cambia colore random";
  24. box.title="random color";
  25. box.id="prova";
  26. box.style=btn_style;
  27. let box_state="btn";
  28. j(box).draggable();
  29. body.append(box);
  30.  
  31. /////////////////////////////////
  32. if(GM_getValue("bg")!==null){
  33. document.body.style.background=GM_getValue("bg");
  34. }
  35. ///////////////////////////////
  36. function changeColor(){
  37. var color = '#'+Math.floor(Math.random()*16777215).toString(16);
  38. document.body.style.background = color;
  39. box.innerHTML = "&nbsp;cambio colore <br/>&nbsp;"+ color;
  40. //colore button dello stesso colore della pagina
  41. box.style.backgroundColor = color;
  42. //colore testo button
  43. box.style.color = 'white';
  44. }
  45.  
  46. body.addEventListener("click",function(){
  47. document.body.style.background=`background:${changeColor("color")};color:${changeColor("color")};transition:.6s;`;
  48. GM_setValue("bg",document.body.style.background)
  49. })
  50.  
  51. //GM_registerMenuCommand("genera color",changeColor);
  52. ///////////////////////////////////
  53. GM_registerMenuCommand("genera color",function(){
  54. document.body.style.background=`background:${changeColor("color")};color:${changeColor("color")};transition:.6s;`;
  55. GM_setValue("bg",document.body.style.background)
  56. })
  57.  
  58.  
  59. function myFunctionnasc() {
  60. if(prova.style.display = (prova.style.display!='none') ? 'none' : 'block');}
  61.  
  62. GM_registerMenuCommand("mostra pulsante/nascondi",myFunctionnasc);