Created
September 25, 2024 11:32
-
-
Save augustin64/54e28e0688c67dc7492c1fd0cf4907df to your computer and use it in GitHub Desktop.
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
| // ==UserScript== | |
| // @name Pédantix/Cémantix helper | |
| // @namespace http://tampermonkey.net/ | |
| // @version 0.1 | |
| // @description Prefill Pédantix, copy cemantix if you want | |
| // @author augustin64 | |
| // @match https://cemantix.certitudes.org/* | |
| // @icon https://www.google.com/s2/favicons?sz=64&domain=certitudes.org | |
| // @grant none | |
| // ==/UserScript== | |
| (function() { | |
| 'use strict'; | |
| let words = [ | |
| "être", "un", "qui", "ce", "ainsi", "que", "avoir", "y", | |
| "à", "dans", "par", "pour", "en", "vers", "avec", "de", "sans", "sous", "sur", "près", | |
| "mais", "où", "et", "donc", "or", "ni", "car", | |
| "le", "la", "les", "son", "sa", "ses", "il", "elle", "ils", | |
| "siècle", "histoire", "peinture", "science", "médecine", "découverte", "pays", "monument", | |
| "XX", "XIX", "XXI", "XVIII", "2000", "1900", "1800", "1700" | |
| ]; | |
| const delay = ms => new Promise(res => setTimeout(res, ms)); | |
| let submitButton = document.getElementById("pedantix-guess-btn"); | |
| let wordArea = document.getElementById("pedantix-guess"); | |
| async function prefill() { | |
| for (var i = 0; i < words.length; i++) { | |
| let word = words[i]; | |
| wordArea.value = word; | |
| submitButton.click(); | |
| await delay(1000); | |
| } | |
| } | |
| function copyCemantix() { | |
| var table = document.getElementById("cemantix-guesses"); | |
| var arr = []; | |
| for (var i = 0, row; row = table.rows[i]; i++) { | |
| if (!row.classList.contains("separator")) { | |
| var mot = row.getElementsByClassName("word")[0].innerText; | |
| var temp = row.getElementsByClassName("number")[0].innerText; | |
| arr.push({"mot":mot, "temp":temp}); | |
| } | |
| } | |
| navigator.clipboard.writeText(JSON.stringify(arr)); | |
| } | |
| function addButton(text, onclick, cssObj) { | |
| cssObj = cssObj || {position: 'absolute', bottom: '70%', left:'10%', 'z-index': 3} | |
| let button = document.createElement('button'), btnStyle = button.style | |
| document.body.appendChild(button) | |
| button.innerHTML = text | |
| button.onclick = onclick | |
| btnStyle.position = 'absolute' | |
| Object.keys(cssObj).forEach(key => btnStyle[key] = cssObj[key]) | |
| return button | |
| } | |
| addButton("prefill pedantix", prefill, { | |
| "position": "absolute", | |
| "background-color": "#ffd700", | |
| "border-color": "#F44133", | |
| "border-style": "dashed", | |
| "padding": "15px 10px", | |
| "position": "absolute", | |
| "bottom": "17%", | |
| "left": "5", | |
| "color": "#f44133", | |
| "font-weight": "bold" | |
| }); | |
| addButton("copy cemantix", copyCemantix, { | |
| "position": "absolute", | |
| "background-color": "#ffd700", | |
| "border-color": "#F44133", | |
| "border-style": "dashed", | |
| "padding": "15px 10px", | |
| "position": "absolute", | |
| "bottom": "12%", | |
| "left": "5", | |
| "color": "#f44133", | |
| "font-weight": "bold" | |
| }); | |
| // Let user copy-paste text | |
| document.getElementById("wiki").style["user-select"] = "auto"; | |
| })(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment