Greasy Fork Theme figuccio

Greasy Fork pagina colorata

目前為 2022-10-31 提交的版本,檢視 最新版本

// ==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/*
// @version        4.7
// @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==
  // 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;}');
//mostra risultato per tutte le lingue
if (document.URL == "https://greasyfork.org/it/scripts") window.location.href = "https://greasyfork.org/it/scripts?filter_locale=0";
if (document.URL == "https://sleazyfork.org/it/scripts" ) window.location.href = "https://sleazyfork.org/it/scripts?filter_locale=0";
/////////////autoclick casella editor checkbox
(() => {
  'use strict';
  waitForElems({
    sel: '#enable-source-editor-code',
    stop: true,
    onmatch(checkbox) {
      checkbox.click();
    }
  });
})();

//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);
///////////////////////////////////////////////scorrimento automatico pagine////////////
(function() {
    // L'ID predefinito è 0
    var curSite = {SiteTypeID: 0};
    // Regole di cambio pagina automatiche
    let DBSite = {
        postslist: {
            SiteTypeID: 1,
            pager: {
                type: 1,
                nextLink: '//a[@class="next_page"][@href]',
                pageElement: 'css;ol#browse-script-list > li',
                HT_insert: ['css;ol#browse-script-list', 3],
                replaceE: 'css;.pagination',
                scrollDelta: 1000
            }
        }
        };
    // Utilizzato per determinare il tipo di URL corrente all'interno dello script
    let SiteType = {
        POSTSLIST: DBSite.postslist.SiteTypeID
    };

    curSite = DBSite.postslist;
    curSite.pageUrl = ""; // URL della pagina successiva
    pageLoading();//Volta pagina automatica

    // Volta pagina automatica
    function pageLoading() {
        if (curSite.SiteTypeID > 0){
            windowScroll(function (direction, e) {
                if (direction === "down") { // Scorri verso il basso per prepararti a voltare pagina
                    var scrollTop = document.documentElement.scrollTop || window.pageYOffset || document.body.scrollTop;
                    let scrollDelta = 1299;
                    if (document.documentElement.scrollHeight <= document.documentElement.clientHeight + scrollTop + scrollDelta) {
                        ShowPager.loadMorePage();
                    }
                }
            });
        }
    }

    // evento della barra di scorrimento
    function windowScroll(fn1) {
        var beforeScrollTop = document.documentElement.scrollTop,
            fn = fn1 || function () {};
        setTimeout(function () { //Ritarda l'esecuzione per evitare di attivare gli eventi di capovolgimento della pagina subito dopo il caricamento della pagina
            window.addEventListener("scroll", function (e) {
                var afterScrollTop = document.documentElement.scrollTop,
                    delta = afterScrollTop - beforeScrollTop;
                if (delta == 0) return false;
                fn(delta > 0 ? "down" : "up", e);
                beforeScrollTop = afterScrollTop;
            }, false);
        }, 1000)
    }

    var ShowPager = { // Modificato da https://greasfork.org/scripts/14178
        getFullHref: function (e) {
            if(e == null) return '';
            "string" != typeof e && (e = e.getAttribute("href"));
            var t = this.getFullHref.a;
            return t || (this.getFullHref.a = t = document.createElement("a")), t.href = e, t.href;
        },
        createDocumentByString: function (e) {
            if (e) {
                if ("HTML" !== document.documentElement.nodeName) return (new DOMParser).parseFromString(e, "application/xhtml+xml");
                var t;
                try {
                    t = (new DOMParser).parseFromString(e, "text/html");
                } catch (e) {
                }
                if (t) return t;
                if (document.implementation.createHTMLDocument) t = document.implementation.createHTMLDocument("ADocument"); else try {
                    (t = document.cloneNode(!1)).appendChild(t.importNode(document.documentElement, !1)),
                        t.documentElement.appendChild(t.createElement("head")), t.documentElement.appendChild(t.createElement("body"));
                } catch (e) {
                }
                if (t) {
                    var r = document.createRange();
                    r.selectNodeContents(document.body);
                    var n = r.createContextualFragment(e);
                    t.body.appendChild(n);
                    for (var a, o = {
                        TITLE: !0,
                        META: !0,
                        LINK: !0,
                        STYLE: !0,
                        BASE: !0
                    }, i = t.body, s = i.childNodes, c = s.length - 1; c >= 0; c--) o[(a = s[c]).nodeName] && i.removeChild(a);
                    return t;
                }
            } else console.error("Nessuna stringa trovata da convertire in DOM");
        },
        loadMorePage: function () {
            if (curSite.pager) {
                let curPageEle = getElementByXpath(curSite.pager.nextLink);
                var url = this.getFullHref(curPageEle);

                if(url === '') return;
                if(curSite.pageUrl === url) return;// Non ricarica la stessa pagina
                curSite.pageUrl = url;
                //Leggi la prossima pagina di dati
                curSite.pager.startFilter && curSite.pager.startFilter();
                GM_xmlhttpRequest({
                    url: url,
                    method: "GET",
                    timeout: 5000,
                    onload: function (response) {
                        try {
                            var newBody = ShowPager.createDocumentByString(response.responseText);
                            let pageElems = getAllElements(curSite.pager.pageElement, newBody, newBody);
                            let toElement = getAllElements(curSite.pager.HT_insert[0])[0];
                            if (pageElems.length >= 0) {
                                let addTo = "beforeend";
                                if (curSite.pager.HT_insert[1] == 1) addTo = "beforebegin";
                                // Inserisci un nuovo elemento di pagina
                                pageElems.forEach(function (one) {
                                    toElement.insertAdjacentElement(addTo, one);
                                });
                                // sostituire l'elemento da sostituire
                                try {
                                    let oriE = getAllElements(curSite.pager.replaceE);
                                    let repE = getAllElements(curSite.pager.replaceE, newBody, newBody);
                                    if (oriE.length === repE.length) {
                                        for (var i = 0; i < oriE.length; i++) {
                                            oriE[i].outerHTML = repE[i].outerHTML;
                                        }
                                    }
                                } catch (e) {
                                    console.log(e);
                                }
                            }
                        } catch (e) {
                            console.log(e);
                        }
                    }
                });
            }
        },
    };


    function getElementByXpath(e, t, r) {
      r = r || document, t = t || r;
      try {
        return r.evaluate(e, t, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
      } catch (t) {
        return void console.error("无效的xpath");
      }
    }


    function getAllElements(e, t, r, n, o) {
      let getAllElementsByXpath = function(e, t, r) {
        return r = r || document, t = t || r, r.evaluate(e, t, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
      }

      var i, s = [];
      if (!e) return s;
      if (r = r || document, n = n || window, o = o || void 0, t = t || r, "string" == typeof e) i = 0 === e.search(/^css;/i) ? function getAllElementsByCSS(e, t) {
        return (t || document).querySelectorAll(e);
      }(e.slice(4), t) : getAllElementsByXpath(e, t, r); else {
        if (!(i = e(r, n, o))) return s;
        if (i.nodeType) return s[0] = i, s;
      }
      return function makeArray(e) {
        var t, r, n, o = [];
        if (e.pop) {
          for (t = 0, r = e.length; t < r; t++) (n = e[t]) && (n.nodeType ? o.push(n) : o = o.concat(makeArray(n)));
          return a()(o);
        }
        if (e.item) {
          for (t = e.length; t;) o[--t] = e[t];
          return o;
        }
        if (e.iterateNext) {
          for (t = e.snapshotLength; t;) o[--t] = e.snapshotItem(t);
          return o;
        }
      }(i);
    }
})();

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


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


function prova(){
if(mytema.style.display = (mytema.style.display!='none') ? 'none' : 'block');}
GM_registerMenuCommand("nascondi/mostra box",prova);
///////////////////////////////test funzione chiudi menu da close funziona
function myFunction() {
document.getElementById("mytema").style.display = "none";
}

/////////////////////////////////////////////////////////////////////
 //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: 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; color:lime;background-color:brown; border: 2px solid green;}

                #setui{
                    width:auto;
                    height:55px;
                    margin-top:0px;
                    margin-left:0px;
                    margin-right:0px;
                    margin-bottom:0px;
                    background-color:#293446;
                    border-width:1px;
                    border-style: solid;
                    color:lime;

                }

                #colorinput{ margin-left:4px; margin-top:11px; background-color:#3b3b3b;color:red;border:1px solid yellow; border-radius: 5px;}
            `);
  //elemento html nel div
   box.innerHTML=`
                      </p>
                      <fieldset style="background:green;border:2px solid red;color:lime;border-radius:7px;text-align:center;">
                      <legend>Select Color</legend>
    <div id=setui>
  HEX<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;
            }

                 colorinput.addEventListener('input', function(event){colorChange(event)},false);
                 $('body').css("background-color", mycolor);
                 document.getElementById('colorinput').value =mycolor;
                  colorinput.addEventListener('input', function(){
                             GM_setValue(userdata.color, mycolor);
console.log(this.value);

 $('body').css("background-color",mycolor);
        });

})();
//////////////////////