Pin a script so it runs in every new document and can be reused by ``execute()``. Args: function_declaration: The JavaScript function declaration to pin, e.g. ``"() => { window.helper = () => 42 }"``. Returns: A ``PinnedScript`` to pass to ``
(self, function_declaration: str)
| 296 | return context_id |
| 297 | |
| 298 | def pin(self, function_declaration: str) -> PinnedScript: |
| 299 | """Pin a script so it runs in every new document and can be reused by ``execute()``. |
| 300 | |
| 301 | Args: |
| 302 | function_declaration: The JavaScript function declaration to pin, |
| 303 | e.g. ``"() => { window.helper = () => 42 }"``. |
| 304 | |
| 305 | Returns: |
| 306 | A ``PinnedScript`` to pass to ``execute()`` and ``unpin()``. |
| 307 | """ |
| 308 | return self._script.pin(function_declaration) |
| 309 | |
| 310 | def unpin(self, script_id: PinnedScript | str) -> None: |
| 311 | """Remove a pinned script. |