claude-export icon indicating copy to clipboard operation
claude-export copied to clipboard

Markdown copy fails with `e is null`

Open akaihola opened this issue 1 year ago • 1 comments

I did the following on Firefox:

  • copy the md.min.js script from https://github.com/ryanschiang/claude-export/blob/main/dist/md.min.js using the Copy raw file icon
  • open a Claude 3.5 Sonnet chat (URL is like https://claude.ai/chat/<uuid>)
  • open the JS console by hitting F12 and clicking on the Console tab
  • paste and execute the md.min.js script by hitting Ctrl-V and Enter

I got the following error:

Uncaught TypeError: e is null    debugger eval code:1:1191
    exports debugger eval code:1
    <anonymous> debugger eval code:1
    <anonymous> debugger eval code:1
    <anonymous> debugger eval code:1

akaihola avatar Jul 07 '24 08:07 akaihola

I un-minified md.min.js using unminify and ran that on the same chat. Now the error is:

Uncaught TypeError: e is null    debugger eval code:60:30
    exports debugger eval code:60
    <anonymous> debugger eval code:81
    <anonymous> debugger eval code:157
    <anonymous> debugger eval code:158

In the un-minified script, the mentioned lines with some context are:

    55	            361: (e) => {
    56	                e.exports = function () {
    57	                    var e = document.querySelector("div.flex-1.flex.flex-col.gap-3.px-4.pt-16"),
    58	                        t = document.querySelector("button[data-testid='chat-menu-trigger']"),
    59	                        n = t ? t.textContent : "";
**  60	                    return {
                                elements: e.querySelectorAll(
                                    "div.font-claude-message, div.font-user-message"
                                ),
                                title: n
                            };
    61	                };
    62	            },

(the word elements on line 60 starts in column 30)

    76	    (e = r(255)),
    77	        (t = r(380)),
    78	        (n = r(361)),
    79	        (function () {
    80	            var o = "",
**  81	                a = n(),
    82	                r = a.elements,
    83	                c = a.title,
    84	                i = t();
   153	                    f.nodeType === Node.TEXT_NODE && (o += "\n");
   154	                }
   155	            }
   156	            e(console, "md", c), console.save(o);
** 157	        })();
** 158	})();

(script ends on line 158)

akaihola avatar Jul 07 '24 08:07 akaihola

Thank you for your contribution! The issue should be fixed as Sep 24, although I missed your PR earlier.

ryanschiang avatar Dec 10 '24 18:12 ryanschiang