miitomo tomodachi miitopia qr decrypt experiment

by arian_

HTML

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />

    <script type="importmap">
    {
      "imports": {
        "qr-scanner": "https://esm.sh/gh/ariankordi/qr-scanner-binary@140fda0/qr-scanner.esm.min.js",
        "qrjs": "https://esm.sh/gh/ariankordi/[email protected]"
      }
    }
  </script>
  <style>
body {
  font-family: sans-serif;
}

@font-face {
    font-family: nintendo_NTLG;
    src: url(nintendo_NTLG.woff2);
}

.tab-content {
  display: none;
}
.active {
  display: block;
}
.tab-button {
  padding: 10px;
  cursor: pointer;
  display: inline-block;
  border: 1px solid #ddd;
  background-color: #f0f0f0;
  margin-right: 5px;
}
.tab-button.active {
  background-color: #ddd;
}

table, table * {
  margin: 0;
  padding: 0;
  vertical-align: top;
  font: 1em/1em monospace;
}
.hex-textarea {
  height: 1.5em;
  resize: none;
  width: 100%;
}
.table-padding {
  padding: 0 2px;
}
.file-input {
  position: absolute;
  opacity: .001;
}
.ascii-output {
  overflow: hidden;
}
.warning {
    color: red;
}
  </style>
  </head>
  <body>

  <!-- Global error display block. -->
  <div id="global-error-box" style="display: none; background: #ffeeee; color: #000; border: 2px solid red; padding: 1em; margin: 1em; font-family: monospace;">
   <div style="font-weight: bold; font-size: 1.2em;"><span id="global-error-text-error">⚠️ JS Error:</span><span id="global-error-text-promise-rejection">⚠️ JS Promise Rejection:</span></div>
    <div id="global-error-message" style="white-space: pre-wrap; margin-top: 0.5em;"></div>
    <button id="global-error-hide-button" style="margin-top: 1em;">Close</button>
  </div>

    <!-- Encode Section -->
    <div id="encode-tab" class="tab-content active">
    <h1>encrypt/encode mii qr code</h1>
    <div>
        <b>StoreData hex input:</b>
        <div>(you can also...

CSS

body {
  font-family: sans-serif;
}

@font-face {
    font-family: nintendo_NTLG;
    src: url(nintendo_NTLG.woff2);
}

.tab-content {
  display: none;
}
.active {
  display: block;
}
.tab-button {
  padding: 10px;
  cursor: pointer;
  display: inline-block;
  border: 1px solid #ddd;
  background-color: #f0f0f0;
  margin-right: 5px;
}
.tab-button.active {
  background-color: #ddd;
}

table, table * {
  margin: 0;
  padding: 0;
  vertical-align: top;
  font: 1em/1em monospace;
}
.hex-textarea {
  height: 1.5em;
  resize: none;
  width: 100%;
}
.table-padding {
  padding: 0 2px;
}
.file-input {
  position: absolute;
  opacity: .001;
}
.ascii-output {
  overflow: hidden;
}
.warning {
    color: red;
}

JavaScript

// @ts-check
/* eslint indent: ['error', 2] -- Define indent rules. */
/* eslint no-multi-spaces: 'off' -- Allow spaced comments. */

import QrScanner from 'qr-scanner';

/**
 * @file HexEditor.js
 * @author Arian Kordi <https://github.com/ariankordi>
 * Shared HTML/JS "hex editor" component.
 */

/** A hex editor class for displaying and editing hex data within a container. */
class HexEditor {
  /**
   * Creates an instance of HexEditor.
   * @param {HTMLElement|null} container - The container element that holds the hex editor components.
   * @param {boolean} [isReadOnly] - Determines if te hex editor should be read-only.
   * @throws {Error} Throws if any of the required elements do not exist.
   */
  constructor(container, isReadOnly = false) {
    if (!container) {
      throw new Error('HexEditor: Passed in container is null.');
    }
    /**
     * Text area for hex input.
     * @type {HTMLTextAreaElement|null}
     */
    const textArea = container.querySelector('.hex-textarea');
    if (!(textArea instanceof HTMLTextAreaElement)) {
      throw new TypeError('HexEditor: Missing or invalid .hex-textarea element.');
    }
    this.textArea = textArea;

    /**
     * Element for storing line numbers.
     * @type {HTMLElement|null}
     */
    const lineNumbers = container.querySelector('.line-numbers');
    if (!(lineNumbers instanceof HTMLElement)) {
      throw new TypeError('HexEditor: Missing or invalid .line-numbers element.');
    }
    this.lineNumbers = lineNumbers;

    /**
     * Element for ASCII/Unicode output.
     * @type {HTMLElement|null}
     */
    const asciiOutput = container.querySelector('.ascii-output');
    if (!(asciiOutput instanceof HTMLElement)) {
      throw new TypeError('HexEditor: Missing or invalid .ascii-output element.');
    }
    this.asciiOutput = asciiOutput;

    /**
     * Hex header element (00, 01, 02...)
     * @type {HTMLElement|null}
     */
    const...