Greasy Fork is available in English.

Greasy Fork Theme figuccio

Greasy Fork pagina colorata

2024-02-22 يوللانغان نەشرى. ئەڭ يېڭى نەشرىنى كۆرۈش.

// ==UserScript==
// @name           Greasy Fork Theme figuccio
// @namespace      https://greasyfork.org/users/237458
// @description    Greasy Fork pagina colorata
// @match          https://greasyfork.org/*
// @match          https://sleazyfork.org/*
// @require        https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js
// @grant          GM_setClipboard
// @version        7.7
// @match          https://greasyfork.org/it/users/*
// @match          https://greasyfork.org/*/users/*
// @noframes
// @author         figuccio
// @grant          GM_addStyle
// @grant          GM_setValue
// @grant          GM_getValue
// @grant          GM_registerMenuCommand
// @match          *://greasyfork.org/*/script_versions/new*
// @match          *://greasyfork.org/*/scripts/*/versions/new*
// @require        https://gitcdn.link/repo/fuzetsu/userscripts/b38eabf72c20fa3cf7da84ecd2cefe0d4a2116be/wait-for-elements/wait-for-elements.js
// @run-at         document-end
// @grant          GM_xmlhttpRequest
// @icon           https://www.google.com/s2/favicons?domain=greasyfork.org
// @require        http://code.jquery.com/jquery-latest.js
// @require        https://code.jquery.com/ui/1.12.1/jquery-ui.js
// @license        MIT
// ==/UserScript==
//data e ora  creato il aggiornato il
function relativeTime() {
    document.querySelectorAll("relative-time").forEach(function(el) {
        var parent = el.parentNode;
        var timestamp = el.title;
        var span = document.createElement("span");
        span.innerHTML = timestamp;
        parent.removeChild(el);
        parent.appendChild(span);
    });
}

document.addEventListener('DOMNodeInserted', relativeTime, false);
////////////////////////////////////7
//display grafica     febbraio 2024
// Function to inject Chart.js from a CDN
const injectChartJs = () => {
    const script = document.createElement('script');
    script.src = 'https://cdn.jsdelivr.net/npm/chart.js';
    document.head.appendChild(script);
};

const plotDistribution = (data1, data2) => {
    // Ensure Chart.js has loaded
    if (typeof Chart === 'undefined') {
        setTimeout(() => plotDistribution(data1,data2), 500); // Retry after 500ms
        return;
    }

    // Create canvas for the chart
    const canvasHtml = '<canvas id="installDistributionCanvas" width="100" height="50"></canvas>';
    const userHeader = document.querySelector('#about-user h2');
    if (userHeader) {
        userHeader.insertAdjacentHTML('afterend', canvasHtml);
        const ctx = document.getElementById('installDistributionCanvas').getContext('2d');

        // Plot chart
        new Chart(ctx, {
            type: 'bar', // Change this to 'line', 'bar', etc. as needed
            data: {
                labels: data1.labels, // X-axis labels
                datasets: [
                {
                    label: 'Total Installs',
                    data: data1.values, // Y-axis data
                    backgroundColor: 'rgba(54, 162, 235, 0.2)',
                    borderColor: 'rgba(54, 162, 235, 1)',
                    borderWidth: 1
                },
                {
                    label: 'Daily Installs',
                    data: data2.values, // Y-axis data
                    backgroundColor: 'rgba(1, 1, 235, 0.2)',
                    borderColor: 'rgba(1, 1, 235, 1)',
                    borderWidth: 1
                }]
            },
            options: {
                scales: {
                    y: {
                        beginAtZero: true
                    }
                }
            }
        });
    }
};

const collectAndPlotData = () => {
    // Assuming you have a way to collect individual install counts
    const totalInstallData = {
        labels: [], // Populate with script names or identifiers
        values: [] // Populate with corresponding install counts
    };

    const dailyInstallData = {
        labels: [], // Populate with script names or identifiers
        values: [] // Populate with corresponding install counts
    };

    var totalInstalls_selector='dd.script-list-total-installs > span';
    var array_totalInstall = Array.from(document.querySelectorAll(totalInstalls_selector)).map(el => (parseInt(el.textContent.replace(/,/g, ''), 10) || 0));
    var dailyInstalls_selector='dd.script-list-daily-installs > span';
    var array_dailyInstalls = Array.from(document.querySelectorAll(dailyInstalls_selector)).map(el => (parseInt(el.textContent.replace(/,/g, ''), 10) || 0))
    var scriptTitle_selector ='article > h2 > a.script-link';
    var array_scriptTitle = Array.from(document.querySelectorAll(scriptTitle_selector)).map(el => el.text)

    for (let i = 0; i < array_totalInstall.length; i++) {
            totalInstallData.labels.push(array_scriptTitle[i]);
            dailyInstallData.labels.push(array_scriptTitle[i]);
            totalInstallData.values=array_totalInstall;
            dailyInstallData.values=array_dailyInstalls;
     }
    plotDistribution(totalInstallData,dailyInstallData);
};


