I made a hacky online code editor within this site

2

SP4CEBAR 2025-06-28 16:26 (Edited)

Use my latest injected NX editor here

Findings

  1. This is the NX embedded player
    https://lowresnx.inutilis.com/player.php
  2. Files are stored like this on NX:
    https://lowresnx.inutilis.com/uploads/vfu9MRt53E_Star_Scroller_1.2.nx
  3. The embedded player gets the file like so:
    https://lowresnx.inutilis.com/player.php?p=uploads/vfu9MRt53E_Star_Scroller_1.2.nx
    open this url, it's interesting. it seems this player only plays sound after you clicked on it to focus it

You can open a program posted as a comment or forum post by:

  1. copying the program's download link
  2. inserting the text player.php?p= between the lowresnx.inutilis.com/and uploads
  3. opening the modified url in a browser

Url loader

Use my latest online NX editor instead: link

Before following the instructions, I can recommend to review the code as this does change the behavior of your local version of the site.

I managed to swap the program loaded by an NX program window with any program hosted on this site by:

  1. Opening a program like Lowres Galaxy
  2. open your browser's developer tools on this page (press F12).
  3. go to the "Console" tab in the dev tools.
  4. click on the empty space below the console messages to type a console command.
  5. paste the script below and press enter.
    • Note: only do this if you trust the script.
  6. on top of the web page you should see a new text input field and a button labeled "Run NX File", you may replace the program url with one of your own if you like
  7. click the button
    • note: you can not rerun it, instead, you should return to step 1.

Command that inserts the a menu to add nx files from any url under this domain

(() => {
  const showCustomPlayer = () => {
    var playerPreview = document.getElementById("player-preview");
    var player = document.getElementById("player");
    playerPreview.parentElement.removeChild(playerPreview);
    player.style.display = "block";
    const customValue = document.getElementById('custom-input').value;
    player.setAttribute("src", "player.php?p=" + customValue);
    player.focus();
    countPlay(2822);
  };

  const container = document.querySelector('.container');
  if (!container) {
    console.error("No .container element found.");
    return;
  }

  // Create the editor container div
  const wrapper = document.createElement('div');
  wrapper.id = 'editor-container';
  wrapper.style.marginBottom = '1em';
  wrapper.style.padding = '1em';
  wrapper.style.border = '1px solid #ccc';

  const input = document.createElement('input');
  input.type = 'text';
  input.id = 'custom-input';
  input.placeholder = 'Enter custom value...';
  input.value = 'uploads/vfu9MRt53E_Star_Scroller_1.2.nx';
  input.style.marginRight = '1em';
  wrapper.appendChild(input);

  // Create button
  const button = document.createElement('button');
  button.textContent = 'Run NX File';
  button.onclick = showCustomPlayer;
  wrapper.appendChild(button);

  // Insert wrapper before the container element
  container.parentNode.insertBefore(wrapper, container);
})();


SP4CEBAR 2025-06-28 16:53 (Edited)

Wait what? I did it!, Here's an online Code Editor

note: scroll down, a newer version is available
Follow the instructions from the previous code block but use the code below and write code in the text field instead of urls player.php is more tolerant to what url it gets than I thought

(() => {
  const runCustomCode = () => {
    var playerPreview = document.getElementById("player-preview");
    /** @type {HTMLIFrameElement} */
    var player = document.getElementById("player");
    playerPreview.parentElement.removeChild(playerPreview);
    player.style.display = "block";

    // Get code from textarea
    var code = document.getElementById("basic-code").value;
    var blob = new Blob([code], { type: "text/plain" });
    var dataUrl = URL.createObjectURL(blob);

    player.setAttribute("src", "player.php?p=" + dataUrl);
    player.focus();
    countPlay(2822);
  };

  const container = document.querySelector('.container');
  if (!container) {
    console.error("No .container element found.");
    return;
  }

  // Create the editor container div
  const wrapper = document.createElement('div');
  wrapper.id = 'editor-container';
  wrapper.style.marginBottom = '1em';
  wrapper.style.padding = '1em';
  wrapper.style.border = '1px solid #ccc';

  // Create textarea
  const textarea = document.createElement('textarea');
  textarea.id = 'basic-code';
  textarea.rows = 10;
  textarea.cols = 60;
  textarea.placeholder = 'Enter BASIC code here...';
  textarea.textContent = 'PRINT "HELLO WORLD"';

  // Create button
  const button = document.createElement('button');
  button.textContent = 'Run Custom Code';
  button.onclick = runCustomCode;

  // Append textarea and button to wrapper
  wrapper.appendChild(textarea);
  wrapper.appendChild(document.createElement('br'));
  wrapper.appendChild(button);

  // Insert wrapper before the container element
  container.parentNode.insertBefore(wrapper, container);
})();


