KA Editor Tools

Modifications/fixes for the Ace Editor embedded in Khan Academys programming projects.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name        KA Editor Tools
// @version     0.1.4
// @namespace   https://www.khanacademy.org/profile/KnowMoreStuff/
// @icon        https://dl.dropboxusercontent.com/u/57161259/icons/cs-ohnoes-icon.png
// @homepageURL http://codeyourown.site/
// @author      Robert Stone
// @description Modifications/fixes for the Ace Editor embedded in Khan Academys programming projects.
// @include     http*://www.khanacademy.org/computer-programming/*
// @include     http*://www.khanacademy.org/computing/computer-programming/*/*/p/*
// @grant       GM_log
// @run-at      document-idle
// ==/UserScript==

(function() {
    'use strict';

    function waitForAjax() {
        var ed;
        var liveEd;
        try {
            liveEd = ScratchpadUI.liveEditor;
            ed = ScratchpadUI.liveEditor.editor.editor;
        } catch (e) {
            GM_log("KAET: Ajax not loaded yet.");
            return;
        }
        clearTimeout(timer);
        GM_log("KAET: Ajax loaded. Timer cleared.");

        ed.setShowInvisibles(true);

        $(".scratchpad-wrap-outer>div:first-child").attr("style","max-width: 100% !important");

        if (liveEd.editorType === "ace_webpage" || liveEd.editorType === "ace_sql" ) {
            $("div.scratchpad-canvas-wrap").attr("style","width: 50%; right: 0; left: auto;");
            ed.resize();
        }

        $("div[class^=\"bubble_\"]")
            .attr("style","top: auto !important; max-width: none !important;" +
                  " padding: 5px !important;" +
                  " position: fixed !important;" +
                  " right: 0px !important; left: 0px; width: 440px;" +
                  " bottom: 10px; height: 28px;");
    }

    var timer = setInterval(waitForAjax, 1000);
    GM_Log("KAET: Started ajax wait timer.");

})();