var publishedScriptsNumber = 0;

(function() {
    'use strict';

    const sumInstalls = (selector) => Array.from(document.querySelectorAll(selector))
        .reduce((sum, el) => sum + (parseInt(el.textContent.replace(/,/g, ''), 10) || 0), 0);

    const displayTotals = (daily, total) => {
        const userHeader = document.querySelector('#about-user h2');
        const language = document.documentElement.lang; // Get the current language of the document

        let dailyInstallsText = '';
        let totalInstallsText = '';

        // Determine the text based on the current language
        switch (language) {
            case 'en':
                publishedScriptsNumber = `Number of published scripts: ${publishedScriptsNumber}`;
                dailyInstallsText = `Total daily installations for all scripts: ${daily}`;
                totalInstallsText = `Total installations to date for all scripts: ${total}`;
                break;
            case 'zh-CN':
                publishedScriptsNumber = `已发布脚本总数:${publishedScriptsNumber}`;
                dailyInstallsText = `该用户所有脚本的今日总安装次数:${daily}`;
                totalInstallsText = `该用户所有脚本的迄今总安装次数:${total}`;
                break;
            case 'zh-TW':
                publishedScriptsNumber = `已發布腳本總數:${publishedScriptsNumber}`;
                dailyInstallsText = `該用戶所有腳本的今日總安裝次數:${daily}`;
                totalInstallsText = `該用戶所有腳本的迄今總安裝次數:${total}`;
                break;
            case 'ja':
                publishedScriptsNumber = `公開されたスクリプトの合計:${publishedScriptsNumber}`;
                dailyInstallsText = `本日の全スクリプトの合計インストール回数:${daily}`;
                totalInstallsText = `全スクリプトの累計インストール回数:${total}`;
                break;
            case 'ko':
                publishedScriptsNumber = `게시된 스크립트 총 수: ${publishedScriptsNumber}`;
                dailyInstallsText = `해당 사용자의 모든 스크립트에 대한 오늘의 총 설치 횟수: ${daily}`;
                totalInstallsText = `해당 사용자의 모든 스크립트에 대한 총 설치 횟수: ${total}`;
                break;
                // ... add other languages if needed
            default:
                publishedScriptsNumber = `Numero di script pubblicati: ${publishedScriptsNumber}`;
                dailyInstallsText = `Installazioni giornaliere totali per tutti gli script: ${daily}`;
                totalInstallsText = `Installazioni totali fino ad oggi per tutti gli script: ${total}`;
        }

        if (userHeader) {
            userHeader.insertAdjacentHTML('afterend', `
            <dib>${publishedScriptsNumber}</div>
            <div>${dailyInstallsText}</div>
            <div>${totalInstallsText}</div>
        `);
        }
    };
    const dailyInstallsSum = sumInstalls('dd.script-list-daily-installs > span');
    const totalInstallsSum = sumInstalls('dd.script-list-total-installs > span');
    (function() {
        var list = document.querySelector('ol#user-script-list.script-list.showing-all-languages');
        if (list) {
            var items = list.querySelectorAll('li');
            publishedScriptsNumber = items.length;
        } else {
            console.log('没有找到指定的OL元素');
        }
    })();

    displayTotals(dailyInstallsSum, totalInstallsSum);

    // Call this function at the appropriate place in your script, after the DOM is ready
    injectChartJs();
    collectAndPlotData();
})();

