Browsing Designer color picker figuccio

color picker background con memoria

目前為 2024-03-15 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name          Browsing Designer color picker figuccio
// @namespace     https://greasyfork.org/users/237458
// @version       1.6
// @description   color picker background con memoria
// @author        figuccio
// @match         *://*/*
// @require       http://code.jquery.com/jquery-latest.js
// @require       https://code.jquery.com/ui/1.12.1/jquery-ui.js
// @grant         GM_addStyle
// @grant         GM_setValue
// @grant         GM_getValue
// @grant         GM_registerMenuCommand
// @icon          https://www.google.com/s2/favicons?sz=64&domain=tampermonkey.net
// @license       MIT
// @noframes
// ==/UserScript==
(function() {
'use strict';
    //marzo 2024
   // Aggiungi la funzione per il trascinamento limitato allo schermo
function makeDraggableLimited(element) {
    element.draggable({
        containment: "window",
        stop: function(event, ui) {
            // Memorizza la posizione dopo il trascinamento
            GM_setValue('boxPosition', JSON.stringify(ui.position));//importante
        }
    });
}

const $ = window.jQuery;
const j = $.noConflict();
const body=document.body;
const style=" position:fixed; top:-11px;left:370px;background:;z-index:99999;"
const box=document.createElement("div");

box.id="my7";
box.style=style;
j(box).draggable();
body.append(box);
 // Ripristina la posizione salvata se presente
const savedPosition = GM_getValue('boxPosition');
if (savedPosition) {
    const parsedPosition = JSON.parse(savedPosition);
    $(box).css({ top: parsedPosition.top, left: parsedPosition.left });
}
    ////////////////////////////////////////////marzo 2024
     // Rendi l'elemento trascinabile con limitazioni di schermo
    makeDraggableLimited($(box));
    /////////////////////////////////
function prova(){
var box = document.getElementById('my7');
box.style.display = ((box.style.display!='none') ? 'none' : 'block');
}
GM_registerMenuCommand("nascondi/mostra box",prova);
/////////////////////////////// funzione chiudi menu da close funziona
function myFunction() {
document.getElementById("my7").style.display = "none";
}

/////////////////////////////////////////////////////////////////////
 //dati per la conservazione
        const userdata = {color: 'mio colore'}

        var mycolor;//dichiarare la variabile colore

   //imposta la variabile del colore
        if(/^#+\w+$/.test(GM_getValue(userdata.color))){mycolor = GM_getValue(userdata.color);}

        else {mycolor="#ff0000";}
/////////////////////////////////////////////////////////////////////////////////////
     function saveSetting() {GM_setValue(userdata.color,mycolor );
     $('body,div[aria-label="Facebook"][role="navigation"]').css("background-color", mycolor);
          }
   ///////////////////////////////////////////////////////////
            //Imposta lo stile CSS degli elementi nel menu
        GM_addStyle(`
                #myMenu {
                    font-family: Helvetica, 'Hiragino Sans GB', 'Microsoft Yahei', Arial, sans-serif;
                    font-size: 14px;
                    z-index: 2147483648;
                }
                 .button {
                    padding: 3px 6px;
                    line-height: 16px;
                    margin-top:-19px;
                    display: inline-block;
                    border: 1px solid black;
                    border-radius: 3px;
                    cursor: pointer;
                    background:chocolate;

                }

                #colorspan { margin-left:1px; margin-bottom:-19px;}

                #seletcolor{margin-top:-47px; margin-left:5px;}

                #setuibd{
                    width:auto;
                    height:35px;
                    margin-top:-10px;
                    margin-left:10px;
                    margin-right:10px;
                    margin-bottom:5px;
                    border-width:1px;
                    color:lime;

                }

                #colorinput{ margin-left:4px; margin-top:4px;}
                #colorspan{ color:lime;background-color:brown; border: 1px solid blue;}
            `);

  //elemento html nel div
   box.innerHTML=`
                      </p>
                      <fieldset style="background:green; border: 2px solid red;color:lime;border-radius:7px;text-align:center; width:315px;height:35px;">
                      <legend>Select Color</legend>
    <div id=setuibd>
   <button id="colorspan">${mycolor}</button>  color picker <input type="color" list="colors" id="colorinput" value="${mycolor}" title="color picker">
   <span class="button" title="chiudi" id='close'>close</span>

                                    </p>
                    </div>
                     </fieldset>
            `;
            //////////////////////////////
            //aggiunta span close per chiudere il box direttamente
            var colorinputsetMenuClose=document.querySelector('#close');
            colorinputsetMenuClose.addEventListener('click',myFunction,false);

            ////////////////////////////////////////
            var colorinput=document.querySelector('#colorinput');
            var colorspan = document.querySelector('#colorspan');
            ////////////////////////////////////////
           //evento della tavolozza dei colori
            function colorChange (e) {
            mycolor = e.target.value;
            colorspan.innerHTML=e.target.value;
            }
//////////////////////////////////////////////////////////
      //recupero colore impostato barra facebook giochi
 var observer = new MutationObserver(function(mutations) {
 mutations.forEach(function(mutation) {
 saveSetting();
        });
    });
 observer.observe(document, {childList:true, subtree:true});
    //////////////
    //////////////////////////
                 colorinput.addEventListener('input', function(event){colorChange(event)},false);
                $('body,div[aria-label="Facebook"][role="navigation"]').css("background-color", mycolor);

                 document.getElementById('colorinput').value =mycolor;
                 colorinput.addEventListener('input', function(){
                      GM_setValue(userdata.color, mycolor);
                     console.log(this.value);
 $('body,div[aria-label="Facebook"][role="navigation"]').css("background-color",mycolor);
        });
})();