KA Editor Tools

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

  1. // ==UserScript==
  2. // @name KA Editor Tools
  3. // @version 0.1.4
  4. // @namespace https://www.khanacademy.org/profile/KnowMoreStuff/
  5. // @icon https://dl.dropboxusercontent.com/u/57161259/icons/cs-ohnoes-icon.png
  6. // @homepageURL http://codeyourown.site/
  7. // @author Robert Stone
  8. // @description Modifications/fixes for the Ace Editor embedded in Khan Academys programming projects.
  9. // @include http*://www.khanacademy.org/computer-programming/*
  10. // @include http*://www.khanacademy.org/computing/computer-programming/*/*/p/*
  11. // @grant GM_log
  12. // @run-at document-idle
  13. // ==/UserScript==
  14.  
  15. (function() {
  16. 'use strict';
  17.  
  18. function waitForAjax() {
  19. var ed;
  20. var liveEd;
  21. try {
  22. liveEd = ScratchpadUI.liveEditor;
  23. ed = ScratchpadUI.liveEditor.editor.editor;
  24. } catch (e) {
  25. GM_log("KAET: Ajax not loaded yet.");
  26. return;
  27. }
  28. clearTimeout(timer);
  29. GM_log("KAET: Ajax loaded. Timer cleared.");
  30.  
  31. ed.setShowInvisibles(true);
  32.  
  33. $(".scratchpad-wrap-outer>div:first-child").attr("style","max-width: 100% !important");
  34.  
  35. if (liveEd.editorType === "ace_webpage" || liveEd.editorType === "ace_sql" ) {
  36. $("div.scratchpad-canvas-wrap").attr("style","width: 50%; right: 0; left: auto;");
  37. ed.resize();
  38. }
  39.  
  40. $("div[class^=\"bubble_\"]")
  41. .attr("style","top: auto !important; max-width: none !important;" +
  42. " padding: 5px !important;" +
  43. " position: fixed !important;" +
  44. " right: 0px !important; left: 0px; width: 440px;" +
  45. " bottom: 10px; height: 28px;");
  46. }
  47.  
  48. var timer = setInterval(waitForAjax, 1000);
  49. GM_Log("KAET: Started ajax wait timer.");
  50.  
  51. })();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址