////////////////////////////////////////////////
function execCopy() {
    var code='';
    if($(".prettyprint li").length>0)
    {
        $(".prettyprint li").each(function(){
            code += $(this).text()+'\n';
        });
    }
   else {code = $(".prettyprint").text();}

    code = encodeURI(code)
    code = code.replace(/%C2%A0/g,'%20');
    code = decodeURI(code);

    GM_setClipboard(code, 'text');
    alert("copia con successo")
    return true;
}

    //Il collegamento al codice sorgente viene visualizzato dopo il collegamento allo script
    $(".script-list h2 a").each(function(){
        if(!$(this).next().hasClass("code-link"))
        {let short_link = $(this).attr("href");
            //let $code_link = $('<a href=\"'+short_link+'/code\" class=\"code-link\">codice</a>');//non apre in nuova scheda
              let $code_link = $('<a target="_blank" a href=\"'+short_link+'/code\" class=\"code-link\">codice</a>');//apre in nuova scheda
            $(this).after($code_link);
        }
    })

    //////////////////////////////////////////////////////////
    GM_addStyle('.source{'+
                'display: inline-block;'+
                'background-color:lime;'+
                'padding: 0.5em 1em;'+
                'color: white;'+
                'text-decoration: none;'+
                'cursor:pointer}'+
                '.code-link'+
                '{'+
                '	margin-left:10px; '+
                '	padding-left:2px;'+
                '	padding-right:2px; '+
                '	font-size:12px; '+
                '	background:red; '+
                '	color:white!important; '+
                '	text-decoration: none;'+
                '}');
//////////////////
      if(window.location.href.indexOf("/code")!= -1) //code
        {var source_btn = $("<a></a>")
        source_btn.addClass("source");
        source_btn.text("copiare il codice sorgente");
        source_btn.click(function(){
            execCopy();
        });
        $("#install-area").after(source_btn);
    }
/////////////////////////////////////////////////////
//passa alla pagina successiva richiede jquery
$(window).scroll(function() {
     if($(window).scrollTop() + $(window).height() == $(document).height()) {
       /////////////////////////////////////////////////////li:nth-last-child(1) > a ///////////////////////////////
document.querySelector("body > div.width-constraint > div > div.sidebarred-main-content > div.pagination > a.next_page").click();
         }
});
//////////////////////////////////
//apre i link in nuova scheda maggio 2023
   function modifyLinks() {
  let links =document.querySelectorAll('#browse-script-list a');
  for (let i = 0; i < links.length; i++) {
    links[i].setAttribute('target', '_blank');
  }

}

modifyLinks();

//////////////////////////////////////////////////////////////////////////
  // Show vertical scrollbar
//GM_addStyle('body {overflow-y: scroll!important;}');
//menu ordina per colorato
GM_addStyle('.list-option-group ul {background-color:#1eb19c!important;}');
//colore paginazione
GM_addStyle('.pagination > *, .script-list + .pagination > *, .user-list + .pagination > *{background-color:rgb(19, 19, 19)!important;}');
GM_addStyle('body > div > div > div.sidebarred-main-content > div.pagination > em{background-color:green!important;}');//colore num pag current
GM_addStyle('.pagination{border: 2px solid peru !important;background: linear-gradient(to bottom, rgba(19, 19, 19, 1) 0%, rgba(51, 51, 51, 1) 0%, rgba(17, 17, 17, 1) 169%, rgba(0, 0, 0, 1) 98%) repeat scroll 0 0 rgba(0, 0, 0, 0); border-radius: 3px 3px 0 0 !important;}');
GM_addStyle('.width-constraint .pagination {border-radius:10px!important;}');

//input casella ricerca script rossa
GM_addStyle('.sidebar-search input{background-color:red!important;}');
//colore parte centrale
GM_addStyle('.script-list{background-color:#d4c515d1!important;}');

//colore nero descrizione script necessario perche se no lo scroll dark lo fara vedere bianco e non si vedra
GM_addStyle('body, input, select {color:black;}');
//////////////////codice sorgente colorato//////////////////////////////////////////////////////////////
GM_addStyle('pre.prettyprint {background-color:#92ad92!important;border: 2px solid red!important;}');//1 stesso colore
GM_addStyle('li.L1, li.L3, li.L5, li.L7, li.L9 {background-color:#92ad92!important;}');//2 stesso colore
/////////////////////////////////////////////////////////////////////////////////////////////////////////
//parte superiore codice sorgente colorata
GM_addStyle('#script-info {border: 2px solid blue!important;background-color:aquamarine!important;}');

//scrool dark
var meta = document.createElement('meta');
meta.name = "color-scheme";
meta.content = "light dark";
document.getElementsByTagName('head')[0].appendChild(meta);

