Last active
May 11, 2022 17:46
-
-
Save smrq/e59125ffaa519002617a375cd043e3ef to your computer and use it in GitHub Desktop.
Custom Redactles
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Custom Redactles | |
// @namespace https://gist.github.com/smrq/e59125ffaa519002617a375cd043e3ef | |
// @version 0.1 | |
// @description Adds a menu bar item for custom Redactles | |
// @author You | |
// @match https://www.redactle.com/ | |
// @icon https://www.google.com/s2/favicons?sz=64&domain=redactle.com | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
/* global baffled:writable, guessedWords:writable, guessCounter:writable, hitCounter:writable, currentAccuracy:writable, pageRevealed:writable, ansStr, RevealPage, fetchData */ | |
async function LoadCustom(game) { | |
if (!game || '') return; | |
var winText = document.getElementById("winText"); | |
var userGuess = document.getElementById('userGuess'); | |
var guessLogBody = document.getElementById('guessLogBody'); | |
window.SaveProgress = function SaveProgress() {} | |
window.WinRound = function WinRound(){ | |
document.getElementById("userGuess").disabled = true; | |
if(!pageRevealed){ | |
RevealPage(); | |
} | |
winText.innerHTML = `<h3>Congratulations, you solved this custom Redactle!</h3><ul><li>The answer was: ${ansStr}</li><li>You solved it in ${guessedWords.length} guesses</li><li>Your accuracy was ${currentAccuracy}%</li></ul>`; | |
winText.style.display = 'block'; | |
winText.style.height = 'auto'; | |
document.getElement | |
} | |
baffled = []; | |
guessedWords = []; | |
guessCounter = 0; | |
hitCounter = 0; | |
currentAccuracy = -1; | |
pageRevealed = false; | |
userGuess.disabled = false; | |
winText.innerHTML = ''; | |
// Keep hiding win text when vic.php is slow and returns after loading a custom game | |
winText.style.height = 0; | |
winText.style.overflow = 'hidden'; | |
guessLogBody.innerHTML = ''; | |
await fetchData(false, game); | |
} | |
window.LoadCustomPopup = function LoadCustomPopup() { | |
var game = prompt('Enter a game code (base64 format)'); | |
LoadCustom(game); | |
} | |
var customNavItem = document.createElement('li'); | |
customNavItem.className = 'nav-item' | |
customNavItem.innerHTML = '<a class="nav-link mx-2" href="javascript:LoadCustomPopup()">Custom</a>'; | |
document.querySelector('ul.navbar-nav').appendChild(customNavItem); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment