Skip to content

Commit a3d504b

Browse files
snpshot added in browser
1 parent ca143b0 commit a3d504b

File tree

2 files changed

+39
-1
lines changed

2 files changed

+39
-1
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@codebolt/codeboltjs",
3-
"version": "1.1.37",
3+
"version": "1.1.38",
44
"description": "",
55
"keywords": [],
66
"author": "",

src/modules/browser.ts

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,44 @@ const cbbrowser = {
152152
});
153153
});
154154
},
155+
/**
156+
* Retrieves the snapshot of the current page.
157+
* @returns {Promise<GetContentResponse>} A promise that resolves with the content.
158+
*/
159+
getSnapShot: ():Promise<any> => {
160+
161+
return new Promise((resolve, reject) => {
162+
cbws.getWebsocket.send(JSON.stringify({
163+
"type": "browserEvent",
164+
action: 'getSnapShot'
165+
}));
166+
cbws.getWebsocket.on('message', (data: string) => {
167+
const response = JSON.parse(data);
168+
if (response.event === "getSnapShotResponse") {
169+
resolve(response);
170+
}
171+
});
172+
});
173+
},
174+
/**
175+
* Retrieves browser info like height width scrollx scrolly of the current page.
176+
* @returns {Promise<GetContentResponse>} A promise that resolves with the content.
177+
*/
178+
getBrowserInfo: ():Promise<any> => {
179+
180+
return new Promise((resolve, reject) => {
181+
cbws.getWebsocket.send(JSON.stringify({
182+
"type": "browserEvent",
183+
action: 'getBrowserInfo'
184+
}));
185+
cbws.getWebsocket.on('message', (data: string) => {
186+
const response = JSON.parse(data);
187+
if (response.event === "getBrowserInfoResponse") {
188+
resolve(response);
189+
}
190+
});
191+
});
192+
},
155193

156194
/**
157195
* Extracts text from the current page.

0 commit comments

Comments
 (0)