Khan Acadamy UI Enhance

1. Khan Acadamy dialogs force FullScreen, 2. Ctrl+Enter To confirm

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         Khan Acadamy UI Enhance
// @namespace    https://userscript.snomiao.com/
// @version      0.0.1
// @description  1. Khan Acadamy dialogs force FullScreen, 2. Ctrl+Enter To confirm
// @author       [email protected]
// @match        https://www.khanacademy.org/*
// @icon         https://www.google.com/s2/favicons?domain=khanacademy.org
// @grant        none
// ==/UserScript==

(function () {
  "use strict";
  const e = document.createElement("div");
  e.innerHTML = `
        <style>
            [role="dialog"] {
                width: 100% !important;
                height: 100% !important;
                max-height: 100% !important;
                max-width: 100% !important;
            }
        <style>`;
  document.addEventListener("keydown", (event) => {
    // ctrl+enter or Alt+Enter to click the confirm button
    if (
      (event.ctrlKey &&
        !event.altKey &&
        !event.shiftKey &&
        event.key === "Enter") ||
      (!event.ctrlKey &&
        event.altKey &&
        !event.shiftKey &&
        event.key === "Enter")
    ) {
      var e =
        document.querySelector('[data-test-id="exercise-check-answer"]') ||
        document.querySelector('[data-test-id="exercise-next-question"]') ||
        document.querySelector('[data-test-id="modal-done-button"]') ||
        document.querySelector('[role="dialog"] [role="button"]');
      if (e) {
        e.click();
        e && event.preventDefault();
      }
    }
  });
  document.body.appendChild(e);
})();