Greasy Fork Theme figuccio

Greasy Fork pagina colorata

目前为 2025-03-16 提交的版本,查看 最新版本

  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 9.9
  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;
  38. const j = $.noConflict();
  39. const body = document.body;
  40.  
  41. const style = "position:fixed;top:9px;left:870px;z-index:99999;";
  42. const box = document.createElement("div");
  43.  
  44. box.id = "mytema";
  45. box.style = style;
  46. j(box).draggable();
  47. body.append(box);
  48.  
  49. // Ripristina la posizione salvata se presente
  50. const savedPosition = GM_getValue('boxPosition');
  51. if (savedPosition) {
  52. const parsedPosition = JSON.parse(savedPosition);
  53. $(box).css({ top: parsedPosition.top, left: parsedPosition.left });
  54. }
  55. ////////////////////////////////////////////marzo 2024
  56. // Rendi l'elemento trascinabile con limitazioni di schermo
  57. makeDraggableLimited($(box));
  58. ////////////////////////////
  59. // Mostra/Nascondi con animazione
  60. function provagf() {
  61. var box = document.getElementById('mytema');
  62. $(box).fadeToggle(300); // Animazione per mostrare/nascondere
  63. }
  64. GM_registerMenuCommand("nascondi/mostra box", provagf);
  65.  
  66. // Dati per la conservazione
  67. const userdata = { color: 'theme' };
  68. var mycolor = GM_getValue(userdata.color, "#980000"); // Valore predefinito
  69.  
  70. // Imposta lo stile CSS degli elementi
  71. GM_addStyle(`
  72. #myMenu {
  73. font-family: Helvetica, 'Hiragino Sans GB', 'Microsoft Yahei', Arial, sans-serif;
  74. font-size: px;
  75. z-index: 2147483648;
  76. }
  77. .button {
  78. margin-left: -5px; padding: 3px 6px; line-height: 16px; margin-top: -19px;
  79. display: inline-block; border: 1px solid yellow; border-radius: 3px;
  80. cursor: pointer; background: chocolate;
  81. }
  82. #colorspan {
  83. font-size: 14px; cursor: pointer; margin-left: 1px; margin-bottom: -19px;
  84. color: lime; background-color: brown; border: 1px solid yellow;
  85. }
  86. #setui {
  87. width: auto; height: 25px; margin-top: -10px; margin-left: 0px;
  88. margin-right: 0px; margin-bottom: 0px;
  89. }
  90. #colorinput {
  91. cursor: pointer; height: 20px; margin-left: 4px; margin-top: -10px;
  92. background-color: #3b3b3b; color: red; border: 1px solid yellow; border-radius: 5px;
  93. }
  94. #greasy {
  95. font-size: 14px !important; display: inline-block; cursor: pointer;
  96. background: #3b3b3b; color: lime; border: 1px solid yellow; border-radius: 5px;
  97. margin: 9px; text-align: center; width: max-content;
  98. }
  99. `);
  100.  
  101. setInterval(myTimer,90);
  102. function myTimer() {
  103. var d = new Date();
  104. var t = d.toLocaleTimeString();
  105. var mm = d.getMilliseconds();//millisecondi ottobre 2023
  106. ////////////////short long
  107. var date = new Date().toLocaleString('it', {'weekday': 'short', 'month': '2-digit', 'day': '2-digit','year':'numeric'});
  108. document.getElementById("greasy").innerHTML =date +" "+ t +":"+ mm;
  109. }
  110.  
  111. // Elemento HTML nel div
  112. box.innerHTML = `
  113. <fieldset style="background:#3b3b3b;border:2px solid red;color:lime;border-radius:7px;text-align:center;width:413px;height:43px;">
  114. <legend>Time</legend>
  115. <div id=setui>
  116. <button id="colorspan" title="Hex value">${mycolor}</button>
  117. <input type="color" list="colors" id="colorinput" value="${mycolor}" title="Color picker">
  118. <div id="greasy" title="Data-ora"></div>
  119. <span class="button" title="Chiudi" id="close">X</span>
  120. </div>
  121. </fieldset>
  122. `;
  123.  
  124. // Aggiunta funzione per chiudere il box
  125. var colorinputsetMenuClose = document.querySelector('#close');
  126. colorinputsetMenuClose.addEventListener('click', provagf, false);
  127.  
  128. var colorinput = document.querySelector('#colorinput');
  129. var colorspan = document.querySelector('#colorspan');
  130.  
  131. // Evento della tavolozza dei colori
  132. colorinput.addEventListener('input', function(event) { colorChange(event); }, false);
  133. $('body').css("background-color", mycolor);
  134.  
  135. function colorChange(e) {
  136. mycolor = e.target.value;
  137. colorspan.innerHTML = e.target.value;
  138. $('body').css("background-color", mycolor);
  139. GM_setValue(userdata.color, mycolor);
  140. }
  141. ////////////////////////////////////////////////
  142. function execCopy() {
  143. var code='';
  144. if($(".prettyprint li").length>0)
  145. {
  146. $(".prettyprint li").each(function(){
  147. code += $(this).text()+'\n';
  148. });
  149. }
  150. else {code = $(".prettyprint").text();}
  151.  
  152. code = encodeURI(code)
  153. code = code.replace(/%C2%A0/g,'%20');
  154. code = decodeURI(code);
  155.  
  156. GM_setClipboard(code, 'text');
  157. alert("copiato con successo")
  158. return true;
  159. }
  160.  
  161. //Il collegamento al codice sorgente viene visualizzato dopo il collegamento allo script
  162. $(".script-list h2 a").each(function(){
  163. if(!$(this).next().hasClass("code-link"))
  164. {let short_link = $(this).attr("href");
  165. let $code_link = $('<a target="_blank" a href=\"'+short_link+'/code\" class=\"code-link\">codice</a>');//apre in nuova scheda
  166. $(this).after($code_link);
  167. }
  168. })
  169.  
  170. //////////////////////////////////////////////////////////
  171. GM_addStyle('.source{'+
  172. 'display: inline-block;'+
  173. 'background-color:lime;'+
  174. 'padding: 0.5em 1em;'+
  175. 'color: white;'+
  176. 'text-decoration: none;'+
  177. 'cursor:pointer}'+
  178. '.code-link'+
  179. '{'+
  180. ' margin-left:10px; '+
  181. ' padding-left:2px;'+
  182. ' padding-right:2px; '+
  183. ' font-size:12px; '+
  184. ' background:red; '+
  185. ' color:white!important; '+
  186. ' text-decoration: none;'+
  187. '}');
  188. //////////////////
  189. if(window.location.href.indexOf("/code")!= -1) //code
  190. {var source_btn = $("<a></a>")
  191. source_btn.addClass("source");
  192. source_btn.text("copiare il codice sorgente");
  193. source_btn.click(function(){
  194. execCopy();
  195. });
  196. $("#install-area").after(source_btn);
  197. }
  198. //////////////////////
  199. //passa alla pagina successiva richiede jquery anche sulla pagina degli autori marzo 2024
  200. $(window).scroll(function() {
  201. if($(window).scrollTop() + $(window).height() == $(document).height()) {
  202. 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();
  203. }
  204. });
  205.  
  206. //apre i link in nuova scheda maggio 2023
  207. function modifyLinks() {
  208. let links =document.querySelectorAll('#browse-script-list a');
  209. for (let i = 0; i < links.length; i++) {
  210. links[i].setAttribute('target', '_blank');
  211. }
  212.  
  213. }
  214. modifyLinks();
  215. //////////////////////////////////////////////////////////////////////////
  216. //mostra risultati in tutte le lingue
  217. GM_addStyle('a:hover {color: ;background-color: #876b9a;padding: 5px 10px;border-radius: 5px;}');
  218. //scritta greasy fork
  219. GM_addStyle('#main-header {background-color:#5d3e72; background-image: linear-gradient(#412451, #009981); box-shadow: 0 0 15px 2px #000000a1;padding: .25em 0; }');
  220. //menu ordina per colorato
  221. GM_addStyle('.list-option-group ul {background-color:#1eb19c!important;}');
  222. //colore paginazione
  223. GM_addStyle('.pagination > *, .script-list + .pagination > *, .user-list + .pagination > *{background-color:#564062;!important;}');
  224. GM_addStyle('body > div > div > div.sidebarred-main-content > div.pagination > em{background-color:green!important;}');//colore num pag current
  225. 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;}');
  226. GM_addStyle('.width-constraint .pagination {border-radius:10px!important;}');
  227.  
  228. //input casella ricerca script rossa
  229. GM_addStyle('.sidebar-search input{background-color:red!important;}');
  230. //colore parte centrale
  231. GM_addStyle('.script-list{background-color:#d4c515d1!important;}');
  232. //////////////////codice sorgente colorato//////////////////////////////////////////////////////////////
  233. GM_addStyle('pre.prettyprint {background-color:#92ad92!important;border: 2px solid red!important;}');//1 stesso colore
  234. GM_addStyle('li.L1, li.L3, li.L5, li.L7, li.L9 {background-color:#92ad92!important;}');//2 stesso colore
  235. /////////////////////////////////////////////////////////////////////////////////////////////////////////
  236. //parte superiore codice sorgente colorata
  237. GM_addStyle('#script-info {border: 2px solid blue!important;background-color:#1f504f!important;}');
  238.  
  239. //////////////////////mostra numero 1,2,3ecc accanto agli script
  240. //Funzione 1: Stile ed evidenziazione degli script utente
  241. function applyStylesAndHighlight() {
  242. const page = +new URLSearchParams(document.location.search).get('page') || 1;
  243. const q = `<style>
  244. #browse-script-list{counter-reset: section ${(page-1)*50};}
  245. .ad-entry{height:0;overflow:hidden;}
  246. #browse-script-list li{position:relative}
  247. .Finn{background:gold;}
  248. .ad-entry{display:none}
  249. #browse-script-list li:after{
  250. counter-increment: section;
  251. content:counter(section);
  252. font:bold 20px/30px Arial;
  253. background:red;
  254. color:green;
  255. position:absolute;
  256. bottom:8px;
  257. right:15px
  258. }
  259. </style>`;
  260. document.documentElement.insertAdjacentHTML('afterbegin', q);
  261.  
  262. const a = document.querySelector(".user-profile-link a")?.href; // Utilizzare il concatenamento facoltativo
  263. if (a) { // Procedere solo se a è definito
  264. document.querySelectorAll("#browse-script-list li").forEach(function(i) {
  265. const b = i.querySelector("dd.script-list-author a");
  266. if (b && b.href === a) {
  267. i.className = 'Finn';
  268. }
  269. });
  270. }
  271. }
  272.  
  273. //Funzione 2: Aggiungere la numerazione all'elenco degli script utente nelle pagine utente
  274. function addNumberingToUserScripts() {
  275. if (window.location.href.includes("/users/")) {
  276. const scriptList = document.querySelectorAll('.script-list > li');
  277.  
  278. if (scriptList) {
  279. scriptList.forEach((script, index) => {
  280. const numberSpan = document.createElement('span');
  281. numberSpan.style.marginRight = '5px';
  282. numberSpan.style.fontWeight = 'bold';
  283. numberSpan.style.background = 'red';
  284. numberSpan.style.color = 'green';
  285. numberSpan.textContent = `${index + 1}`;
  286. script.insertBefore(numberSpan, script.firstChild);
  287. });
  288. }
  289. }
  290. }
  291.  
  292. // Chiama entrambe le funzioni
  293. applyStylesAndHighlight();
  294. addNumberingToUserScripts();
  295.  
  296. //autoclick casella editor checkbox
  297. const checkbox = document.querySelector("#enable-source-editor-code")
  298. if (checkbox.checked === false) {
  299. checkbox.click();
  300. }
  301.  
  302. })();