Greasy Fork Theme figuccio

Greasy Fork pagina colorata

目前为 2025-04-24 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name Greasy Fork Theme figuccio
  3. // @namespace https://greasyfork.org/users/237458
  4. // @description Greasy Fork pagina colorata
  5. // @match https://greasyfork.org/*
  6. // @match https://sleazyfork.org/*
  7. // @match *://greasyfork.org/*/users/*
  8. // @require https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js
  9. // @grant GM_setClipboard
  10. // @version 11.3
  11. // @noframes
  12. // @author figuccio
  13. // @grant GM_addStyle
  14. // @grant GM_setValue
  15. // @grant GM_getValue
  16. // @grant GM_registerMenuCommand
  17. // @run-at document-end
  18. // @grant GM_xmlhttpRequest
  19. // @icon https://www.google.com/s2/favicons?domain=greasyfork.org
  20. // @require http://code.jquery.com/jquery-latest.js
  21. // @require https://code.jquery.com/ui/1.13.2/jquery-ui.js
  22. // @license MIT
  23. // ==/UserScript==
  24. (function() {
  25. 'use strict';
  26. // Aggiungi la funzione per il trascinamento limitato allo schermo
  27. function makeDraggableLimited(element) {
  28. element.draggable({
  29. containment: "window",
  30. stop: function(event, ui) {
  31. // Memorizza la posizione dopo il trascinamento
  32. GM_setValue('boxPosition', JSON.stringify(ui.position));//importante
  33. }
  34. });
  35. }
  36.  
  37. const $ = window.jQuery.noConflict();//$ evita triangolo giallo
  38. const body = document.body;
  39. const style = "position:fixed;top:9px;left:870px;z-index:99999;";
  40. const box = document.createElement("div");
  41.  
  42. box.id = "mytema";
  43. box.style = style;
  44. body.append(box);
  45.  
  46. // Ripristina la posizione salvata se presente
  47. const savedPosition = GM_getValue('boxPosition');
  48. if (savedPosition) {
  49. const parsedPosition = JSON.parse(savedPosition);
  50. $(box).css({ top: parsedPosition.top, left: parsedPosition.left });
  51. }
  52. ////////////////////////////////////////////marzo 2024
  53. // Rendi l'elemento trascinabile con limitazioni di schermo
  54. makeDraggableLimited($(box));
  55. ////////////////////////////
  56. // Mostra/Nascondi con animazione
  57. function provagf() {
  58. var box = document.getElementById('mytema');
  59. $(box).fadeToggle(3000); // Animazione per mostrare/nascondere
  60. }
  61. GM_registerMenuCommand("nascondi/mostra box", provagf);
  62.  
  63. // Dati per la conservazione
  64. const userdata = { color: 'theme' };
  65. var mycolor = GM_getValue(userdata.color, "#980000"); // Valore predefinito
  66.  
  67. let use12HourFormat = GM_getValue('use12HourFormat', false); // Default è il formato 24 ore
  68. let language = GM_getValue('language') || 'it'; // Recupera la lingua dal localStorage o usa 'it' come predefinita
  69.  
  70. const languages = {
  71. en: { weekday: 'short', month: 'short', day: '2-digit', year: 'numeric' },
  72. it: { weekday: 'short', month: '2-digit', day: '2-digit', year: 'numeric' }
  73. };
  74. function myTimer() {
  75. const now = new Date(); // Crea un'istanza di Date ogni volta
  76. let hours = now.getHours();
  77. const minutes = String(now.getMinutes()).padStart(2, "0");
  78. const seconds = String(now.getSeconds()).padStart(2, "0");
  79. const milliseconds = String(now.getMilliseconds()).padStart(3, "0");
  80. const date = now.toLocaleString(language, languages[language]); // Usa la lingua selezionata per la data
  81. let period = "";
  82.  
  83. if (use12HourFormat) { // Condizione corretta per il formato 12 ore
  84. period = hours >= 12 ? " PM" : " AM";
  85. hours = hours % 12 || 12; // Converte in formato 12 ore
  86. }
  87.  
  88. hours = String(hours).padStart(2, "0"); // Aggiunge lo zero iniziale per ore
  89. document.getElementById("greasy").textContent = `${date} ${hours}:${minutes}:${seconds}:${milliseconds}${period}`;
  90. }
  91.  
  92. function toggleFormat() {
  93. use12HourFormat = !use12HourFormat; // Alterna il formato orario
  94. GM_setValue('use12HourFormat', use12HourFormat); // Salva lo stato del formato
  95. language = (language === 'it') ? 'en' : 'it'; // Alterna tra 'it' e 'en'
  96. GM_setValue('language', language); // Salva la lingua scelta
  97. }
  98. // Registra i menu di comando
  99. //GM_registerMenuCommand("Cambia formato orario 12/24", toggleFormat);
  100. // Chiama la funzione di inizializzazione e avvia il timer
  101. const intervalTime = 90; // Imposta l'intervallo di tempo
  102. setInterval(myTimer, intervalTime);
  103.  
  104. // Elemento HTML nel div
  105. box.innerHTML = `
  106. <fieldset style="background:#3b3b3b;border:2px solid red;color:lime;border-radius:7px;text-align:center;width:480px;height:43px;">
  107. <legend>Time</legend>
  108. <div id=setui style="width:auto;height:25px;margin-top:-13px;margin-left:0px;margin-right:0px;margin-bottom:0px;">
  109. <button id="colorspan" title="Hex value" style="font-size:14px;cursor:pointer;margin-left:1px;margin-bottom:-19px;color:lime;background-color:brown;border:1px solid yellow;">${mycolor}</button>
  110. <input type="color" title="Color picker" list="colors" id="colorinput" style="width:50px;height:23px;cursor:pointer;margin-left:1px;margin-top:12px;background-color:#3b3b3b;color:red;border:1px solid yellow;border-radius:5px;"value="${mycolor}">
  111.  
  112. <div id="greasy" title="Data-ora" style="font-size:14px!important;display:inline-block;cursor:pointer;background:#3b3b3b;color:lime;border:1px solid yellow;border-radius:5px;margin:1px;text-align:center;width:max-content;">
  113. </div>
  114. <label title="Cambia 12/24h" style="cursor:pointer">
  115. <input type="radio" name="options" title="Cambia 12/24h" value="toggleFormat" style="cursor:pointer;">12/24h
  116. </label>
  117. <span class="button" title="Chiudi" id='close' style="background:chocolate;color:lime;border:1px solid yellow;border-radius:50%;cursor:pointer;font-size:14px;padding:3px 6px;display:inline-block;line-height:16px;margin-top:-19px;margin-left:1px;">X</span>
  118.  
  119. </fieldset>
  120. `;
  121. // Event listener for radio button selection
  122. $('input[name="options"]').on('change', function() {
  123. const selectedValue = $(this).val();
  124. if (selectedValue === 'toggleFormat') {
  125. toggleFormat();
  126. }
  127.  
  128. // Disable the radio buttons temporarily
  129. $('input[name="options"]').prop('disabled', true);
  130.  
  131. // Re-enable the radio buttons after a short delay
  132. setTimeout(() => {
  133. $('input[name="options"]').prop('disabled', false).prop('checked', false);
  134. }, 300); // Milliseconds
  135. });
  136. // Aggiunta funzione per chiudere il box
  137. var colorinputsetMenuClose = document.querySelector('#close');
  138. colorinputsetMenuClose.addEventListener('click', provagf, false);
  139.  
  140. var colorinput = document.querySelector('#colorinput');
  141. var colorspan = document.querySelector('#colorspan');
  142.  
  143. // Evento della tavolozza dei colori
  144. colorinput.addEventListener('input', function(event) { colorChange(event); }, false);
  145. $('body').css("background-color", mycolor);
  146.  
  147. function colorChange(e) {
  148. mycolor = e.target.value;
  149. colorspan.innerHTML = e.target.value;
  150. $('body').css("background-color", mycolor);
  151. GM_setValue(userdata.color, mycolor);
  152. }
  153. ////////////////////////////////////////////////
  154. function execCopy() {
  155. var code='';
  156. if($(".prettyprint li").length>0)
  157. {
  158. $(".prettyprint li").each(function(){
  159. code += $(this).text()+'\n';
  160. });
  161. }
  162. else {code = $(".prettyprint").text();}
  163.  
  164. code = encodeURI(code)
  165. code = code.replace(/%C2%A0/g,'%20');
  166. code = decodeURI(code);
  167.  
  168. GM_setClipboard(code, 'text');
  169. alert("copiato con successo")
  170. return true;
  171. }
  172.  
  173. //Il collegamento al codice sorgente viene visualizzato dopo il collegamento allo script
  174. $(".script-list h2 a").each(function(){
  175. if(!$(this).next().hasClass("code-link"))
  176. {let short_link = $(this).attr("href");
  177. let $code_link = $('<a target="_blank" a href=\"'+short_link+'/code\" class=\"code-link\">codice</a>');//apre in nuova scheda
  178. $(this).after($code_link);
  179. }
  180. })
  181.  
  182. //////////////////////////////////////////////////////////
  183. GM_addStyle('.source{'+
  184. 'display: inline-block;'+
  185. 'background-color:lime;'+
  186. 'padding: 0.5em 1em;'+
  187. 'color: white;'+
  188. 'text-decoration: none;'+
  189. 'cursor:pointer}'+
  190. '.code-link'+
  191. '{'+
  192. ' margin-left:10px; '+
  193. ' padding-left:2px;'+
  194. ' padding-right:2px; '+
  195. ' font-size:12px; '+
  196. ' background:red; '+
  197. ' color:white!important; '+
  198. ' text-decoration: none;'+
  199. '}');
  200. //////////////////
  201. if(window.location.href.indexOf("/code")!= -1) //code
  202. {var source_btn = $("<a></a>")
  203. source_btn.addClass("source");
  204. source_btn.text("copiare il codice sorgente");
  205. source_btn.click(function(){
  206. execCopy();
  207. });
  208. $("#install-area").after(source_btn);
  209. }
  210. //////////////////////
  211. //passa alla pagina successiva richiede jquery anche sulla pagina degli autori marzo 2024
  212. $(window).scroll(function() {
  213. if($(window).scrollTop() + $(window).height() == $(document).height()) {
  214. document.querySelector("#user-script-list-section > div > a.next_page,body > div.width-constraint > div > div.sidebarred-main-content > div.pagination > a.next_page").click();
  215. }
  216. });
  217.  
  218. //apre i link in nuova scheda maggio 2023
  219. function modifyLinks() {
  220. let links =document.querySelectorAll('#browse-script-list a');
  221. for (let i = 0; i < links.length; i++) {
  222. links[i].setAttribute('target', '_blank');
  223. }
  224.  
  225. }
  226. modifyLinks();
  227. //////////////////////////////////////////////////////////////////////////
  228. //mostra risultati in tutte le lingue
  229. GM_addStyle('a:hover {color: ;background-color: #876b9a;padding: 5px 10px;border-radius: 5px;}');
  230. //scritta greasy fork
  231. GM_addStyle('#main-header {background-color:#5d3e72; background-image: linear-gradient(#412451, #009981); box-shadow: 0 0 15px 2px #000000a1;padding: .25em 0; }');
  232. //menu ordina per colorato
  233. GM_addStyle('.list-option-group ul {background-color:#1eb19c!important;}');
  234. //colore paginazione
  235. GM_addStyle('.pagination > *, .script-list + .pagination > *, .user-list + .pagination > *{background-color:#564062;!important;}');
  236. GM_addStyle('body > div > div > div.sidebarred-main-content > div.pagination > em{background-color:green!important;}');//colore num pag current
  237. 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;}');
  238. GM_addStyle('.width-constraint .pagination {border-radius:10px!important;}');
  239.  
  240. //input casella ricerca script rossa
  241. GM_addStyle('.sidebar-search input{background-color:red!important;}');
  242. //////////////////codice sorgente colorato//////////////////////////////////////////////////////////////
  243. GM_addStyle('pre.prettyprint {background-color:#92ad92!important;border: 2px solid red!important;}');//1 stesso colore
  244. GM_addStyle('li.L1, li.L3, li.L5, li.L7, li.L9 {background-color:#92ad92!important;}');//2 stesso colore
  245. /////////////////////////////////////////////////////////////////////////////////////////////////////////
  246. //////////////////////mostra numero 1,2,3ecc accanto agli script
  247. //Funzione 1: Stile ed evidenziazione degli script utente
  248. function applyStylesAndHighlight() {
  249. const page = +new URLSearchParams(document.location.search).get('page') || 1;
  250. const q = `<style>
  251. #browse-script-list{counter-reset: section ${(page-1)*50};}
  252. .ad-entry{height:0;overflow:hidden;}
  253. #browse-script-list li{position:relative}
  254. .Finn{background:gold;}
  255. .ad-entry{display:none}
  256. #browse-script-list li:after{
  257. counter-increment: section;
  258. content:counter(section);
  259. font:bold 20px/30px Arial;
  260. background:red;
  261. color:green;
  262. position:absolute;
  263. bottom:8px;
  264. right:15px
  265. }
  266. </style>`;
  267. document.documentElement.insertAdjacentHTML('afterbegin', q);
  268.  
  269. const a = document.querySelector(".user-profile-link a")?.href; // Utilizzare il concatenamento facoltativo
  270. if (a) { // Procedere solo se a è definito
  271. document.querySelectorAll("#browse-script-list li").forEach(function(i) {
  272. const b = i.querySelector("dd.script-list-author a");
  273. if (b && b.href === a) {
  274. i.className = 'Finn';
  275. }
  276. });
  277. }
  278. }
  279.  
  280. //Funzione 2: Aggiungere la numerazione all'elenco degli script utente nelle pagine utente
  281. function addNumberingToUserScripts() {
  282. if (window.location.href.includes("/users/")) {
  283. const scriptList = document.querySelectorAll('.script-list > li');
  284.  
  285. if (scriptList) {
  286. scriptList.forEach((script, index) => {
  287. const numberSpan = document.createElement('span');
  288. numberSpan.style.marginRight = '5px';
  289. numberSpan.style.fontWeight = 'bold';
  290. numberSpan.style.background = 'red';
  291. numberSpan.style.color = 'green';
  292. numberSpan.textContent = `${index + 1}`;
  293. script.insertBefore(numberSpan, script.firstChild);
  294. });
  295. }
  296. }
  297. }
  298.  
  299. // Chiama entrambe le funzioni
  300. applyStylesAndHighlight();
  301. addNumberingToUserScripts();
  302.  
  303. //autoclick casella editor checkbox
  304. const checkbox = document.querySelector("#enable-source-editor-code")
  305. if (checkbox.checked === false) {
  306. checkbox.click();
  307. }
  308.  
  309. })();