Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wombat should clean up after itself in inline script blocks #166

Open
mrcolbyrussell opened this issue Aug 12, 2024 · 2 comments
Open

wombat should clean up after itself in inline script blocks #166

mrcolbyrussell opened this issue Aug 12, 2024 · 2 comments

Comments

@mrcolbyrussell
Copy link

mrcolbyrussell commented Aug 12, 2024

I've been experimenting with the largely unrecognized ability for modern web browsers to enable literate programming. For context, refer to:

I'll focus on the latter as a test case. Steps to reproduce:

  1. Visit https://www.colbyrussell.com/LP/leave-pocket-casts/
  2. Read (or skim) the page, paying particular attention to the contents of the program modules as they are written out in inline scripts
  3. Open the same page in the Hypothes.is proxy https://via.hypothes.is/https://www.colbyrussell.com/LP/leave-pocket-casts/
  4. Skim over the page again

Actual results:

All the script elements containing inline scripts (which are visible on the page, for reasons described in plain.txt.htm), are all mutated with wombat's prologue to intercede on the use of globals, and this is all shown to the reader.

Expected results:

No wombat spam visible.

The fix:

Unlike with CSS and style elements, the text content of script elements containing inline script blocks is not live. Changing the value of the text node inside a style element at runtime has the effect of changing the applied style sheet, but the effect of changing the text of a script element at runtime is nil. So wombat should clean up after itself by iterating all of the script elements on a page, locating the prologue, and then deleting it.

Screenshot:
Two browser windows side-by-side, showing the /LP/leave-pocket-casts document.  In the leftmost window, the first program module on the page appears as intended.  In the rightmost window, the document is actually loaded through Hypothes.is's "Via" service.  The first program module on the page has a conspicuous blob that starts out var _____WB$wombat$assign$function_____ = function(name) {return (self._wb_wombat, followed by 11 other lines where wombat overrides page globals.

@ikreymer
Copy link
Member

Hm, this may be possible, but would be a bit tricky, since script elements can be removed and added dynamically. Possibly better approach would be to remove the wombat wrapping when returning the text of the script elements...

@mrcolbyrussell
Copy link
Author

mrcolbyrussell commented Sep 19, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants