random color menu comand

cambio colore dal pulsante e dal menu

目前为 2022-07-18 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name random color menu comand
  3. // @namespace https://greasyfork.org/users/237458
  4. // @version 0.1
  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. // @noframes
  14. // @license MIT
  15. // ==/UserScript==
  16. (function() {
  17. 'use strict';
  18. var Button = document.createElement('button');
  19. document.getElementsByTagName('body')[0].appendChild(Button);
  20. Button.setAttribute ('id', 'prova');
  21. Button.setAttribute ('title', 'cambio colore');
  22. Button.style = "position:absolute;top:370px;right:0px;z-index:9999999999999999999999;background-color:green;color:red;padding:3px;border-radius: 5px;border-color:black;";
  23. Button.innerHTML = "cambia colore random";
  24. Button .addEventListener("click",getRandomColor);
  25. function getRandomColor() {
  26. var letters = "0123456789ABCDEF";
  27. var randomColor = "#";
  28. for (var i = 0; i < 6; i++) {
  29. randomColor += letters[Math.floor(Math.random() * letters.length)];
  30. }
  31.  
  32. document.body.style.backgroundColor = randomColor;
  33. }
  34.  
  35. GM_registerMenuCommand("genera color",getRandomColor);
  36. })();
  37.