Get HTML from Safari [JS1]

A JavaScript one-liner to get the HTML from a Safari webpage


A single line of JavaScript to get the HTML from a webpage opened in Safari. Not the webpage source, but the HTML after any modifications made by JavaScript or the user.

This was one of the ingredients of one of my oldest shortcuts, View Current Page Source (Nov'18). Why now? Because I've been asked about it twice in the last week :-D

Don't download the shortcut

If you just want the code, there's no need to download the shortcut. Copy this and paste it in a "Run JavaScript on Webpage" action:

completion(new XMLSerializer().serializeToString(document));

Latest Release Notes

1.0.0 - Sept. 28, 2020, 7:15 p.m.

First public version