///////////////////////// color picker
(function() {
   'use strict';
var $ = window.jQuery;
var j = $.noConflict();
var body=document.body;
var style=" position:fixed;top:9px;left:870px;z-index:99999;"
var box=document.createElement("div");


box.id="mytema";
box.style=style;
j(box).draggable();
body.append(box);

//mostra/nascondi
function provagf(){
var box = document.getElementById('mytema');
box.style.display = ((box.style.display!='none') ? 'none' : 'block');
}
GM_registerMenuCommand("nascondi/mostra box",provagf);
/////////////////////////////////////////////////////////////////////
        //dati per la conservazione
        var userdata = { color: 'theme',}
        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="#000000";}
            ///////////////////////////////////////////////////////////
            //Imposta lo stile CSS degli elementi nel menu
        GM_addStyle(`
                #myMenu {
                    font-family: Helvetica, 'Hiragino Sans GB', 'Microsoft Yahei', Arial, sans-serif;
                    font-size: px;
                    z-index: 2147483648;
                }
  .button {margin-left:-5px;padding:3px 6px;line-height:16px;margin-top:-19px;display:inline-block;border:1px solid yellow;border-radius:3px;cursor:pointer;background:chocolate;}

          #colorspan {cursor:pointer; margin-left:1px; margin-bottom:-19px; color:lime;background-color:brown; border:1px solid yellow;}

          #setui{ width:auto;height:25px;margin-top:-10px; margin-left:0px;margin-right:0px; margin-bottom:0px;background-color:#293446;color:lime;}

          #colorinput{cursor:pointer; height:20px; margin-left:4px; margin-top:-10px;background-color:#3b3b3b;color:red;border:1px solid yellow; border-radius: 5px;}
          #greasy {font-size:13px!important;display:inline-block;cursor:pointer; background:#3b3b3b;color:lime;border:1px solid yellow; border-radius:5px;margin:9px;text-align:center;width:max-content;}

            `);
setInterval(myTimer,70);
function myTimer() {
var d = new Date();
var t = d.toLocaleTimeString();
var mm = d.getMilliseconds();//millisecondi ottobre 2023
    ////////////////short  long
var date = new Date().toLocaleString('it', {'weekday': 'short', 'month': '2-digit', 'day': '2-digit','year':'numeric'});

document.getElementById("greasy").innerHTML =date +" "+ t +":"+ mm;
}

  //elemento html nel div readonly datatime non fa comparire licona del calendario  width:280px evita che spostandolo ai lati cambi forma
   box.innerHTML=`
                      </p>
                      <fieldset style="background:#3b3b3b;border:2px solid red;color:lime;border-radius:7px;text-align:center;width:395px;height:43px;">
                      <legend>Time</legend>
    <div id=setui>
<button id="colorspan" title="Hex value">${mycolor}</button> <input type="color" list="colors" id="colorinput" value="${mycolor}" title="Color picker"><div id="greasy"  title="Data-ora"></div>  <span class="button" title="Chiudi" id='close'>X</span>

                                    </p>
                    </div>
                    </fieldset>
            `;

            //////////////////////////////
            //aggiunta span close per chiudere il box direttamente
            var colorinputsetMenuClose=document.querySelector('#close');
            colorinputsetMenuClose.addEventListener('click',provagf,false);

            ////////////////////////////////////////
            var colorinput=document.querySelector('#colorinput');
            var colorspan = document.querySelector('#colorspan');
            ////////////////////////////////////////
            colorinput.addEventListener('input', function(event){colorChange(event)},false);
            $('body').css("background-color", mycolor);
           //evento della tavolozza dei colori
            function colorChange (e) {
            mycolor = e.target.value;
            colorspan.innerHTML=e.target.value;
            $('body').css("background-color", mycolor);
            GM_setValue(userdata.color, mycolor);
            }
})();
//////////////////////mostra numero 1,2,3ecc accanto agli script
(function() {
    'use strict';
    const page = +new URLSearchParams(document.location.search).get('page')||1;
    const q= `<style>#browse-script-list{counter-reset: section ${(page-1)*50};}.ad-entry{height:0;overflow:hidden;}#browse-script-list li{position:relative}.Finn{background:gold;} .ad-entry{display:none}#browse-script-list li:after{counter-increment: section;content:counter(section);font:bold 20px/30px Arial;background:red;color:green;position:absolute;bottom:8px;right:15px}</style>`;
    document.documentElement.insertAdjacentHTML('afterbegin', q);
    const a = document.querySelector(".user-profile-link a").href;
    document.querySelectorAll("#browse-script-list li").forEach(function(i){
        const b = i.querySelector("dd.script-list-author a");
        if( b&& b.href===a) { i.className='Finn' }
    })
})();
///////////////////////////////autoclick casella editor checkbox lunghezza codice height 560px funziona
(function() {
  var textarea = document.getElementById('script_version_code');
 if (textarea !== null) {
    textarea.style.height = '560px';
  }
//autoclick casella editor checkbox
    const checkbox = document.querySelector("#enable-source-editor-code")
    if (checkbox.checked === false) {
        checkbox.click();
    }
//setTimeout(function(){document.getElementById("enable-source-editor-code").click();}, 2000);
})();
////////////informazioni sugli script
(async function() {
  'use strict';
  var date, ok = 0, bad = 0, Dailytotal = 0, total = 0, good = 0; //Crea nuove variabili
  document.querySelectorAll(".ok-rating-count").forEach(el => ok += parseInt(el.innerText)); //Aggiungi le valutazioni
  document.querySelectorAll(".bar-rating-count").forEach(el => bad += parseInt(el.innerText));
  document.querySelectorAll(".good-rating-count").forEach(el => good += parseInt(el.innerText));
  document.querySelectorAll("dd.script-list-total-installs").forEach(el => total += parseInt(el.innerText.replaceAll(',',''))); //Aggiungi le installazioni
  document.querySelectorAll("dd.script-list-daily-installs").forEach(el => Dailytotal += parseInt(el.innerText.replaceAll(',','')));

  if (location.href.match('sort=created') === null) { //If the current page is not already being sorted by the created date
    date = await (await fetch(location.href + '?sort=created')).text(); //Fetch the page sorted by the created date
    date = new DOMParser().parseFromString(date, "text/html").querySelector("span > relative-time").innerText; //Save the newest created date
  } //Finishes the if condition
  else //If the current page is already being sorted by the created date
  { //Starts the else condition
    date = document.querySelector("relative-time").title; //Save the newest created date
  } //Finishes the else condition
 location.href.match('users') ? document.querySelector("#user-script-sets-section").insertAdjacentHTML("afterbegin", ` <section> <header> <h3>Totale</h3> </header> <section class="text-content"> <ul> <li><b>Script posts</b>: ${document.querySelectorAll("#user-script-list > li").length}</li> <li><b>Installazioni giornaliere</b>: ${Dailytotal.toLocaleString()}</li> <li><b>Installazioni totali</b>: ${total.toLocaleString()}</li> <li><b>Ultimo creato</b>: ${date}</li> <li><b>Numero di persone che lo hanno valutato cattivo</b>: ${bad.toLocaleString()}</li> <li><b>Numero di persone che lo hanno valutato OK</b>: ${ok.toLocaleString()}</li> <li><b>Numero di persone che lo hanno valutato Buono o lo hanno aggiunto ai preferiti</b>: ${good.toLocaleString()}</li> </ul> </section> </section>`) : document.querySelector(".width-constraint:nth-child(2)").insertAdjacentHTML("afterbegin", ` <section> <header> <h3>Total</h3> </header> <section class="text-content"> <ul> <li><b>Script posts</b>: ${document.querySelectorAll("#browse-script-list > li").length}</li> <li><b>Daily installs</b>: ${Dailytotal.toLocaleString()}</li> <li><b>Total installs</b>: ${total.toLocaleString()}</li> <li><b>Latest created</b>: ${date}</li> <li><b>Number of people who rated it Bad</b>: ${bad.toLocaleString()}</li> <li><b>Number of people who rated it OK</b>: ${ok.toLocaleString()}</li> <li><b>Numero di persone che lo hanno valutato Buono o lo hanno aggiunto ai preferiti</b>: ${good.toLocaleString()}</li> </ul> </section> </section>`); //Add the information on the page
})();
/////////////////////////formato data creato il aggiornato il (giorno mese anno ore)
function pad(s, d){

  s= `000000${s}`
return s.substring(s.length-d)

}
let did = 0;
let cid = setInterval(()=>{

  for(const s of document.querySelectorAll("relative-time[datetime]:not(.absolute)")){
    s.classList.add("absolute")
    s.format = 'datetime';
    did ? (cancelAnimationFrame(did), (did=0)) :0;
    Promise.resolve(s).then(()=>{

    did ? (cancelAnimationFrame(did), (did=0)) :0;
    requestAnimationFrame(()=>{

    did ? (cancelAnimationFrame(did), (did=0)) :0;
      let d = s.getAttribute('datetime');
      let dt = d ? new Date(d) : null;

      if(dt && s.shadowRoot && s.shadowRoot.firstChild){
        //giorno/mese/anno/ora
s.shadowRoot.firstChild.textContent =`${pad(dt.getDate(),2)}/${pad(dt.getMonth()+1,2)}/${dt.getFullYear()} -${pad(dt.getHours(),2)}:${pad(dt.getMinutes(),2)}`

      }
    })

    })

  }

    did = did || (document.body ? requestAnimationFrame(()=>{
      cid && clearInterval(cid);
      cid = 0;
    }) : 0);

},1)
//////////////////////////////////////////////////////////////////////////