User:Robloxian493/WikiCLI95
From Progressbar95 Wiki
To get started, paste this following code into your developer console:
// WikiCLI95 DEV by Leukocyte // Version: 0.9.7.2 // this script was made a long time ago (june 2022) and the final version was v0.9.5, but now im updating it again, so enjoy! (function() { // defining variables var gameelement = document.getElementsByClassName("wikicli95")[0]; // the div element containg the class "wikicli95", only supports the first element with the class var allsegments = ["Blue", "Cyan 2x", "Cyan 3x", "Yellow", "Red", "Pink", "Gray", "Green", "Random"]; var rawprogress = ""; // the raw data of your progress, which will be converted to a readable string later var segment = ""; // for later var level = 1; // defining functions function random(min, max) { return Math.floor(Math.random() * (max - min) ) + min; } function getRandomSegment() { if (rawprogress.length >= 20) { endGame(true); } segment = allsegments[random(0, allsegments.length)]; // get a random segment if (segment == "Green") { // using the same algorithim progresscli95 uses to make green segments rarer if (random(0, 250) == 95) { console.log('Green segment!'); } else { return getRandomSegment(); // reroll segment } } var returnedhtml = ""; switch (segment) { // convert the segment into a html element with the corresponding colour case "Blue": returnedhtml = '<font color="blue">Blue</font>'; break; case "Cyan 2x": returnedhtml = '<font color="cyan">Cyan 2x</font>'; break; case "Cyan 3x": returnedhtml = '<font color="cyan">Cyan 3x</font>'; break; case "Yellow": returnedhtml = '<font color="orange">Yellow</font>'; break; case "Red": returnedhtml = '<font color="red">Red</font>'; break; case "Pink": returnedhtml = '<font color="pink">Pink</font>'; break; case "Gray": returnedhtml = '<font color="gray">Gray</font>'; break; case "Green": returnedhtml = '<font color="green">Green</font>'; break; case "Random": returnedhtml = '<span style="background-image: linear-gradient(to right, blue, cyan, cyan, yellow, red, pink, gray, green); -webkit-background-clip: text; color: transparent;">Random</span>'; break; default: returnedhtml = '<font>Invalid segment.</font>'; break; } segmentcontainer.innerHTML = "<b>Segment:</b> " + returnedhtml; } function endGame(won) { // end the game with either "you won" or "you lose" if (won) { mw.notify("You won! Continuing to the next level...", {type: "success"}); level++; levelcontainer.innerHTML = "<b>Your level:</b> " + level; rawprogress = ""; getRandomSegment(); // restart the game progresscontainer.innerHTML = "<b>Your progress:</b> " + rawToReadable(); } else { mw.notify("You lose! Refresh the page to play again.", {type: "error"}); catchbtn.disabled = "disabled"; avoidbutton.disabled = "disabled"; } } function catchSegment() { switch (segment) { // get the segment, and add progress to the progress bar, depending on what segment it is, or do something else case "Blue": rawprogress += "B"; getRandomSegment(); break; case "Cyan 2x": rawprogress += "B"; rawprogress += "B"; getRandomSegment(); break; case "Cyan 3x": rawprogress += "B"; rawprogress += "B"; rawprogress += "B"; getRandomSegment(); break; case "Yellow": rawprogress += "Y"; getRandomSegment(); break; case "Red": rawprogress = "RRRRRRRRRRRRRRRRRRRR"; endGame(false); break; case "Pink": // remove the last segment in the progress bar rawprogress.slice(0, -1); getRandomSegment(); break; case "Gray": // add nothing to the progress bar getRandomSegment(); break; case "Green": rawprogress = "GGGGGGGGGGGGGGGGGGGG"; endGame(true); break; case "Random": segment = allsegments[random(0, allsegments.length)]; catchSegment(); getRandomSegment(); break; default: console.error("Invalid segment."); break; } progresscontainer.innerHTML = "<b>Your progress:</b> " + rawToReadable(); } function rawToReadable() { // convert the raw progress to a colourized progress bar var progressbar = "["; // colourized progress bar for (var i in rawprogress) { // iterate over the raw progress var char = rawprogress[i]; switch (char) { // add segments to the progress bar, depending on what it is, and colourize them case "B": progressbar += "<font color='blue'>#</font>"; break; case "Y": progressbar += "<font color='orange'>#</font>"; // yellow isn't gonna display well on bright themes sorry break; case "G": progressbar += "<font color='green'>#</font>"; break; case "R": progressbar += "<font color='red'>#</font>"; break; default: progressbar += "<font color='gray'>?</font>"; break; } } progressbar += "]"; return progressbar; } // startup code if (gameelement) { console.log("Welcome to WikiCLI95!"); } else { throw new Error("No game element was found."); // halt script execution } console.log("Setting up the game..."); gameelement.innerHTML = ""; // get rid of the notice var levelcontainer = document.createElement("span"); // level indicator levelcontainer.innerHTML = "<b>Your level:</b> " + level; gameelement.appendChild(levelcontainer); gameelement.appendChild(document.createElement("br"));// new line var progresscontainer = document.createElement("span"); // progress bar progresscontainer.innerHTML = "<b>Your progress:</b> " + rawToReadable(); gameelement.appendChild(progresscontainer); gameelement.appendChild(document.createElement("br")); // new line var segmentcontainer = document.createElement("span"); // segment teller gameelement.appendChild(segmentcontainer); gameelement.appendChild(document.createElement("br"));// new line var catchbtn = document.createElement("button"); // catch button catchbtn.textContent = "Catch"; catchbtn.onclick = catchSegment; gameelement.appendChild(catchbtn); gameelement.append(" "); // button spacing var avoidbutton = document.createElement("button"); // avoid button avoidbutton.textContent = "Shy Away"; avoidbutton.onclick = getRandomSegment; gameelement.appendChild(avoidbutton); console.log("DONE!"); getRandomSegment(); // start the game console.log("Game started."); })();