Greasy Fork Theme figuccio

Greasy Fork pagina colorata

当前为 2022-10-25 提交的版本,查看 最新版本

  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. // @version 4.4
  8. // @noframes
  9. // @author figuccio
  10. // @grant GM_addStyle
  11. // @grant GM_setValue
  12. // @grant GM_getValue
  13. // @grant GM_registerMenuCommand
  14. // @match *://greasyfork.org/*/script_versions/new*
  15. // @match *://greasyfork.org/*/scripts/*/versions/new*
  16. // @require https://gitcdn.link/repo/fuzetsu/userscripts/b38eabf72c20fa3cf7da84ecd2cefe0d4a2116be/wait-for-elements/wait-for-elements.js
  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.12.1/jquery-ui.js
  22. // @license MIT
  23. // ==/UserScript==
  24. // Show vertical scrollbar
  25. GM_addStyle('body {overflow-y: scroll!important;}');
  26.  
  27. //menu ordina per colorato
  28. GM_addStyle('.list-option-group ul {background-color:#1eb19c!important;}');
  29. //colore paginazione
  30. GM_addStyle('.pagination > *, .script-list + .pagination > *, .user-list + .pagination > *{background-color:rgb(19, 19, 19)!important;}');
  31. GM_addStyle('body > div > div > div.sidebarred-main-content > div.pagination > em{background-color:green!important;}');//colore num pag current
  32. 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;}');
  33. GM_addStyle('.width-constraint .pagination {border-radius:10px!important;}');
  34.  
  35. //input casella ricerca script rossa
  36. GM_addStyle('.sidebar-search input{background-color:red!important;}');
  37. //colore parte centrale
  38. GM_addStyle('.script-list{background-color:#d4c515d1!important;}');
  39. //mostra risultato per tutte le lingue
  40. if (document.URL == "https://greasyfork.org/it/scripts") window.location.href = "https://greasyfork.org/it/scripts?filter_locale=0";
  41. if (document.URL == "https://sleazyfork.org/it/scripts" ) window.location.href = "https://sleazyfork.org/it/scripts?filter_locale=0";
  42. /////////////autoclick casella editor checkbox
  43. (() => {
  44. 'use strict';
  45. waitForElems({
  46. sel: '#enable-source-editor-code',
  47. stop: true,
  48. onmatch(checkbox) {
  49. checkbox.click();
  50. }
  51. });
  52. })();
  53.  
  54. //colore nero descrizione script necessario perche se no lo scroll dark lo fara vedere bianco e non si vedra
  55. GM_addStyle('body, input, select {color:black!important;}');
  56. //////////////////codice sorgente colorato//////////////////////////////////////////////////////////////
  57. GM_addStyle('pre.prettyprint {background-color:#92ad92!important;border: 2px solid red!important;}');//1 stesso colore
  58. GM_addStyle('li.L1, li.L3, li.L5, li.L7, li.L9 {background-color:#92ad92!important;}');//2 stesso colore
  59. /////////////////////////////////////////////////////////////////////////////////////////////////////////
  60. //parte superiore codice sorgente colorata
  61. GM_addStyle('#script-info {border: 2px solid blue!important;background-color:aquamarine!important;}');
  62. //scrool dark
  63. var meta = document.createElement('meta');
  64. meta.name = "color-scheme";
  65. meta.content = "light dark";
  66. document.getElementsByTagName('head')[0].appendChild(meta);
  67. ///////////////////////////////////////////////scorrimento automatico pagine////////////
  68. (function() {
  69. // L'ID predefinito è 0
  70. var curSite = {SiteTypeID: 0};
  71. // Regole di cambio pagina automatiche
  72. let DBSite = {
  73. postslist: {
  74. SiteTypeID: 1,
  75. pager: {
  76. type: 1,
  77. nextLink: '//a[@class="next_page"][@href]',
  78. pageElement: 'css;ol#browse-script-list > li',
  79. HT_insert: ['css;ol#browse-script-list', 3],
  80. replaceE: 'css;.pagination',
  81. scrollDelta: 1000
  82. }
  83. }
  84. };
  85. // Utilizzato per determinare il tipo di URL corrente all'interno dello script
  86. let SiteType = {
  87. POSTSLIST: DBSite.postslist.SiteTypeID
  88. };
  89.  
  90. curSite = DBSite.postslist;
  91. curSite.pageUrl = ""; // URL della pagina successiva
  92. pageLoading();//Volta pagina automatica
  93.  
  94. // Volta pagina automatica
  95. function pageLoading() {
  96. if (curSite.SiteTypeID > 0){
  97. windowScroll(function (direction, e) {
  98. if (direction === "down") { // Scorri verso il basso per prepararti a voltare pagina
  99. var scrollTop = document.documentElement.scrollTop || window.pageYOffset || document.body.scrollTop;
  100. let scrollDelta = 1299;
  101. if (document.documentElement.scrollHeight <= document.documentElement.clientHeight + scrollTop + scrollDelta) {
  102. ShowPager.loadMorePage();
  103. }
  104. }
  105. });
  106. }
  107. }
  108.  
  109. // evento della barra di scorrimento
  110. function windowScroll(fn1) {
  111. var beforeScrollTop = document.documentElement.scrollTop,
  112. fn = fn1 || function () {};
  113. setTimeout(function () { //Ritarda l'esecuzione per evitare di attivare gli eventi di capovolgimento della pagina subito dopo il caricamento della pagina
  114. window.addEventListener("scroll", function (e) {
  115. var afterScrollTop = document.documentElement.scrollTop,
  116. delta = afterScrollTop - beforeScrollTop;
  117. if (delta == 0) return false;
  118. fn(delta > 0 ? "down" : "up", e);
  119. beforeScrollTop = afterScrollTop;
  120. }, false);
  121. }, 1000)
  122. }
  123.  
  124. var ShowPager = { // Modificato da https://greasfork.org/scripts/14178
  125. getFullHref: function (e) {
  126. if(e == null) return '';
  127. "string" != typeof e && (e = e.getAttribute("href"));
  128. var t = this.getFullHref.a;
  129. return t || (this.getFullHref.a = t = document.createElement("a")), t.href = e, t.href;
  130. },
  131. createDocumentByString: function (e) {
  132. if (e) {
  133. if ("HTML" !== document.documentElement.nodeName) return (new DOMParser).parseFromString(e, "application/xhtml+xml");
  134. var t;
  135. try {
  136. t = (new DOMParser).parseFromString(e, "text/html");
  137. } catch (e) {
  138. }
  139. if (t) return t;
  140. if (document.implementation.createHTMLDocument) t = document.implementation.createHTMLDocument("ADocument"); else try {
  141. (t = document.cloneNode(!1)).appendChild(t.importNode(document.documentElement, !1)),
  142. t.documentElement.appendChild(t.createElement("head")), t.documentElement.appendChild(t.createElement("body"));
  143. } catch (e) {
  144. }
  145. if (t) {
  146. var r = document.createRange();
  147. r.selectNodeContents(document.body);
  148. var n = r.createContextualFragment(e);
  149. t.body.appendChild(n);
  150. for (var a, o = {
  151. TITLE: !0,
  152. META: !0,
  153. LINK: !0,
  154. STYLE: !0,
  155. BASE: !0
  156. }, i = t.body, s = i.childNodes, c = s.length - 1; c >= 0; c--) o[(a = s[c]).nodeName] && i.removeChild(a);
  157. return t;
  158. }
  159. } else console.error("Nessuna stringa trovata da convertire in DOM");
  160. },
  161. loadMorePage: function () {
  162. if (curSite.pager) {
  163. let curPageEle = getElementByXpath(curSite.pager.nextLink);
  164. var url = this.getFullHref(curPageEle);
  165.  
  166. if(url === '') return;
  167. if(curSite.pageUrl === url) return;// Non ricarica la stessa pagina
  168. curSite.pageUrl = url;
  169. //Leggi la prossima pagina di dati
  170. curSite.pager.startFilter && curSite.pager.startFilter();
  171. GM_xmlhttpRequest({
  172. url: url,
  173. method: "GET",
  174. timeout: 5000,
  175. onload: function (response) {
  176. try {
  177. var newBody = ShowPager.createDocumentByString(response.responseText);
  178. let pageElems = getAllElements(curSite.pager.pageElement, newBody, newBody);
  179. let toElement = getAllElements(curSite.pager.HT_insert[0])[0];
  180. if (pageElems.length >= 0) {
  181. let addTo = "beforeend";
  182. if (curSite.pager.HT_insert[1] == 1) addTo = "beforebegin";
  183. // Inserisci un nuovo elemento di pagina
  184. pageElems.forEach(function (one) {
  185. toElement.insertAdjacentElement(addTo, one);
  186. });
  187. // sostituire l'elemento da sostituire
  188. try {
  189. let oriE = getAllElements(curSite.pager.replaceE);
  190. let repE = getAllElements(curSite.pager.replaceE, newBody, newBody);
  191. if (oriE.length === repE.length) {
  192. for (var i = 0; i < oriE.length; i++) {
  193. oriE[i].outerHTML = repE[i].outerHTML;
  194. }
  195. }
  196. } catch (e) {
  197. console.log(e);
  198. }
  199. }
  200. } catch (e) {
  201. console.log(e);
  202. }
  203. }
  204. });
  205. }
  206. },
  207. };
  208.  
  209.  
  210. function getElementByXpath(e, t, r) {
  211. r = r || document, t = t || r;
  212. try {
  213. return r.evaluate(e, t, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  214. } catch (t) {
  215. return void console.error("无效的xpath");
  216. }
  217. }
  218.  
  219.  
  220. function getAllElements(e, t, r, n, o) {
  221. let getAllElementsByXpath = function(e, t, r) {
  222. return r = r || document, t = t || r, r.evaluate(e, t, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  223. }
  224.  
  225. var i, s = [];
  226. if (!e) return s;
  227. 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) {
  228. return (t || document).querySelectorAll(e);
  229. }(e.slice(4), t) : getAllElementsByXpath(e, t, r); else {
  230. if (!(i = e(r, n, o))) return s;
  231. if (i.nodeType) return s[0] = i, s;
  232. }
  233. return function makeArray(e) {
  234. var t, r, n, o = [];
  235. if (e.pop) {
  236. for (t = 0, r = e.length; t < r; t++) (n = e[t]) && (n.nodeType ? o.push(n) : o = o.concat(makeArray(n)));
  237. return a()(o);
  238. }
  239. if (e.item) {
  240. for (t = e.length; t;) o[--t] = e[t];
  241. return o;
  242. }
  243. if (e.iterateNext) {
  244. for (t = e.snapshotLength; t;) o[--t] = e.snapshotItem(t);
  245. return o;
  246. }
  247. }(i);
  248. }
  249. })();
  250.  
  251. ///////////////////////// color picker
  252. (function() {
  253. 'use strict';
  254. var $ = window.jQuery;
  255. var j = $.noConflict();
  256. var body=document.body;
  257. var style=" position:absolute;top:-10px;left:650px;background:;z-index: 99999;"
  258. var box=document.createElement("div");
  259.  
  260.  
  261. box.id="mytema";
  262. box.style=style;
  263. j(box).draggable();
  264. body.append(box);
  265.  
  266.  
  267. function prova(){
  268. if(mytema.style.display = (mytema.style.display!='none') ? 'none' : 'block');}
  269. GM_registerMenuCommand("nascondi/mostra box",prova);
  270. ///////////////////////////////test funzione chiudi menu da close funziona
  271. function myFunction() {
  272. document.getElementById("mytema").style.display = "none";
  273. }
  274.  
  275. /////////////////////////////////////////////////////////////////////
  276. //dati per la conservazione
  277. var userdata = { color: 'theme',}
  278. var mycolor;//dichiarare la variabile colore
  279.  
  280. //imposta la variabile del colore
  281. if(/^#+\w+$/.test(GM_getValue(userdata.color))){mycolor = GM_getValue(userdata.color); }
  282.  
  283. else { mycolor="#000000";}
  284. ///////////////////////////////////////////////////////////
  285. //Imposta lo stile CSS degli elementi nel menu
  286. GM_addStyle(`
  287. #myMenu {
  288. font-family: Helvetica, 'Hiragino Sans GB', 'Microsoft Yahei', Arial, sans-serif;
  289. font-size: 14px;
  290. z-index: 2147483648;
  291. }
  292. .button {
  293. padding: 3px 6px;
  294. line-height: 16px;
  295. margin-top:-19px;
  296. display: inline-block;
  297. border: 1px solid black;
  298. border-radius: 3px;
  299. cursor: pointer;
  300. background:chocolate;
  301.  
  302. }
  303.  
  304. #colorspan { margin-left:1px; margin-bottom:-19px;}
  305.  
  306. #seletcolor{margin-top:-47px; margin-left:5px;}
  307.  
  308. #setui{
  309. width:auto;
  310. height:55px;
  311. margin-top:0px;
  312. margin-left:0px;
  313. margin-right:0px;
  314. margin-bottom:0px;
  315. background-color:#293446;
  316. border-width:1px;
  317. border-style: solid;
  318. color:lime;
  319.  
  320. }
  321.  
  322. #colorinput{ margin-left:4px; margin-top:11px;}
  323. #code{ color:lime;background-color:brown; border: 2px solid green;}
  324. `);
  325. //elemento html nel div
  326. box.innerHTML=`
  327. </p>
  328. <fieldset style="background:green; border: 2px solid red;color:lime;border-radius:7px;">
  329. <legend>Select Color</legend>
  330. <div id=setui>
  331. <button id="code">${mycolor}</button> color picker <input type="color" list="colors" id="colorinput" value="${mycolor}" title="color picker" oninput= "document.getElementById('code').innerHTML = this.value;">
  332. <span class="button" title="chiudi" id='close'>close</span>
  333. <datalist id="colors">
  334. <option value="#000000">
  335. <option value="#404040">
  336. <option value="#808080">
  337. <option value="#c0c0c0">
  338. <option value="#FFFFFF">
  339. <option value="#980000">
  340. <option value="#FF0000">
  341. <option value="#FF9900">
  342. <option value="#FFFF00">
  343. <option value="#00FF00">
  344. <option value="#00FFFF">
  345. <option value="#4a86e8">
  346. <option value="#0000FF">
  347. <option value="#9900ff">
  348. <option value="#ff00ff">
  349. <option value="#003f00">
  350. <option value="#ff7200">
  351. <option value="#9e6600">
  352. <option value="#d1754e">
  353. <option value="#ffcdb2">
  354. <option value="#2d6a4f">
  355. <option value="#ff5d8f">
  356. <option value="#f0efeb">
  357. <option value="#f8f9fa">
  358. <option value="#57060c">
  359. <option value="#9d6b53">
  360. <option value="#01fe94">
  361. <option value="#333922">
  362. <option value="#f9dcc4">
  363. <option value="#1b4332">
  364.  
  365. </datalist>
  366.  
  367. </p>
  368. </div>
  369. </fieldset>
  370. `;
  371.  
  372. //////////////////////////////
  373. //aggiunta span close per chiudere il box direttamente
  374. var colorinputsetMenuClose=document.querySelector('#close');
  375. colorinputsetMenuClose.addEventListener('click',myFunction,false);
  376.  
  377. ////////////////////////////////////////
  378. var colorinput=document.querySelector('#colorinput');
  379. var colorspan = document.querySelector('#colorspan');
  380. ////////////////////////////////////////
  381. //evento della tavolozza dei colori
  382. function colorChange (e) {
  383. mycolor = e.target.value;
  384. colorspan.innerHTML=e.target.value;
  385. }
  386.  
  387. colorinput.addEventListener('input', function(event){colorChange(event)},false);
  388. $('body').css("background-color", mycolor);
  389. document.getElementById('colorinput').value =mycolor;
  390. colorinput.addEventListener('input', function(){
  391. GM_setValue(userdata.color, mycolor);
  392. console.log(this.value);
  393.  
  394. $('body').css("background-color",mycolor);
  395. });
  396.  
  397. })();
  398. //////////////////////