From 9e77f0a5b13eed5b2df0a2a14e626827a78a240c Mon Sep 17 00:00:00 2001 From: CanadaHonk Date: Sun, 9 Apr 2023 00:27:43 +0100 Subject: [PATCH] typedef: add resources api --- gluon.d.ts | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/gluon.d.ts b/gluon.d.ts index 1cb5369..7c18c2a 100644 --- a/gluon.d.ts +++ b/gluon.d.ts @@ -435,6 +435,27 @@ type ControlsApi = { ): Promise }; +type CSSResource = { + /** Remove the CSS previously added from the current page and future page loads. */ + remove(): Promise, + + /** Update the CSS previously added to new code given in the current page and future page loads. */ + modify(newCode: string): Promise +}; + +type JSResource = { + /** Remove the JS previously added so it no longer executes in new page loads. */ + remove(): Promise +}; + +type ResourcesApi = { + /** Inject CSS to the current page and future page loads (refresh, navigations, etc). */ + css(code: string): Promise, + + /** Inject JS to the current page and future page loads (refresh, navigations, etc). */ + js(code: string): Promise +}; + type Window = { /** API for the page of the window. */ page: PageApi, @@ -445,6 +466,9 @@ type Window = { /** API for manually using CDP with the browser. */ cdp: CDPApi, + /** API for injecting resources like CSS and JS. */ + resources: ResourcesApi, + /** * API for Gluon idle management (like hibernation). Chromium only. * @experimental