Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name WordleShare
- // @namespace http://tampermonkey.net/
- // @version 0.1
- // @description extract wordle bitmap
- // @author Suppenbiatch
- // @match https://www.powerlanguage.co.uk/wordle/
- // @icon https://www.powerlanguage.co.uk/wordle/images/wordle_logo_192x192.png
- // @run-at document-idle
- // @grant none
- // ==/UserScript==
- (function() {
- 'use strict';
- var result = []
- var row = []
- function parse_rows (ele, idx, arr) {
- var items = ele.shadowRoot.querySelectorAll('game-tile')
- row = []
- items.forEach(parse_items)
- result.push(row)
- }
- function parse_items(ele, idx, arr) {
- try {
- var evaluation = ele.attributes.evaluation.value
- } catch (e) {
- if (e instanceof TypeError) {
- row.push(0)
- return;
- }
- console.log(e)
- }
- if (evaluation === 'absent') {
- row.push(0)
- } else if (evaluation === 'present') {
- row.push(1)
- } else if (evaluation === 'correct') {
- row.push(2)
- }
- return;
- }
- function createBitmap() {
- result = []
- const rows = document.querySelector('game-app').shadowRoot.querySelectorAll('game-row');
- rows.forEach(parse_rows)
- console.log(result)
- const output = '!wordle ' + btoa(JSON.stringify(result))
- navigator.clipboard.writeText(output).then(function() {
- return;
- }, function(err) {
- console.error(err);
- })
- }
- function addButton(text, onclick, cssObj, parentElement) {
- cssObj = cssObj || {color: '#e8e6e3', 'background-color': '#181a1b', 'z-index': 1}
- parentElement = parentElement || document.body
- let button = document.createElement('button'), btnStyle = button.style
- parentElement.appendChild(button)
- button.innerHTML = text
- button.onclick = onclick
- Object.keys(cssObj).forEach(key => btnStyle[key] = cssObj[key])
- return button
- }
- function add_button_element() {
- var buttonList = document.createElement('ul');
- buttonList.setAttribute('id', 'button-header');
- buttonList.style.listStyleType = 'none'
- buttonList.style.margin = '4%';
- buttonList.style.padding = '2px';
- buttonList.style.textAlign = 'center';
- buttonList.style.position = 'fixed';
- buttonList.style.bottom = '7%';
- buttonList.style.left = '10%';
- buttonList.style.zIndex = '10';
- document.body.appendChild(buttonList);
- var button = document.createElement('li');
- window.addEventListener('load', () => {
- addButton('Create BitMap', createBitmap, null, button)
- })
- buttonList.appendChild(button);
- }
- add_button_element()
- // Your code here...
- })();
Add Comment
Please, Sign In to add comment