geogrid undo
bendn 2025-02-26
commit 809ce03
-rw-r--r--icon.svg1
-rw-r--r--manifest.json16
-rw-r--r--undo.js42
3 files changed, 59 insertions, 0 deletions
diff --git a/icon.svg b/icon.svg
new file mode 100644
index 0000000..1caac43
--- /dev/null
+++ b/icon.svg
@@ -0,0 +1 @@
+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 36 36"><defs><marker id="a" markerHeight=".5" markerWidth=".5" orient="auto-start-reverse" preserveAspectRatio="xMidYMid" refX="0" refY="0" style="overflow:visible" viewBox="0 0 1 1"><path d="m5.77 0-8.65 5V-5Z" style="fill:context-stroke;fill-rule:evenodd;stroke:context-stroke;stroke-width:1pt" transform="scale(.5)"/></marker></defs><circle cx="18" cy="18" r="18" fill="#88C9F9" style="stroke-width:3;stroke-dasharray:none;marker-end:url(#a)"/><path fill="#5C913B" d="M2.812 25.375c-.062-1-.062-1.187-.062-2.375s.562-1 1.125-1.562.438-.625 1.375-1.241.438-1.321.375-1.696-.625-.063-1.563.061-.624-.312-1.187-.562-.812-.625-1.188-1.75-.438-1.438-.312-2.375.563-.063.625.937.938.625.938 1.25 1.25 1.312 1.562 1.5 1.188-.938 1.5-1.25.688-.75.812-1 1.688-.438 2-.438 1.062.938 1.062 1.375.375 1.625.688 2.312 1 .812 1.625 1.312.938.062.938.062-.25-1.062-.25-1.938.75-1.625.75-1.625 1.188.875 1.25 1.125 1 1.125 1.062 1.562.562 1 1.483 1.125.267-1.062.579-1.875.75-.938 1.312-1.062 1-.625 1.375-1.125 1.062-1.188 1-1.75-.25-.938-.5-1.625.75-.938 1.188-1.75 0 0 1-.25.562-.25.75-.625.312-.75.125-1.438-.875 0-1.562 0S22.938 7.75 23 7s.938-.562 1.562-.625.812.812 1 1 2.125-1.25 2.625-1.938-.437-.499-.187-.789-1.5-.349-2.188-.46-2.437-.188-3.124-.612-3.312-.104-4 .237-1.125-.029-1.438-.5-1.625-.235-2-.5-.75.437-1.25.625-.688.25-1.312-.125.187-.813-.688-1.125c-.586-.209-1.288-.087-2.38-.111C3.902 5.092 0 11.087 0 18c0 3.42.971 6.605 2.627 9.327.308-.518.231-1.217.185-1.952m14.5-1.187c.438.062 1.688 0 .688-.812s-1.562-.188-1.438-1.125-.625-.938-.625-.938c0 .688-.5 1.438 0 2.125s.938.687 1.375.75" style="stroke-width:3;stroke-dasharray:none;marker-end:url(#a)"/><path fill="#5C913B" d="M23.688 13.75c-1-.812-.25-.562-.125-1.5s-.625-.938-.625-.938c0 .688-.5 1.438 0 2.125s-1 1.25-.562 1.312 2.312-.187 1.312-.999m-3.88 9.75c.62.688.38 0 1.192-.312s-.688-1-1.188-1.375-.997-.389-1.434.438c-.496.937.81.561 1.43 1.249m7.317 1.25c-.312-.375-1-.562-1.75-.545s-.688-.83-1.438-.768-1.286-.504-1.625-.679c-.737-.38-.25.491 0 1.446s1.188.232 2.062.732.938-.188 1.75.062 1.125.812 1.904.75-.59-.623-.903-.998M25.5 27.5c-.312-.625-1.226-1.188-1.601-1.505s-.962-.424-1.462-.24-.812 0-1.062-.495-.688-.322-1.062-.26-1.875.688-2.75 1.125-1.273.817-1.847 1.375c-.898.874-.403.312 0 .875s-.442 2.312-.504 3.312 1.602-.312 2.227-.438.441-.5.941-.875.825-.463 1.374.037 1.268.963 1.268 1.525 1.979 1.5 2.729 1.125 1.188-1.125 1.875-1.75.438-1.812.625-2.562-.439-.624-.751-1.249" style="stroke-width:3;stroke-dasharray:none;marker-end:url(#a)"/><path d="m-15.852 8.73 2.18-1.219-.035 2.5z" style="fill:context-stroke;fill-rule:evenodd" transform="translate(3.221 6.819)"/><path d="m-13.502 7.225-2.684 1.502 2.641 1.576zm-.34.572-.027 1.922-1.649-.983z" style="fill:context-stroke;fill-rule:evenodd" transform="translate(3.221 6.819)"/><path d="m16.271 6.292-9.407 5.432 9.407 5.783v-3.433c4.224.19 7.86.713 9.304 2.018 1.77 1.598 1.763 5.275.11 6.8-.826.763-2.39 1.333-4.498 1.61-2.105.276-11.037.008-13.665.008v3.923c2.628 0 11.686.285 14.176-.042s4.86-.963 6.648-2.615c3.578-3.303 3.519-9.287-.14-12.592-3.015-2.727-7.447-3.017-11.935-3.079z" style="color:#000;font-style:normal;font-variant:normal;font-weight:400;font-stretch:normal;font-size:medium;line-height:normal;font-family:sans-serif;font-variant-ligatures:normal;font-variant-position:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-alternates:normal;font-variant-east-asian:normal;font-feature-settings:normal;font-variation-settings:normal;text-indent:0;text-align:start;text-decoration-line:none;text-decoration-style:solid;text-decoration-color:#000;letter-spacing:normal;word-spacing:normal;text-transform:none;writing-mode:lr-tb;direction:ltr;text-orientation:mixed;dominant-baseline:auto;baseline-shift:baseline;text-anchor:start;white-space:normal;shape-padding:0;shape-margin:0;inline-size:0;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000;solid-opacity:1;fill:#4a742f;fill-opacity:1;fill-rule:evenodd;stroke:#6dbef7;stroke-width:3.92291;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:markers stroke fill;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;stop-color:#000"/><path fill="none" d="m-6.69 7.227-13.933 8.044 13.934 8.565zm-4.564 7.906v.54l-.455-.278z" style="fill-opacity:0;fill-rule:evenodd;paint-order:markers stroke fill"/></svg> \ No newline at end of file
diff --git a/manifest.json b/manifest.json
new file mode 100644
index 0000000..3921df4
--- /dev/null
+++ b/manifest.json
@@ -0,0 +1,16 @@
+{
+ "manifest_version": 2,
+ "name": "Geoundo",
+ "version": "1.0",
+ "description": "adds undos for geogrid",
+ "icons": {
+ "48": "icon.svg"
+ },
+
+ "content_scripts": [
+ {
+ "matches": ["*://*.geogridgame.com/*"],
+ "js": ["undo.js"]
+ }
+ ]
+}
diff --git a/undo.js b/undo.js
new file mode 100644
index 0000000..2861d46
--- /dev/null
+++ b/undo.js
@@ -0,0 +1,42 @@
+let today = +document.querySelector(".page-title").innerHTML.replace(/[^0-9]+/, "");
+function get() {
+ let c = JSON.parse(localStorage.getItem("userData"));
+ return { data: c[today], raw: c }
+}
+let last = undefined;
+let c = get();
+
+setInterval(() => {
+ let n = get();
+ if (!n.data) return;
+ if (c.data === undefined) {
+ console.log("started")
+ c = n;
+ return;
+ }
+ if (c.data.board.toString() !== n.data.board.toString()) {
+ console.log("change detected")
+ last = c.raw;
+ c = n;
+ console.log("last board stored", c.data.board)
+ }
+}, 500)
+const reset = () => {
+ delete c.raw[today];
+ localStorage.setItem("userData", JSON.stringify(c.raw));
+ window.location.reload();
+};
+
+document.addEventListener('keydown', function (event) {
+ if (event.ctrlKey && event.key === 'z' && c.data !== undefined) {
+ if (last === undefined) {
+ reset()
+ } else {
+ localStorage.setItem("userData", JSON.stringify(last));
+ window.location.reload();
+ }
+ }
+ if (event.altKey && event.key === 'r' && c.data !== undefined) {
+ reset()
+ }
+}); \ No newline at end of file