facebook Color Themes figuccio

Aggiunge lista colori. Puoi scegliere red, orange, yellow, green, blue,ecc

  1. // ==UserScript==
  2. // @name facebook Color Themes figuccio
  3. // @version 1.1
  4. // @namespace https://greasyfork.org/users/237458
  5. // @match https://*.facebook.com/*
  6. // @author figuccio
  7. // @description Aggiunge lista colori. Puoi scegliere red, orange, yellow, green, blue,ecc
  8. // @run-at document-start
  9. // @require https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js
  10. // @require http://code.jquery.com/jquery-latest.js
  11. // @require https://code.jquery.com/ui/1.12.1/jquery-ui.js
  12. // @require https://greasyfork.org/scripts/12228/code/setMutationHandler.js
  13. // @grant GM_addStyle
  14. // @grant GM_setValue
  15. // @grant GM_getValue
  16. // @icon https://www.google.com/s2/favicons?domain=facebook.com
  17. // @grant GM_registerMenuCommand
  18. // @noframes
  19. // @license MIT
  20. // ==/UserScript==
  21. (function() {
  22. 'use strict';
  23.  
  24. var $ = window.jQuery;
  25.  
  26. $(document).ready(function() {
  27. var body = document.body;
  28. var style = "position:fixed; top:-3px;right:500px;z-index:99999;";
  29. var box = document.createElement("div");
  30.  
  31. // Recupera la posizione memorizzata dalla localStorage
  32. var storedPosition = GM_getValue('position', '');
  33. if (storedPosition !== '') {
  34. var [top, left] = storedPosition.split(',');
  35. style = `position:fixed; top:${top}px; left:${left}px; z-index:99999;`;
  36. }
  37.  
  38. box.id = "myteme";
  39. box.style = style;
  40. $(box).draggable({
  41. containment: "window", // Limita il trascinamento entro i bordi della finestra
  42. stop: function(event, ui) {
  43. // Memorizza la nuova posizione nella localStorage
  44. var position = `${ui.position.top},${ui.position.left}`;
  45. GM_setValue('position', position);
  46. }
  47. });
  48.  
  49. // Aggiunta dell'elemento HTML nel div box
  50. box.innerHTML = `
  51. <fieldset style="background:#3b3b3b;border:2px solid red;color:lime;border-radius:7px;text-align:center;width:120px!important;height:44px;">
  52. <legend>Themes figuccio</legend>
  53. <div id="setuii">
  54. <select id="selectColor" title="Selettore colori">
  55. <option value="">Scegli ...</option>
  56. <option style="background-color: Purple" value="Purple">Purple</option>
  57. <option style="background-color: Blue" value="Blue">Blue</option>
  58. <option style="background-color: Green" value="Green">Green</option>
  59. <option style="background-color: Orange" value="Orange">Orange</option>
  60. <option style="background-color: Brown" value="Brown">Brown</option>
  61. <option style="background-color: Cyan" value="Cyan">Cyan</option>
  62. <option style="background-color: Gray" value="Gray">Gray</option>
  63. <option style="background-color: Indigo" value="Indigo">Indigo</option>
  64. <option style="background-color: Magenta" value="Magenta">Magenta</option>
  65. <option style="background-color: Pink" value="Pink">Pink</option>
  66. <option style="background-color: Red" value="Red">Red</option>
  67. <option style="background-color: Violet" value="Violet">Violet</option>
  68. <option style="background-color: Yellow" value="Yellow">Yellow</option>
  69. <option style="background-color: Black" value="Black">Black</option>
  70. <option style="background-color: lightgreen" value="lightgreen">lightgreen</option>
  71. <option style="background-color: lightyellow" value="lightyellow">lightyellow</option>
  72. <option style="background-color: lightblue" value="lightblue">lightblue</option>
  73. <option style="background-color: lightgrey" value="lightgrey">lightgrey</option>
  74. </select>
  75. </div>
  76. </fieldset>
  77. `;
  78.  
  79. body.append(box);
  80.  
  81. // Funzione per applicare il colore selezionato
  82. function applyColor(color) {
  83. $("div[aria-label=Facebook][role=navigation]").css("background-color", color);
  84. }
  85.  
  86. // Recupera il valore di colore dal local storage
  87. var storedColor = GM_getValue('color', '');
  88.  
  89. // Imposta il colore iniziale
  90. if (storedColor !== '') {
  91. applyColor(storedColor);
  92. $('#selectColor').val(storedColor);
  93. }
  94.  
  95. // Pulizia del local storage se l'utente annulla la selezione
  96. GM_registerMenuCommand("Reset Color", function() {
  97. GM_setValue('color', '');
  98. applyColor('');
  99. $('#selectColor').val('');
  100. });
  101.  
  102. // Gestisce il cambiamento di colore
  103. $('#selectColor').change(function() {
  104. var selectedColor = this.value;
  105.  
  106. // Salva il colore selezionato nel local storage
  107. GM_setValue('color', selectedColor);
  108.  
  109. // Applica il colore selezionato
  110. applyColor(selectedColor);
  111. });
  112. });
  113.  
  114. // Imposta lo stile CSS degli elementi nel menu
  115. GM_addStyle(`
  116. #setuii { width:auto; height:25px; margin-top:0px!important; margin-left:-12px; margin-right:-12px; margin-bottom:0px; border-width:1px; }
  117. #selectColor { background:#3b3b3b; color:lime; border:1px solid yellow; border-radius:5px; }
  118. `);
  119.  
  120. // Applica lo stile dei colori
  121. $(function() {
  122. $("select").change(function() {
  123. var $selectedOption = $(this).find("option:selected");
  124. $(this).removeAttr("style").attr("style", $selectedOption.attr("style"));
  125. });
  126. });
  127. })();
  128.