SP4CEBAR 2025-06-28 17:01

It actually works, for big programs too
wow I did not expect that
you just can't rerun it easily in the current version of this script I wrote


SP4CEBAR 2025-06-28 17:08 (Edited)

Latest injected editor

this can be turned into a browser extention
this version allows re-running code

Instructions:

Attention: Before following the instructions, I can recommend to review the code as this does change the behavior of your local version of the site.

  1. Open any NX program page like Lowres Galaxy.
  2. Open your browser's developer tools on this page (press F12).
  3. Go to the "Console" tab in the dev tools.
  4. Click on the empty space below the console messages to type a console command.
  5. Paste the script below and press enter.
    • Note: only do this if you trust the script.
  6. On the web page you should see a new text input field and a button labeled "Run NX Code", type code in the input field and click the button to run it.

Code To Copy

(() => {
  /** 
    This is a modification of the showPlayer function found in the DOM.
    It encodes your written program as a blob and starts the embedded 
    player.php (the NX player window) with this blob as its loaded NX 
    program.
  */
  const runCustomCode = () => {
    var playerPreview = document.getElementById("player-preview");
    /** @type {HTMLIFrameElement} The NX player window */
    var player = document.getElementById("player");
    if (playerPreview) {
      playerPreview.parentElement.removeChild(playerPreview);
    }
    player.style.display = "block";

    // Clear the iframe before using it
    player.removeAttribute("src");
    player.src = "about:blank";

    // Get code from textarea
    var code = document.getElementById("basic-code").value;

    // Encode code as blob url
    var blob = new Blob([code], { type: "text/plain" });
    var dataUrl = URL.createObjectURL(blob);

    // Loads the player.php with a program into the player window
    player.setAttribute("src", "player.php?p=" + dataUrl);
    player.focus();
  };

  // Gets the element above which the code block will be inserted
  const gridElement = document.querySelector('.grid');
  if (!gridElement) {
    console.error("No .grid element found.");
    return;
  }

  // Create the editor container div
  const wrapper = document.createElement('div');
  wrapper.id = 'editor-container';
  wrapper.style.marginBottom = '1em';
  wrapper.style.padding = '1em';
  wrapper.style.border = '1px solid #ccc';

  // Create textarea
  const textarea = document.createElement('textarea');
  textarea.id = 'basic-code';
  textarea.rows = 10;
  textarea.cols = 60;
  textarea.placeholder = 'Enter BASIC code here...';
  textarea.textContent = 'PRINT "HELLO WORLD"';

  // Create button
  const button = document.createElement('button');
  button.textContent = 'Run NX Code';
  button.onclick = runCustomCode;

  // Append textarea and button to wrapper
  wrapper.appendChild(textarea);
  wrapper.appendChild(document.createElement('br'));
  wrapper.appendChild(button);

  // Insert wrapper before the grid element
  gridElement.parentNode.insertBefore(wrapper, gridElement);
})();


SP4CEBAR 2025-06-28 17:38

I'm working on an NX editor website: GitHub


SP4CEBAR 2025-06-28 17:45 (Edited)

You can see this editor site on sp4cebar.com/nx-editor But the embed of player.php does not work, probably because it blocks external domains like mine:

Error message on console:
Security Error: Content at https://lowresnx.inutilis.com/player.php?p=blob:https://sp4cebar.com/8f771b44-f573-4282-ad0e-504ff437764e may not load data from blob:https://sp4cebar.com/8f771b44-f573-4282-ad0e-504ff437764e.


SP4CEBAR 2025-06-28 21:31

I fixed the editor website by using the embedded NX web player with a small modification so it can import code through a URI parameter.

I started a new topic for this website here


Log in to reply.