Khan Acadamy UI Enhance

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

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==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);
})();