Skip to content

Instantly share code, notes, and snippets.

@smrq
Last active May 11, 2022 17:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save smrq/e59125ffaa519002617a375cd043e3ef to your computer and use it in GitHub Desktop.
Save smrq/e59125ffaa519002617a375cd043e3ef to your computer and use it in GitHub Desktop.
Custom Redactles
// ==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