User:WikiMacaroons/cinnamon.js

/* CinnamonTalk 1.0 Source by WikiMacaroons

Read at your own peril. orun = mw.user.getName; orun = orun.replace(/ /g, '_'); prefpage = "User:"+orun+"/CinnamonPrefs"; new mw.Api.get( {    action: "query",     titles: [ prefpage ], } ).then( function( ret ) {     $.each( ret.query.pages, function { if ( this.missing !== "" ) { doCinnamon; } else { addprefs; }   } ); }, function( error ) { } ); function addprefs{ alert("Loading CinnamonTalk Assets..."); var params = { action: 'edit', title: prefpage, prependtext: 'Hello', summary: 'Automatically created preferences page using CinnamonTalk.', format: 'json' },		api = new mw.Api; api.postWithToken( 'csrf', params ).done( function ( data ) {		//alert( data );	} ); alert("Done!"); } function doCinnamon{ donecon = 0; if(document.getElementById("firstHeading").textContent.substring(0, 5) === "Talk:" ||document.getElementById("firstHeading").textContent.substring(0, 10) === "User talk:"){ const newcss = ` .boxed { border: 2px solid gold ; }		`;		document.documentElement.innerHTML = newcss+document.documentElement.innerHTML; firstcon = document.documentElement.innerHTML.toString; if(donecon === 0){ firsthead = firstcon.indexOf('<span class="mw-headline"'); sechead = firstcon.indexOf('<span class="mw-headline"', firsthead + 1); newcon = firstcon.substring(firsthead, (sechead-4)); pgraph = newcon.indexOf(" "); talkp = newcon.substring(pgraph, newcon.length); firstmes = talkp.substring(0, talkp.indexOf(" ")+4); upindex = firstmes.indexOf('title=User:'); userstr = firstmes.substring(upindex, firstmes.length); doneu = 0; cuchar = 11; username = ""; while(doneu === 0){ mini = cuchar + 1; minii = cuchar + 2; miniii = cuchar + 3; if(userstr[cuchar] === "&" && userstr[mini] === "a" && userstr[minii] === "m" && userstr[miniii] === "p"){ doneu = 1; }				else{ username = username+userstr[cuchar]; cuchar += 1; }			}			username = username.replace(/ /g, '_'); changemes = " "+username+""+firstmes+" "; newmes = document.documentElement.innerHTML.toString.replace(firstmes, changemes); document.documentElement.innerHTML = newmes; nextmesid = talkp.indexOf(""); nextmesfull = talkp.substring(nextmesid, talkp.length); donep = 0; var msgs = []; while(donep === 0){ if(nextmesfull.includes("(UTC)")){ nextmes = nextmesfull.substring(4, nextmesfull.indexOf("(UTC)")+5); msgs.push(nextmes); nextmesfull = nextmesfull.replace(nextmes, ""); upindex = nextmes.indexOf('title=User:'); userstr = nextmes.substring(upindex, nextmes.length); doneu = 0; cuchar = 11; username = ""; while(doneu === 0){ mini = cuchar + 1; minii = cuchar + 2; miniii = cuchar + 3; if(userstr[cuchar] === "&" && userstr[mini] === "a" && userstr[minii] === "m" && userstr[miniii] === "p"){ doneu = 1; }						else{ username = username+userstr[cuchar]; cuchar += 1; }					}					username = username.replace(/ /g, '_'); changemes = " "+username+""+nextmes+" "; newmes = document.documentElement.innerHTML.toString.replace(nextmes, changemes); document.documentElement.innerHTML = newmes; }				else{ donep = 1; }			}			//Underneath here /*			nextmes = nextmesfull.substring(4, nextmesfull.indexOf("(UTC)")+5); newmes = document.documentElement.innerHTML.toString.replace(nextmes, " "+nextmes+" "); document.documentElement.innerHTML = newmes; nextmes = nextmesfull.substring(nextmesfull.indexOf("(UTC)")+5, nextmesfull.length); alert(nextmes); if(nextmes.includes("")){ nextmes = nextmes.substring(0, nextmes.length - 21); }			else{ nextmes = nextmes.substring(0, nextmes.length - 11); }			newmes = document.documentElement.innerHTML.toString.replace(nextmes, " "+nextmes+" "); document.documentElement.innerHTML = newmes; */		}	} }