# US 2025/0148060 A1 · System and method for client-side rewriting of code included in a web page

> Agents: this data is available as JSON from the patentgrep API and MCP server — see https://patentgrep.com/llms.txt

- Number: US 2025/0148060 A1
- Document ID: US20250148060A1
- Status: Published application
- Kind: A1
- Application number: 19/017,076
- Filed: 2025-01-10
- Published: 2025-05-08
- Earliest claimed: 2022-04-27
- Assignees: Microsoft Technology Licensing, LLC
- Applicants: Microsoft Technology Licensing, LLC
- Inventors: Meir Baruch BLACHMAN; Itamar AZULAY
- Web page: https://patentgrep.com/patent/US20250148060A1

## CPC

- G06F 21/125: {by manipulating the program code, e.g. source code, compiled code, interpreted code, machine code}
- H04L 63/20: {for managing network security; network security policies in general (filtering policies H04L63/0227)}
- G06F 16/9566: {URL specific, e.g. using aliases, detecting broken or misspelled links}
- G06F 16/958: Organisation or management of web site content, e.g. publishing, maintaining pages or automatic linking
- G06F 21/54: by adding security routines or objects to programs
- H04L 63/0281: {Proxies}
- H04L 67/02: based on web technology, e.g. hypertext transfer protocol [HTTP]
- H04L 67/565: Conversion or adaptation of application format or content (adding application control or application functional data H04L67/561)
- G06F: ELECTRIC DIGITAL DATA PROCESSING (computer systems based on specific computational models G06N)
- H04L: TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION (arrangements common to telegraphic and telephonic communication H04M)

## Abstract

Systems and methods are described for client-side rewriting of web page code. A proxy computing device receives a web page from a server computing device and analyzes the web page to identify a code component. The proxy computing device generates a modified version of the web page by replacing the identified code component with a wrapped code component and including a code rewriting and evaluation function in the web page. The wrapped code component includes a call to the code rewriting and evaluation function that includes the identified code component as an argument thereof. The code rewriting and evaluation function is configured to generate a rewritten code component by rewriting the identified code component and to evaluate the rewritten code component. The proxy computing device sends the modified version of the web page to a client computing device that is configured to load the modified version of the web page.

## Claims

### Claim 1

A client computing device communicatively coupled to a proxy computing device, the client computing device comprising:
a processor; and
a memory storing program code structured to cause the processor to:
receive, from the proxy computing device, a code rewriting and evaluation function,
responsive to sending a first request for a resource to the proxy computing device, receive a modified version of the resource from the proxy computing device, the modified version of the resource comprising a wrapped code component replacing a code component in the resource and comprising a call of the code rewriting and evaluation function, the call comprising the code component as an argument thereof,
execute the modified version of the resource, and
cause execution of the call, causing:
rewriting of the code component, resulting in a rewritten code component, and
evaluation of the rewritten code component.

### Claim 2 (depends on 1)

The client computing device of claim 1, wherein the first request for the resource causes the proxy computing device to:
organize a plurality of code components of the resource into an abstract syntax tree (AST);
identify the code component based on traversal of the AST;
responsive to identification of the code component, replace the code component with the wrapped code component.

### Claim 3 (depends on 1)

The client computing device of claim 1, wherein to receive the code rewriting and evaluation function, the program code is structured to cause the processor to:
receive the code rewriting and evaluation function in the modified version of the resource.

### Claim 4 (depends on 1)

The client computing device of claim 1, wherein to receive the code rewriting and evaluation function, the program code is structured to cause the processor to:
receive code rewriting and evaluation function in a response to a second request transmitted to the proxy computing device, the second request transmitted prior to the first request.

### Claim 5 (depends on 1)

The client computing device of claim 1, wherein the program code is further structured to cause the processor to:
store the code rewriting and evaluation function in a storage accessible to the processor.

### Claim 6 (depends on 5)

The client computing device of claim 5, wherein the modified version of the resource comprises a reference to the code rewriting and evaluation function and to execute the modified resource, the program code is structured to cause the processor to:
load the code rewriting and evaluation function from the storage based on the reference.

