rewrite page.title as a function
This commit is contained in:
parent
9ea7835bb6
commit
8e36c19f11
10
gluon.d.ts
vendored
10
gluon.d.ts
vendored
@ -11,8 +11,14 @@ type PageApi = {
|
||||
/** Promise for waiting until the page has loaded. */
|
||||
loaded: Promise<void>,
|
||||
|
||||
/** Get or set the title of the page (async) */
|
||||
title: Promise<string>
|
||||
/**
|
||||
* Get or set the title of the page.
|
||||
* Use no arguments to get the title, or provide a string to set it.
|
||||
*/
|
||||
title: (
|
||||
/** Set the page title to a new title. */
|
||||
newTitle: string
|
||||
) => Promise<string>
|
||||
};
|
||||
|
||||
type IPCStoreApi = {
|
||||
|
@ -99,8 +99,10 @@ export default async (CDP, proc, injectionType = 'browser', { browserName, brows
|
||||
eval: evalInWindow,
|
||||
loaded: pageLoadPromise,
|
||||
|
||||
get title() { return evalInWindow('document.title'); },
|
||||
set title(val) { return evalInWindow(`document.title = \`${val}\``); }
|
||||
title: val => {
|
||||
if (!val) return evalInWindow('document.title');
|
||||
return evalInWindow(`document.title = \`${val}\``);
|
||||
}
|
||||
},
|
||||
|
||||
ipc: IPC,
|
||||
|
Loading…
x
Reference in New Issue
Block a user