{"id":5965,"date":"2023-08-25T17:53:15","date_gmt":"2023-08-25T17:53:15","guid":{"rendered":"https:\/\/robertjwallace.com\/?p=5965"},"modified":"2025-02-12T13:28:08","modified_gmt":"2025-02-12T13:28:08","slug":"wordle-bookmarklet","status":"publish","type":"post","link":"https:\/\/robertjwallace.com\/es\/wordle-bookmarklet\/","title":{"rendered":"Wordle bookmarklet"},"content":{"rendered":"\n<p class=\"\">Do you have trouble remembering words when playing Wordle.  I wrote a <a href=\"https:\/\/en.wikipedia.org\/wiki\/Bookmarklet\">bookmarklet<\/a> that examines your guesses and displays a list of words that potentially match for your next guess.<\/p>\n\n\n\n<p class=\"\">The bookmarklet is at the end of this post.  If you don&#8217;t know what a bookmarklet is you can use the link above to learn about them.<\/p>\n\n\n\n<!--more-->\n\n\n\n<p class=\"\">To use the bookmarklet, first drag it to your bookmark bar.  Then, when playing wordle, after your guess, click on the bookmarklet.  The bookmarklet will analyze the board and in the header portion of the Wordle page display a list of possible words.  For example: here is the start of a game.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"736\" height=\"209\" data-src=\"https:\/\/robertjwallace.com\/wp-content\/uploads\/2023\/08\/image.png\" alt=\"\" class=\"wp-image-5966 lazyload\" data-srcset=\"https:\/\/robertjwallace.com\/wp-content\/uploads\/2023\/08\/image.png 736w, https:\/\/robertjwallace.com\/wp-content\/uploads\/2023\/08\/image-300x85.png 300w\" data-sizes=\"(max-width: 736px) 100vw, 736px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 736px; --smush-placeholder-aspect-ratio: 736\/209;\" \/><\/figure>\n\n\n\n<p class=\"\">Here is the board after your first guess:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"744\" height=\"188\" data-src=\"https:\/\/robertjwallace.com\/wp-content\/uploads\/2023\/08\/image-1.png\" alt=\"\" class=\"wp-image-5967 lazyload\" data-srcset=\"https:\/\/robertjwallace.com\/wp-content\/uploads\/2023\/08\/image-1.png 744w, https:\/\/robertjwallace.com\/wp-content\/uploads\/2023\/08\/image-1-300x76.png 300w\" data-sizes=\"(max-width: 706px) 89vw, (max-width: 767px) 82vw, 740px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 744px; --smush-placeholder-aspect-ratio: 744\/188;\" \/><\/figure>\n\n\n\n<p class=\"\">Now you can press the Wordle bookmarket and the board will change to:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"742\" height=\"177\" data-src=\"https:\/\/robertjwallace.com\/wp-content\/uploads\/2023\/08\/image-2.png\" alt=\"\" class=\"wp-image-5968 lazyload\" data-srcset=\"https:\/\/robertjwallace.com\/wp-content\/uploads\/2023\/08\/image-2.png 742w, https:\/\/robertjwallace.com\/wp-content\/uploads\/2023\/08\/image-2-300x72.png 300w\" data-sizes=\"(max-width: 706px) 89vw, (max-width: 767px) 82vw, 740px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 742px; --smush-placeholder-aspect-ratio: 742\/177;\" \/><\/figure>\n\n\n\n<p class=\"\">Where the header was now is a list of possible words for your next guess.  Assume you type &#8220;blaze&#8221; in for your next guess:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"743\" height=\"203\" data-src=\"https:\/\/robertjwallace.com\/wp-content\/uploads\/2023\/08\/image-3.png\" alt=\"\" class=\"wp-image-5969 lazyload\" data-srcset=\"https:\/\/robertjwallace.com\/wp-content\/uploads\/2023\/08\/image-3.png 743w, https:\/\/robertjwallace.com\/wp-content\/uploads\/2023\/08\/image-3-300x82.png 300w\" data-sizes=\"(max-width: 706px) 89vw, (max-width: 767px) 82vw, 740px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 743px; --smush-placeholder-aspect-ratio: 743\/203;\" \/><\/figure>\n\n\n\n<p class=\"\">Press the bookmarklet again to generate a new list of possible solutions.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"746\" height=\"225\" data-src=\"https:\/\/robertjwallace.com\/wp-content\/uploads\/2023\/08\/image-5.png\" alt=\"\" class=\"wp-image-5971 lazyload\" data-srcset=\"https:\/\/robertjwallace.com\/wp-content\/uploads\/2023\/08\/image-5.png 746w, https:\/\/robertjwallace.com\/wp-content\/uploads\/2023\/08\/image-5-300x90.png 300w\" data-sizes=\"(max-width: 706px) 89vw, (max-width: 767px) 82vw, 740px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 746px; --smush-placeholder-aspect-ratio: 746\/225;\" \/><\/figure>\n\n\n\n<p class=\"\">Guessing &#8220;opera&#8221; gives:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"741\" height=\"258\" data-src=\"https:\/\/robertjwallace.com\/wp-content\/uploads\/2023\/08\/image-6.png\" alt=\"\" class=\"wp-image-5972 lazyload\" data-srcset=\"https:\/\/robertjwallace.com\/wp-content\/uploads\/2023\/08\/image-6.png 741w, https:\/\/robertjwallace.com\/wp-content\/uploads\/2023\/08\/image-6-300x104.png 300w\" data-sizes=\"(max-width: 706px) 89vw, (max-width: 767px) 82vw, 740px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 741px; --smush-placeholder-aspect-ratio: 741\/258;\" \/><\/figure>\n\n\n\n<p class=\"\">Below is the bookmarklet.  Simply drag and drop it onto your bookmark bar in your browser.  This has been tested on Chrome, Firefox, and Edge.<\/p>\n\n\n\n<div class=\"wp-block-columns are-vertically-aligned-center is-layout-flex wp-container-core-columns-is-layout-9d6595d7 wp-block-columns-is-layout-flex\">\n<div class=\"wp-block-column is-vertically-aligned-center is-layout-flow wp-block-column-is-layout-flow\">\n<a role=\"button\" style=\"padding:5px 8px;background-color:olive;color:white;font-family:arial\" href=\"javascript:(function(){_my_script=document.createElement(&quot;SCRIPT&quot;),_my_script.type=&quot;text\/javascript&quot;,_my_script.src=&quot;http:\/\/robertjwallace.com\/bookmarklet.js?&quot;,document.getElementsByTagName(&quot;head&quot;)[0].appendChild(_my_script);}());\" class=\"button button-bookmarklet svelte-7bsmc8\">Wordle<\/a>\n<\/div>\n\n\n\n<div class=\"wp-block-column is-vertically-aligned-center is-layout-flow wp-block-column-is-layout-flow\">\n<p class=\"\"><strong>&lt;- drag the button to your bookmark or favorites bar<\/strong><\/p>\n<\/div>\n<\/div>\n\n\n\n<p class=\"\">Note that this bookmarklet does not look at any of your personal information.  It only analyzes the guesses on the page.  This comes without any warranty. Below is the listing of the code, without the actual list of dictionary words.  <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>function cheatWordle() {\n    const ele = document.querySelectorAll('&#91;aria-label*=\"letter\"]');\n    let absent = new Set();\n    let present = new Set();\n    let correct = Array(5).fill(\".\");\n    let wrongloc = Array(5).fill(\"\");\n\n    ele.forEach(el => {\n        const lab = el.getAttribute(\"aria-label\").split(\/, \/);\n        if (lab.length === 3) {\n            let letter = lab&#91;1].toLowerCase();\n            let index = parseInt(lab&#91;0]&#91;0]) - 1;\n\n            if (lab&#91;2].includes(\"correct\")) {\n                correct&#91;index] = letter;\n            } else if (lab&#91;2].includes(\"present\")) {\n                present.add(letter);\n                wrongloc&#91;index] += letter;\n            } else if (lab&#91;2].includes(\"absent\") &amp;&amp; !present.has(letter)) {\n                absent.add(letter);\n            }\n        }\n    });\n\n    let it = &#91;\"aahed\", ...]; \/\/ Replace with actual word list\n\n    \/\/ Filter out words containing absent letters\n    let reAbsent = new RegExp(`&#91;${&#91;...absent].join(\"\")}]`);\n    let filtered = it.filter(word => !reAbsent.test(word));\n\n    \/\/ Ensure words contain at least one present letter\n    present.forEach(letter => {\n        filtered = filtered.filter(word => word.includes(letter));\n    });\n\n    \/\/ Remove words with letters in the wrong location\n    let reWrongLoc = new RegExp(wrongloc.map(w => w ? `&#91;^${w}]` : \".\").join(\"\"));\n    filtered = filtered.filter(word => reWrongLoc.test(word));\n\n    \/\/ Remove words that don't have letters in the correct location\n    let reCorrect = new RegExp(correct.join(\"\"));\n    filtered = filtered.filter(word => reCorrect.test(word));\n\n    \/\/ Display results\n    let main = document.querySelector(\"header\");\n    let answerDiv = document.getElementById(\"wordleanswer\");\n\n    if (answerDiv) {\n        answerDiv.remove();\n    }\n\n    let newDiv = document.createElement(\"div\");\n    newDiv.id = \"wordleanswer\";\n    newDiv.style.width = \"600px\";\n    newDiv.style.height = \"100%\";\n    newDiv.style.backgroundColor = \"white\";\n    newDiv.style.overflow = \"auto\";\n\n    newDiv.textContent = filtered.sort().join(\", \");\n    main.innerHTML = \"\";\n    main.appendChild(newDiv);\n}\n\ncheatWordle();\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Do you have trouble remembering words when playing Wordle. I wrote a bookmarklet that examines your guesses and displays a list of words that potentially match for your next guess. The bookmarklet is at the end of this post. If you don&#8217;t know what a bookmarklet is you can use the link above to learn &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/robertjwallace.com\/es\/wordle-bookmarklet\/\" class=\"more-link\">Continuar leyendo<span class=\"screen-reader-text\"> &#8220;Wordle bookmarklet&#8221;<\/span><\/a><\/p>","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"nf_dc_page":"","_eb_attr":"","footnotes":""},"categories":[143],"tags":[],"class_list":["post-5965","post","type-post","status-publish","format-standard","hentry","category-computer-stuff"],"featured_image_src":null,"featured_image_src_square":null,"author_info":{"display_name":"Bob","author_link":"https:\/\/robertjwallace.com\/es\/author\/admin\/"},"_links":{"self":[{"href":"https:\/\/robertjwallace.com\/es\/wp-json\/wp\/v2\/posts\/5965","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/robertjwallace.com\/es\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/robertjwallace.com\/es\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/robertjwallace.com\/es\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/robertjwallace.com\/es\/wp-json\/wp\/v2\/comments?post=5965"}],"version-history":[{"count":8,"href":"https:\/\/robertjwallace.com\/es\/wp-json\/wp\/v2\/posts\/5965\/revisions"}],"predecessor-version":[{"id":6349,"href":"https:\/\/robertjwallace.com\/es\/wp-json\/wp\/v2\/posts\/5965\/revisions\/6349"}],"wp:attachment":[{"href":"https:\/\/robertjwallace.com\/es\/wp-json\/wp\/v2\/media?parent=5965"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/robertjwallace.com\/es\/wp-json\/wp\/v2\/categories?post=5965"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/robertjwallace.com\/es\/wp-json\/wp\/v2\/tags?post=5965"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}