mirror of
https://github.com/garrytan/gstack.git
synced 2026-05-02 03:35:09 +02:00
refactor: remove unnecessary return await in content-security and read-commands
Remove 6 redundant return-await patterns where there's no enclosing try block. Eliminates all defensive.async-noise findings from these files. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -85,7 +85,7 @@ const ARIA_INJECTION_PATTERNS = [
|
||||
* - ARIA labels with injection patterns
|
||||
*/
|
||||
export async function markHiddenElements(page: Page | Frame): Promise<string[]> {
|
||||
return await page.evaluate((ariaPatterns: string[]) => {
|
||||
return page.evaluate((ariaPatterns: string[]) => {
|
||||
const found: string[] = [];
|
||||
const elements = document.querySelectorAll('body *');
|
||||
|
||||
@@ -167,7 +167,7 @@ export async function markHiddenElements(page: Page | Frame): Promise<string[]>
|
||||
* Uses clone + remove approach: clones body, removes marked elements, returns innerText.
|
||||
*/
|
||||
export async function getCleanTextWithStripping(page: Page | Frame): Promise<string> {
|
||||
return await page.evaluate(() => {
|
||||
return page.evaluate(() => {
|
||||
const body = document.body;
|
||||
if (!body) return '';
|
||||
const clone = body.cloneNode(true) as HTMLElement;
|
||||
|
||||
@@ -49,7 +49,7 @@ function wrapForEvaluate(code: string): string {
|
||||
* Exported for DRY reuse in meta-commands (diff).
|
||||
*/
|
||||
export async function getCleanText(page: Page | Frame): Promise<string> {
|
||||
return await page.evaluate(() => {
|
||||
return page.evaluate(() => {
|
||||
const body = document.body;
|
||||
if (!body) return '';
|
||||
const clone = body.cloneNode(true) as HTMLElement;
|
||||
@@ -73,7 +73,7 @@ export async function handleReadCommand(
|
||||
|
||||
switch (command) {
|
||||
case 'text': {
|
||||
return await getCleanText(target);
|
||||
return getCleanText(target);
|
||||
}
|
||||
|
||||
case 'html': {
|
||||
@@ -81,9 +81,9 @@ export async function handleReadCommand(
|
||||
if (selector) {
|
||||
const resolved = await session.resolveRef(selector);
|
||||
if ('locator' in resolved) {
|
||||
return await resolved.locator.innerHTML({ timeout: 5000 });
|
||||
return resolved.locator.innerHTML({ timeout: 5000 });
|
||||
}
|
||||
return await target.locator(resolved.selector).innerHTML({ timeout: 5000 });
|
||||
return target.locator(resolved.selector).innerHTML({ timeout: 5000 });
|
||||
}
|
||||
// page.content() is page-only; use evaluate for frame compat
|
||||
const doctype = await target.evaluate(() => {
|
||||
|
||||
Reference in New Issue
Block a user