Copy Minified Code for Mobile
code

  
  
javascript:(function(){

  /* -------------------------------------------------
     STEP 1 — USER CLICKS PARENT CHAT CONTAINER
  ------------------------------------------------- */

  alert("Click the chat container or section you want to start overflow fixing from.");

  function clickHandler(ev) {
    ev.preventDefault();
    ev.stopPropagation();

    const start = ev.target;
    document.removeEventListener('click', clickHandler, true);

    /* -------------------------------------------------
       STEP 2 — APPLY OVERFLOW FIX UPWARD
    ------------------------------------------------- */

    let el = start;
    while (el && el !== document.documentElement) {
      el.style.setProperty('overflow','visible','important');
      el.style.setProperty('overflow-y','visible','important');
      el.style.setProperty('overflow-x','visible','important');
      el.style.setProperty('max-height','none','important');
      el.style.setProperty('height','auto','important');
      el.style.setProperty('max-width','none','important');
      el.style.setProperty('width','auto','important');
      el = el.parentElement;
    }

    alert("Overflow unlocked. Now choose which message to isolate.");

    /* -------------------------------------------------
       STEP 3 — ASK WHICH MESSAGE NUMBER TO KEEP
    ------------------------------------------------- */

    let n = prompt("Which message number (1 = most recent)?");
    if (!n) return;
    n = parseInt(n, 10);
    if (!n) return;

    let msgs = Array.from(
      document.querySelectorAll('[data-message-id]')
    );

    msgs.reverse(); // newest message now index 0

    if (n < 1 || n > msgs.length) {
      alert("Invalid index");
      return;
    }

    /* -------------------------------------------------
       STEP 4 — ISOLATE TARGET MESSAGE
    ------------------------------------------------- */

    msgs.forEach((msg, i) => {
      if (i !== (n - 1)) msg.remove();
    });

    msgs[n - 1].classList.add("target-element-e");

    const targets = document.querySelectorAll(".target-element-e");
    if (!targets.length) return;

    targets.forEach(target => {

      // mark descendants
      target.querySelectorAll("*").forEach(child =>
        child.classList.add("target-element-e")
      );

      // mark ancestors
      let el2 = target;
      while (el2) {
        el2.classList.add("target-element-e");
        el2 = el2.parentElement;
      }
    });

    // hide everything else
    document.querySelectorAll("*").forEach(el3 => {
      if (!el3.classList.contains("target-element-e")) {
        el3.style.display = "none";
      }
    });

  }

  document.addEventListener('click', clickHandler, true);

})();







    

  

How to Install a Bookmarklet on iPhone Safari

Follow these steps to add a custom JavaScript bookmarklet to Safari on iOS:

Step 1 - Add a Normal Bookmark

  1. Open Safari.
  2. Tap the Share button.
  3. Select Add Bookmark.
  4. Name it anything you want - for example: Fix ChatGPT Printing.
  5. Save it (Favorites is recommended).

Step 2 - Edit the Bookmark

  1. Open your bookmarks.
  2. Tap Edit.
  3. Select the bookmark you created.
  4. Replace the URL with your JavaScript code, beginning with javascript:.
  5. Tap Done.

Step 3 - Use the Bookmarklet

  1. Navigate to the webpage where you want the script to run (e.g., ChatGPT).
  2. Open your bookmarks.
  3. Tap the bookmarklet.
  4. Your JavaScript code runs instantly inside the page.

Example Bookmarklet Format

Here's the structure all bookmarklets follow:

javascript:(function(){
  /* your code here */
})();
  

You can paste any valid JavaScript inside that wrapper.