Code.org Data Editor Console

Execute a code to edit the data while you're in a code.org fullscreen project (a code.org project link that does not have /edit or /view or anything on the last part.). You can execute data functions for example createRecord(), readRecords(), setKeyValue(), getKeyValue(), etc.

  1. // ==UserScript==
  2. // @name Code.org Data Editor Console
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.1
  5. // @description Execute a code to edit the data while you're in a code.org fullscreen project (a code.org project link that does not have /edit or /view or anything on the last part.). You can execute data functions for example createRecord(), readRecords(), setKeyValue(), getKeyValue(), etc.
  6. // @author cool
  7. // @match https://studio.code.org/projects/*/*
  8. // @icon https://www.google.com/s2/favicons?sz=64&domain=code.org
  9. // @grant none
  10. // @license MIT
  11. // ==/UserScript==
  12.  
  13. (function() {
  14. 'use strict';
  15. var style = document.createElement("style");
  16. style.textContent = `
  17. #ci {
  18. outline: 0px;
  19. position: fixed;
  20. left: 5px;
  21. bottom: 5px;
  22. width: calc(100% - 20px);
  23. }
  24. `;
  25. document.head.appendChild(style);
  26. var loadIn = setInterval(function() {
  27. if (document.querySelector(".WireframeButtons_containerRight") != null) {
  28. clearInterval(loadIn);
  29. var odc = document.createElement("span");
  30. odc.style.display = "inline-block";
  31. odc.style.cursor = "pointer";
  32. var odca = document.createElement("a");
  33. odca.className = "WireframeButtons_button";
  34. odca.innerHTML = "<i class=\"fa fa-code\"></i>Open Data Console";
  35. odc.appendChild(odca);
  36. odc.addEventListener("click", function() {
  37. odca.innerHTML = odca.innerHTML == "<i class=\"fa fa-code\"></i>Open Data Console" ? "<i class=\"fa fa-code\"></i>Close Data Console" : "<i class=\"fa fa-code\"></i>Open Data Console";
  38. ci.hidden = !ci.hidden;
  39. if (!ci.hidden) {
  40. ci.focus();
  41. }
  42. });
  43. document.querySelector(".WireframeButtons_containerRight").childNodes[0].appendChild(odc);
  44. var ci = document.createElement("input");
  45. ci.id = "ci";
  46. ci.placeholder = "Press enter to execute";
  47. ci.hidden = true;
  48. ci.addEventListener("keydown", function(event) {
  49. if (event.key == "Enter") {
  50. (function() {
  51. 'use strict';
  52. eval(ci.value);
  53. ci.value = "";
  54. })();
  55. }
  56. });
  57. document.body.appendChild(ci);
  58. if (location.href.split("/")[4] == "applab") {
  59. for (var i = 0; i < Object.keys(Applab.storage).length; i++) {
  60. window[Object.keys(Applab.storage)[i]] = Applab.storage[Object.keys(Applab.storage)[i]];
  61. }
  62. } else if (location.href.split("/")[4] == "gamelab") {
  63. for (i = 0; i < Object.keys(__mostRecentGameLabInstance.apiJS).length; i++) {
  64. window[Object.keys(__mostRecentGameLabInstance.apiJS)[i]] = __mostRecentGameLabInstance.apiJS[Object.keys(__mostRecentGameLabInstance.apiJS)[i]];
  65. }
  66. }
  67. }
  68. }, 100);
  69. })();