### Claim 7 (depends on 6)

The client computing device of claim 6, wherein the reference comprises a prompt that causes loading a file comprising the code rewriting and evaluation function.

### Claim 8 (depends on 5)

The client computing device of claim 5, wherein the storage is a browser cache of a web browser executing on the client computing device.

### Claim 9

A method performed by a client computing device, the method comprising:
receiving, from a proxy computing device, a code rewriting and evaluation function;
storing the code rewriting and evaluating function in a storage accessible to the client computing device;
receiving, from the proxy computing device, a first resource comprising:
a reference to the code rewriting and evaluation function, and
a call of the code rewriting and evaluation function comprising a code component as an argument thereof;
accessing the code rewriting and evaluation function stored in the storage; and
causing execution of the call of the code rewriting and evaluation function, the execution causing:
rewriting of the code component, resulting in a rewritten code component, and
evaluation of the rewritten code component.

### Claim 10 (depends on 9)

The method of claim 9, further comprising:
transmitting a request for the first resource, wherein said transmitting the request causes the proxy computing device to:
organize a plurality of code components of the first resource into an abstract syntax tree (AST);
identify the code component based on traversal of the AST; and
responsive to identification of the code component, replace the code component with the wrapped code component.

### Claim 11 (depends on 9)

The method of claim 9, wherein said receiving the code rewriting and evaluation function comprises:
transmitting, to the proxy computing device, a request for a file comprising the code rewriting and evaluation function; and
responsive to said transmitting the request, receiving the file.

### Claim 12 (depends on 9)

The method of claim 9, wherein said receiving the code rewriting and evaluation function comprises:
transmitting, to the proxy computing device, a request for a second resource; and
receiving a modified version of the second resource, the modified version comprising the code rewriting and evaluation function.

### Claim 13 (depends on 9)

The method of claim 9, wherein the reference comprises a prompt that causes loading a file comprising the code rewriting and evaluation function.

### Claim 14 (depends on 9)

The method of claim 9, wherein the storage is a browser cache of a web browser executing on the client computing device.

### Claim 15

A computer-readable storage medium having programming instructions encoded thereon, the programming instructions structured to cause a processor of a client computing device to perform a method comprising:
receiving, from a proxy computing device, a code rewriting and evaluation function;
receiving a modified version of the resource from the proxy computing device, the modified version of the resource comprising a wrapped code component replacing a code component in the resource and comprising a call of the code rewriting and evaluation function, the call comprising the code component as an argument thereof;
executing the modified version of the resource; and
causing execution of the call, the execution of the call comprising:
rewriting of the code component, resulting in a rewritten code component, and
evaluating of the rewritten code component.

### Claim 16 (depends on 15)

The computer-readable storage medium of claim 15, wherein the method further comprises:
transmitting a first request to the proxy computing device, the request causing the proxy computing device to:
organize a plurality of code components of the resource into an abstract syntax tree (AST);
identify the code component based on traversal of the AST;
responsive to identification of the code component, replace the code component with the wrapped code component.

### Claim 17 (depends on 16)

The computer-readable storage medium of claim 16, wherein said receiving the code rewriting and evaluation function comprises:
receiving the code rewriting and evaluation function in a response to a second request transmitted to the proxy computing device, the second request transmitted prior to the first request.

### Claim 18 (depends on 15)

The computer-readable storage medium of claim 15, wherein said receiving the code rewriting and evaluation function comprises:
receiving the code rewriting and evaluation function in the modified version of the resource.

### Claim 19 (depends on 15)

The computer-readable storage medium of claim 15, wherein the method further comprises:
storing the code rewriting and evaluation function in a storage accessible to the processor.

### Claim 20 (depends on 19)

The computer-readable storage medium of claim 19, wherein the modified version of the resource comprises a reference to the code rewriting and evaluation function and said executing the modified resource further comprises:
loading the code rewriting and evaluation function from the storage based on the reference.
