Skip to content

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

Open
@mrcolbyrussell

Description

@mrcolbyrussell

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions