-
-
Save thisisparker/f53bede9a7685da9470affedee935f15 to your computer and use it in GitHub Desktop.
Newsday Saturday Stumper AcrossLite Grid Parser
This file contains hidden or 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
// Instructions: | |
// Open the Newsday Saturday Stumper in Firefox: https://www.newsday.com/entertainment/extras/crossword-puzzle-1.6375288 | |
// Click on your selected puzzle to navigate to the puzzle page. | |
// Right-click (option click) anywhere on the puzzle. Select "This Frame -> Show Only This Frame". | |
// This should bring up just the puzzle. | |
// Right-click (option click) and click "Inspect Element". Enter the Console tab. | |
// Paste the code below, and press Enter. Save the text file, and open into Across Lite. | |
// PLEASE NOTE: EXECUTING CODE IN YOUR CONSOLE YOU DON'T UNDERSTAND IS GENERALLY A VERY BAD IDEA. Don't make a habit of this. | |
function bda(a, l) { | |
a = a.replace(/[^A-Za-z0-9\+\/]/g, ""); | |
var p = a.length; | |
l = l ? Math.ceil((3 * p + 1 >> 2) / l) * l : 3 * p + 1 >> 2; | |
for (var R = new Uint8Array(l), y, b = 0, na = 0, Ea = 0; Ea < p; Ea++) | |
if (y = Ea & 3, b |= bc4ToUint6(a.charCodeAt(Ea)) << 18 - 6 * y, 3 === y || 1 === p - Ea) { | |
for (y = 0; 3 > y && na < l; y++, na++) R[na] = b >>> (16 >>> y & 24) & 255; | |
b = 0 | |
} return R | |
} | |
function UTF8ArrToStr(a) { | |
for (var l = "", p, R = a.length, y = 0; y < R; y++) p = a[y], l += String.fromCharCode(251 < p && 254 > p && y + 5 < R ? 1073741824 * (p - 252) + (a[++y] - 128 << 24) + (a[++y] - 128 << 18) + (a[++y] - 128 << 12) + (a[++y] - 128 << 6) + a[++y] - 128 : 247 < p && 252 > p && y + 4 < R ? (p - 248 << 24) + (a[++y] - 128 << 18) + (a[++y] - 128 << 12) + (a[++y] - 128 << 6) + a[++y] - 128 : 239 < p && 248 > p && y + 3 < R ? (p - 240 << 18) + (a[++y] - 128 << 12) + (a[++y] - 128 << 6) + a[++y] - 128 : 223 < p && 240 > p && y + 2 < R ? (p - 224 << 12) + (a[++y] - 128 << 6) + a[++y] - 128 : 191 < p && 224 > p && y + 1 < R ? (p - 192 << 6) + a[++y] - 128 : p); | |
return l | |
} | |
function download(filename, text) { | |
var element = document.createElement('a'); | |
element.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(text)); | |
element.setAttribute('download', filename); | |
element.style.display = 'none'; | |
document.body.appendChild(element); | |
element.click(); | |
document.body.removeChild(element); | |
} | |
function exec() { | |
var data = JSON.parse(UTF8ArrToStr(bda(window.rawc))) | |
var grid = Array(data.h).fill('') | |
data.box.forEach((col) => col.forEach((letter, row) => grid[row] += letter)) | |
grid = grid.map(row => row.replace(/\u0000/gi,'.')) | |
var across = data.placedWords.filter(word => word.acrossNotDown).map(word => word.clue.clue) | |
var down = data.placedWords.filter(word => !word.acrossNotDown).map(word => word.clue.clue) | |
var output = [ | |
'<ACROSS PUZZLE>', | |
'<TITLE>', | |
data.title, | |
'<AUTHOR>', | |
data.author, | |
'<COPYRIGHT>', | |
data.copyright, | |
'<SIZE>', | |
`${data.h}x${data.w}`, | |
'<GRID>', | |
...grid, | |
'<ACROSS>', | |
...across, | |
'<DOWN>', | |
...down | |
] | |
download(data.id + '.txt', output.join('\n')) | |
} | |
exec() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment