====== Script Greasemonkey per il FdT ====== Grazie a [[https://addons.mozilla.org/it/firefox/addon/748|greasemonkey]] è possibile personalizzare il funzionamento del FdT, grazie a javascript è infatti possibile accedere al [[struttura_dei forum|DOM della pagina]] e modificarne gli attributi. * [[script_greasemonkey#script base]] * [[script_greasemonkey#repository]] ===== Repository ===== E' stato creato un [[http://fdt.dev.kom.pl/|Repository per gli script]] e le estensioni del FdT, in particolare si veda l'apposita [[http://fdt.dev.kom.pl/b/|board di sviluppo]]. ===== Script base ===== Dopo la correzione del [[lista_dei_bug|bug //Achille97//]] la redazione di PI ha implementato la visualizzazione dei filmati youtube anche sul FdT, pertanto lo script base è considerato //superato//. Viene qui riportato a fini didattici: // ==UserScript== // @name FDT // @namespace http://forumdeitroll.it // @description FDT Enhancer (versione 0.5) // @include http://*.forumdeitroll.it/* // ==/UserScript== // FDT // Copyright (C) 2008 Wakko Warner (http://thewakkowarner.netsons.org/) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see . //----------------------------------------------------------------- //---------------------------- OPZIONI ---------------------------- //----------------------------------------------------------------- var ytTimeout = 1000; var colorTimeout = 500; var colori = true; //Se impostato a false mostrerà la parte quotata in grigetto //----------------------------------------------------------------- //------------------------- FINE OPZIONI -------------------------- //----------------------------------------------------------------- var Url = document.URL; //Non usato per ora //Cerchiamo il TD del contenuto var td = document.getElementsByTagName("td"); var tr = document.getElementsByTagName("tr"); var tdcontent = null; var tdaction = null; var i = 0; for (c=0; c<(td.length); c++) { if ((td[c].className == "content")) { tdcontent = td[c]; if (i==1) { break; } i++; } } for (c=0; c<(tr.length); c++) { if ((tr[c].className == "paginazione")) { tdaction = tr[c].firstChild.nextSibling.nextSibling.nextSibling; break; } } if (tdcontent != null) { //Se al passo precedente l'ho trovato... iframe = document.createElement("iframe"); iframe.innerHTML = "Non puo' essere che il tuo FF non supporti gli iFrame :/"; iframe.src = ""; iframe.setAttribute("style","width: 100%; height: 23em; display: none;"); iframe.id = "motorino"; tdcontent.insertBefore(iframe, tdcontent.firstChild); if (tdaction != null) { tdaction.innerHTML = "Mostra Motorino | FDT-Chat | " + tdaction.innerHTML; } } //Gestione Youtube var body = document.getElementsByTagName("body")[0]; var ytscript = document.createElement("script"); ytscript.innerHTML="function youtube() {\n var body = document.getElementsByTagName(\"body\")[0];\n var div = document.getElementsByTagName(\"div\");\n for(c=0; c<(div.length); c++) {\n if ((div[c].parentNode.nodeName==\"TD\") && (div[c].innerHTML.match(/\\[yt\\]((.){11})\\[\\/yt\\]/g) != null)) {\n div[c].innerHTML = div[c].innerHTML.replace(/\\[yt\\]((.){11})\\[\\/yt\\]/g, '');\n }\n }\n}\n"; body.appendChild(ytscript); setTimeout('youtube()', ytTimeout); //Gestione Colori var colorizescript = document.createElement("script"); var colorstring = ""; if (colori) { colorstring = " level1 = \"#007BDF\";\n level2 = \"#00AF59\";\n level3 = \"#9A00EF\";\n level4 = \"#AF6F00\";\n"; } else { colorstring = " level1 = \"#9F9F9F\";\n level2 = \"#9F9F9F\";\n level3 = \"#9F9F9F\";\n level4 = \"#9F9F9F\";\n"; } colorizescript.innerHTML = "function colorize() {\n" + colorstring + " div = document.getElementsByTagName('div');\n for (c=0; c<(div.length); c++) {\n if ((div[c].parentNode.className == \"funcbarthread\")) { myhtml = div[c].innerHTML;\n myhtmlarray = myhtml.split(\"
\");\n myhtml = \"\";\n for (z=0; z<(myhtmlarray.length); z++) {\n if (myhtmlarray[z].substring(0,19)==\"> > > >\") {\n myhtmlarray[z] = \"\" + myhtmlarray[z] + \"\";\n } else if (myhtmlarray[z].substring(0,14)==\"> > >\") {\n myhtmlarray[z] = \"\" + myhtmlarray[z] + \"\";\n } else if (myhtmlarray[z].substring(0,9)==\"> >\") {\n myhtmlarray[z] = \"\" + myhtmlarray[z] + \"\";\n } else if (myhtmlarray[z].substring(0,4)==\">\") {\n myhtmlarray[z] = \"\" + myhtmlarray[z] + \"\";\n }\n myhtml = myhtml + myhtmlarray[z] + \"
\";\n }\n div[c].innerHTML = myhtml;\n }\n }\n}\n"; body.appendChild(colorizescript); setTimeout('colorize()', colorTimeout);