A method and apparatus for generating a browser scripting function
By generating browser script code using natural language commands and combining it with an interactive interface, this technology solves the problem of high barriers to entry for existing browser script generation tools, enabling efficient and convenient customization of personalized web page functions.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- BEIJING SANKUAI ONLINE TECH CO LTD
- Filing Date
- 2026-03-02
- Publication Date
- 2026-06-05
AI Technical Summary
Existing browser script generation tools rely on professional programming knowledge, which is a high barrier to entry and makes it difficult to achieve personalized customization for non-professional users. Furthermore, the efficiency of script generation and debugging is low.
This paper provides a method for generating browser script functions. It generates script code through natural language instructions and combines the script to generate an interactive interface. It supports the visual trial run and persistent storage of the script. It adopts a secure sandbox encapsulation and unified management mechanism to achieve controllable triggering and fine-grained configuration of the script.
It lowers the barrier to entry for creating browser script functions, provides a "what you see is what you get" user experience, improves script generation and debugging efficiency, and enables efficient and personalized web page function customization.
Smart Images

Figure CN122152295A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of Internet technology, and in particular to a method for generating browser script functionality. Background Technology
[0002] With the widespread adoption of internet technology, browser scripts have become an important means for users to customize webpage functions and improve operational efficiency. By running custom scripts on the browser side, users can process webpage content or optimize its behavior in real time according to their individual needs.
[0003] In existing script creation and management scenarios, users still primarily rely on professional programming knowledge. Users need to manually write complex code logic and repeatedly switch between independent editing environments and web environments to verify the script's execution. This highly manual coding approach and fragmented interaction flow make it difficult for non-professional users to quickly translate their needs into executable script functions. Furthermore, script debugging and refinement are inefficient, failing to meet the growing demands for automated web processing and personalized customization. Summary of the Invention
[0004] This application provides a method and device for generating browser script functionality. The technical solution is as follows: In a first aspect, embodiments of this application provide a method for generating browser script functionality, characterized by comprising: responding to a script functionality creation operation on a browser interactive interface, displaying a script generation interactive interface; generating script code based on a natural language creation instruction input in the script generation interactive interface, and displaying the script code and an execution control and / or a save control associated with the script code; executing the script code in the runtime environment of the browser's current page in response to a trigger instruction for the execution control; or, storing the generated script functionality in response to a trigger instruction for the save control.
[0005] In one possible implementation, the method further includes the script function creation operation comprising: Enter a preset trigger identifier in the browser input area; or, select a script creation control in the browser toolbar or function panel.
[0006] In one possible implementation, the function of storing the generated script includes: If the current session is not associated with an existing script function, a new script function is created; if the current session is associated with an existing script function, a storage mode option is displayed, and in response to a selection instruction for the storage mode option, the existing script function is updated or a new script function is created.
[0007] In one possible implementation, the method further includes: the generated script code, comprising: The natural language creation instructions and the context information of the current page are input into a preset generation model to obtain the script code corresponding to the context information of the current page.
[0008] In one possible implementation, the method further includes: the generated script code, which also includes: The generated raw code is encapsulated in a preset logic block to generate the script code; wherein the preset logic block includes an immediately invoked function expression or an exception handling block.
[0009] In one possible implementation, the response to the trigger command for the save control further includes: displaying a script configuration interface, the script configuration interface including an effective scope option and a trigger strategy option, the effective scope option being used for a specific Uniform Resource Locator or Domain Name matching rule, and the trigger strategy option being used to indicate an automatic run or manual trigger mode.
[0010] In one possible implementation, the method further includes: generating updated script code in response to a natural language modification instruction for the script code.
[0011] In one possible implementation, the method further includes: determining the natural language creation instruction by: storing the script code as a generated script function in response to a selection operation for script code displayed in historical dialogue messages.
[0012] In one possible implementation, the method further includes: if the current user's login status is not logged in, then triggering login guidance.
[0013] In a second aspect, embodiments of this application provide an electronic device, including a memory and a processor, wherein the processor executes a computer program stored in the memory to implement the method as described in any one of claims 1-9.
[0014] The technical solution provided in this application provides at least the following beneficial effects: The technical solution provided in this application can directly generate script code adapted to the current webpage context through dialogue commands, and supports visual trial runs of the script effects before saving. It provides users with a "what you see is what you get" script creation experience, lowers the barrier to creating browser script functions, eliminates the technical barriers to writing code, and shortens the transformation path from requirements to functions, thereby achieving efficient, convenient, and personalized webpage function customization. Attached Figure Description
[0015] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0016] Figure 1 The diagram illustrates a method for generating browser script functionality according to an embodiment of the present disclosure.
[0017] Figure 2 A schematic diagram of a device for generating browser script functionality is shown.
[0018] Figure 3 A schematic diagram of an electronic device structure is shown. Detailed Implementation
[0019] To make the objectives, technical solutions, and advantages of this application clearer, the embodiments of this application will be described in further detail below with reference to the accompanying drawings.
[0020] Example embodiments will be described more fully with reference to the accompanying drawings. However, example embodiments can be implemented in many forms and should not be construed as limited to the examples set forth herein; rather, these embodiments are provided to make this disclosure more comprehensive and complete, and to fully convey the concept of example embodiments to those skilled in the art. The described features, structures, or characteristics can be combined in any suitable manner in one or more embodiments. In the following description, numerous specific details are provided to give a full understanding of embodiments of this disclosure. However, those skilled in the art will recognize that the technical solutions of this disclosure can be practiced with one or more of the specific details omitted, or other methods, components, apparatus, steps, etc., can be employed. In other instances, well-known technical solutions are not shown or described in detail to avoid obscuring various aspects of this disclosure.
[0021] Furthermore, the accompanying drawings are merely illustrative of this disclosure and are not necessarily drawn to scale. The same reference numerals in the drawings denote the same or similar parts, and therefore repeated descriptions of them will be omitted. Some block diagrams shown in the drawings are functional entities and do not necessarily correspond to physically or logically independent entities. These functional entities may be implemented in software, in one or more hardware modules or integrated circuits, or in different network and / or processor devices and / or microcontroller devices.
[0022] Existing browsers or plug-in scripting tools typically suffer from the following shortcomings: scripts often exist as temporary commands, lacking persistent storage and a unified management entry point; script execution is weakly bound to the webpage scenario, lacking fine-grained control over the scope of effect, and prone to accidental triggering; script generation and modification have high barriers to entry, relying on manual code writing and lacking stable execution feedback. This disclosure integrates scripting capabilities into the browser's "tricks" system, enabling script generation and modification through conversational interaction, and combining URL filtering and persistence rules to achieve scripts that are savable, manageable, reusable, and controllable in triggering.
[0023] Next, with reference to the accompanying drawings, each step and specific embodiment of a browser script function generation method according to an embodiment of the present disclosure will be described in detail.
[0024] Step S110: In response to the script creation operation of the browser interactive interface, display the script generation interactive interface.
[0025] The browser provides a unified entry point for "Tips," with scripts being a core type of tip. The system creates or switches to a new conversation while keeping the current webpage URL unchanged, prompting the user to input their script requirements in the interactive interface (such as the conversation area).
[0026] In some embodiments of this disclosure, in order to provide a convenient triggering method to meet the usage habits of different users in different scenarios, the browser provides a unified entry point for "tips" in multiple dimensions. As a core type of tip, the triggering mechanism for script creation operations includes, but is not limited to, the following specific implementation methods: Shortcut triggering: In any dialog input area of the browser (such as the AI assistant input box in the sidebar), the user directly enters a preset trigger identifier. For example, entering " / script" or " / script". After the keyboard event listener of the front-end input box captures the identifier, it immediately triggers a state machine state switch, changing the current input box mode from "normal question and answer mode" to "script creation mode", and pops up a dedicated UI prompt for script creation above the input box (such as "Please describe the script function you need...").
[0027] Panel control trigger: A clear "+Create Script" button is provided in the browser's sidebar panel, the "Tips Center" on the homepage panel, or the extended function area on the right side of the address bar. In response to click or touch operations on this control, the system displays the script generation interactive interface by sliding out from the side of the screen or as a modal window, while keeping the current webpage URL and rendering state completely unchanged.
[0028] Context menu trigger (right-click menu): When a user right-clicks on a specific element (such as an image or table) on the current webpage, the system provides the option to "Generate script based on this element" in the right-click menu. After selecting this option, the system not only displays the script generation interface, but also automatically uses the CSS selector or XPath of the webpage element selected by the user as implicit parameters and incorporates them into the subsequent generation process.
[0029] Step S120: Based on the natural language creation instructions entered in the script generation interactive interface, generate script code and display the script code and the execution control and / or save control associated with the script code.
[0030] In this embodiment, users do not need to write code directly; they only need to express their needs through natural language. The system generates corresponding script content based on user input and displays the generated result in a dialog-based interactive interface. Simultaneously, interactive controls such as "Execute" and "Save" are provided in the code area.
[0031] In some embodiments of this disclosure, to address the shortcomings of traditional script generation tools that are detached from the actual webpage environment and result in inaccurate code manipulation of webpage elements, the system, upon receiving the user's natural language creation instruction, does not directly generate code. Instead, the browser kernel or extension first performs a context snapshot capture operation of the current page. Specifically, the current page context information extraction process includes: obtaining the basic metadata of the current page, such as the complete Uniform Resource Locator (URL), domain name, and page title; simultaneously, to avoid transmitting the entire massive webpage source code, which could lead to processing timeouts or exceeding the input limits of the generation model, the system traverses the current page's Document Object Model (DOM) tree, removing semantically meaningless or non-visual tag nodes (such as style tags, script tags, etc.), and focusing on extracting the hierarchical structure of core visible elements with specific attribute identifiers (such as ID, Class, etc.), thereby generating a lightweight DOM summary. Subsequently, the system concatenates the natural language creation instruction with the extracted context information according to a preset prompt word template and inputs it into the preset generation model. This generation method, which combines the actual operating environment of the webpage, enables the output script code to accurately match and act on specific elements of the current target webpage.
[0032] Furthermore, considering that the original code output by the generated model may pose security risks such as variable naming conflicts, global environment pollution, or uncaught runtime errors when directly injected into the browser runtime, this embodiment of the disclosure further includes a step of secure sandboxing encapsulation after obtaining the original code. Specifically, the system performs abstract syntax tree parsing or string-level reconstruction on the original code at the front-end or back-end, forcibly encapsulating it in a preset logic block. The preset logic block mainly includes an immediately invoked function expression (IIFE) and an exception handling block nested within it. By using an immediately invoked function expression, the system strictly restricts all variables declared in the original code to their local scope, completely eliminating the risk of conflicts with native script variables or other browser plugin variables. At the same time, the outer exception handling block is used to monitor the running status in real time during script execution. Once there is a fatal error in the original code logic (such as attempting to operate on a node that does not exist on the current page), the exception handling block can safely capture the error and prevent the exception from being thrown to the outer layer, thereby avoiding the current webpage from crashing or freezing.
[0033] During the aforementioned security encapsulation process, the system also embeds status reporting logic within the exception handling block. When the script completes normal execution or an error is caught by the exception handling block, the encapsulated script securely transmits the success callback information or failure information containing the error stack to the browser's front-end presentation layer via the browser's native cross-window communication mechanism (such as the postMessage interface), so as to provide clear execution feedback to the user in subsequent steps.
[0034] After intelligent code generation and secure encapsulation, the system displays the final generated script code to the user in the script generation interactive interface (i.e., the dialogue flow interface) with a specific visual style (e.g., a code display area with syntax highlighting). Furthermore, the system dynamically renders interactive controls for triggering subsequent operations at associated locations within the code display area (e.g., the bottom or side of the area). These interactive controls include at least execution and save controls. At this point, the generated script code only temporarily resides in the memory context of the current dialogue session and has not yet been written to the underlying database. The system awaits the user to trigger the aforementioned controls for actual runtime testing or persistent storage.
[0035] Step S130: In response to a trigger instruction for the execution control, execute the script code in the runtime environment of the current page of the browser; or, in response to a trigger instruction for the save control, store the generated script function.
[0036] In some embodiments of this disclosure, when the system receives a trigger command for the execution control, it immediately injects temporarily generated script code into the current webpage's runtime environment for execution testing. To improve the perceptibility and debuggability of script execution, the system provides clear execution status feedback through the front-end interface after execution. Specifically, if the script code runs successfully, the system will display a success message in a prominent position on the interface (such as the top of the screen); if the script execution fails or an error is caught by the underlying exception handling block, the system will display a warning message indicating execution failure and provide error details for user reference.
[0037] On the other hand, when the system receives a trigger command for the save control, it will intercept the destruction process of the temporary script and display a script configuration interface (e.g., a save or edit pop-up) overlaid on the current screen. In this configuration interface, in addition to automatically filling in or allowing users to modify the script name and description information, the system also provides key options for the scope of application and the triggering strategy. The scope of application option allows users to configure specific Uniform Resource Locators (URLs) or domain name matching rules applicable to the script. Users can choose to apply the rule to all web pages or enter a specific URL rule containing wildcards. During the user's URL rule input, the system's underlying configuration and validation module performs real-time format validation and deduplication checks, i.e., it iterates through the existing rule set of the current script to determine whether the newly input rule conflicts with existing rules due to complete duplication or inclusion relationships. If an anomaly is detected, the system will prevent form submission and output corresponding error messages on the screen. The triggering strategy option indicates whether the script is in automatic or manual triggering mode.
[0038] Furthermore, upon completing the above configuration and confirming storage, the system follows the persistence rule of "first creation, subsequent updates" to effectively reduce the management costs of script version forks and duplicate creation. Specifically, the system detects the context state of the current conversation. If the current conversation is not yet associated with any existing script function entity, the system determines it as the first save, and then creates a new script entity in the underlying database and establishes a binding relationship between the script entity and the current conversation. If the current conversation is already associated with an existing script function entity (for example, the user makes minor adjustments to the script in the same conversation and saves it again), the system does not force the creation of a new copy. Instead, it displays storage mode options and, in response to the user's selection, directly updates the content and configuration of the already bound script function in the underlying database, while simultaneously prompting the user that the update was successful.
[0039] After the scripts are successfully persisted, this disclosure also provides a dynamic visibility filtering and precise triggering mechanism based on Uniform Resource Locators (URLs). When a user invokes the script list from different entry points in the browser (such as the homepage panel, input box list, sidebar panel, etc.), or when switching tabs in the browser causes the current page URL to change, the underlying effective scope matching module extracts the URL of the currently active page in real time and performs regular expression matching with the effective scope rules of each script in the underlying database. The system only filters the successfully matched scripts into the currently available script set for rendering and display, thereby dynamically filtering out scripts that do not match the current webpage, avoiding visual interference and accidental triggering on non-target webpages. At the same time, for scripts that are successfully matched and whose triggering strategy is configured to run automatically, the system will silently inject and execute them after the current webpage is loaded; while for scripts configured to be manually triggered, the system only displays their execution entry point, waiting for the user to actively click to trigger them.
[0040] Furthermore, to create a dialog-based iterative loop for the script, when a user clicks the "Modify" button in the script configuration interface, the system collapses the configuration interface, records the current configuration state, and refocuses the interaction on the dialog area. The system guides the user to input natural language modification commands and generates new script content based on the previous code. When the user saves the script again, it is written according to the aforementioned update rules. Simultaneously, considering that script execution involves high-level webpage operation permissions, the system verifies the user's login status at key operation nodes such as creation, saving, editing, and execution. If the system detects that the user is not logged in, it suspends the current operation and triggers login guidance to ensure the security of script assets, multi-device synchronization, and traceability of actions.
[0041] In some embodiments, for the generated script code described in step S120, this disclosure introduces a context-based intelligent generation and secure encapsulation mechanism.
[0042] Specifically, the generation of script code includes: inputting the natural language creation instructions and the context information of the current page into a preset generation model to obtain the script code corresponding to the context information of the current page.
[0043] For example, the system not only receives the user's request description in natural language, but also automatically extracts the context information of the current page (such as the DOM structure, key element features, page title, etc.). These two sets of data are input into a preset generation model, enabling the generated script code to accurately match and apply to the current target webpage, avoiding the generation of invalid code that is detached from the actual webpage environment.
[0044] Furthermore, to ensure the security and stability of the script running in the browser, the generation of script code further includes: encapsulating the generated original code in a preset logic block to generate the script code; wherein, the preset logic block includes an immediately invoked function expression or an exception handling block.
[0045] For example, after obtaining the original code generated by the model, the system automatically wraps it with an immediately invoked function expression (IIFE) to isolate variable scope and prevent script variables from polluting the browser's global environment. At the same time, an exception handling block (Try-Catch) is nested outside the code. When the script fails to run or an exception occurs, the exception handling block can catch the error and trigger the system frontend to give clear feedback (such as indicating execution failure), thereby improving the perceptibility and debuggability of script execution.
[0046] In some embodiments, this disclosure provides a fine-grained script configuration and persistent storage strategy in response to a trigger command for the save control as described in step S130.
[0047] Specifically, the response to the trigger command for the save control further includes: displaying a script configuration interface, the script configuration interface including an effective scope option and a trigger strategy option, the effective scope option being used for specific Uniform Resource Locator or Domain Name matching rules, and the trigger strategy option being used to indicate automatic operation or manual trigger mode.
[0048] For example, in response to a user's "save" operation, the system displays a script save pop-up (or edit pop-up). In this pop-up, the user can configure the "scope," which can be set to all web pages or specify multiple URLs (wildcards are supported, e.g., ...). .example.com / The system performs deduplication validation on the URLs entered by the user, preventing duplicate entries and displaying an error message. Users can also configure an "Auto-run" switch: if enabled, the system will automatically execute the corresponding script when the user subsequently enters a webpage within the matching range; if set to manual trigger, the script entry will only be displayed on matching webpages, waiting for the user to click and execute. Filtering the display of script entry points based on the current page URL effectively avoids accidental triggering and interference on non-target webpages.
[0049] Furthermore, the storage-generated script function includes: if the current session is not associated with an existing script function, then creating a new script function; if the current session is associated with an existing script function, then displaying a storage mode option, and in response to a selection instruction for the storage mode option, updating the existing script function or creating a new script function.
[0050] For example, the system processes scripts according to the rule of "first save creates, subsequent saves update". When a script is saved for the first time in a conversation, the system creates a new script entity and establishes a binding relationship with that conversation; after the binding is completed, if the user triggers a save again in the same conversation (e.g., saving after fine-tuning code), the system no longer forces the creation of a new script, but directly updates the existing script content and prompts that the save was successful. This significantly reduces the management cost of script version forks and duplicate creation.
[0051] In some embodiments, this disclosure also supports conversational iterative loops for scripts and reuse of historical assets.
[0052] Specifically, the method further includes: generating updated script code in response to a natural language modification instruction for the script code.
[0053] For example, when a user clicks the "Modify" button in the script pop-up, the system collapses the pop-up, records the user's current configuration, refocuses the focus on the dialog area, and guides the user to submit modification requests. The system generates updated script content based on the new natural language modification instructions, and the user can write it according to the aforementioned update rules when saving again, thus forming a dialogic and seamless iterative process for the script.
[0054] Furthermore, the natural language creation instructions can also be determined by storing the script code as a generated script function in response to a selection operation for the script code displayed in the historical dialogue messages.
[0055] For example, when browsing historical conversations, if a user finds a script code from a system response that matches their current needs, they can directly select that code block (e.g., click "Save as Script"). The system will then directly extract that historical script code and enter the configuration and saving process, maximizing the reuse of the user's historical assets.
[0056] In some embodiments, to ensure the security and traceability of script assets, this disclosure introduces an identity verification mechanism. Specifically, the method further includes: if the current user's login status is not logged in, then triggering login guidance. For example, since scripts have the ability to directly manipulate the webpage DOM and data, in a non-logged-in scenario, the system restricts script-related operations such as creation, saving, editing, and execution. When an unlogged-in user triggers the above operations, the system will intercept the instruction and redirect to a unified authentication page or pop up a login window. Only after the user completes identity authentication is the script execution process allowed to continue, thereby ensuring that script capabilities are strictly bound to user identity and that behavior is traceable.
[0057] In one optional embodiment, corresponding to the above-described method for generating browser script functionality, this application also provides an apparatus for generating browser script functionality. Since this apparatus embodiment is fundamentally similar to the method embodiment, it is described simply; relevant details can be found in the description of the method embodiment. The apparatus embodiment described below is merely illustrative.
[0058] The device for generating this browser scripting functionality may include: The interface interaction module is used to respond to the script creation operation of the browser interface and display the script generation interactive interface. The code generation and display module is used to generate script code based on the natural language creation instructions input in the script generation interactive interface, and to display the script code and the execution control and / or save control associated with the script code. An execution and storage module is configured to execute the script code in the runtime environment of the current page of the browser in response to a trigger command for the execution control; or to store the generated script function in response to a trigger command for the save control.
[0059] Optionally, the interface interaction module is further configured to: receive a preset trigger identifier in the browser input area; or, respond to a selection operation of a script creation control in the browser toolbar or function panel.
[0060] Optionally, when storing the generated script function, the execution and storage module is specifically configured to: if the current session is not associated with an existing script function, create a new script function; if the current session is associated with an existing script function, display a storage mode option, and in response to a selection instruction for the storage mode option, update the existing script function or create a new script function.
[0061] Figure 3 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. The electronic device 1000 (e.g., it may be a user terminal or a server) may vary considerably due to differences in configuration or performance.
[0062] like Figure 3 As shown, the electronic device 1000 may include one or more processors (CPUs) 1001 and one or more memories 1002. The memory 1002 stores at least one line of computer program code, which is loaded and executed by the one or more processors 1001 to implement the browser scripting functionality generation method provided in the above-described method embodiments.
[0063] Specifically, when the processor 1001 executes the computer program code, it can perform the following steps: in response to a script function creation operation of the browser's interactive interface, display a script generation interactive interface; based on the natural language creation instructions input in the script generation interactive interface, generate script code and display the script code and execution controls and / or save controls associated with the script code; in response to a trigger instruction for the execution control, execute the script code in the runtime environment of the browser's current page; or, in response to a trigger instruction for the save control, store the generated script function.
[0064] Of course, the electronic device 1000 may also have wired or wireless network interfaces, display components, keyboards, and input / output interfaces to facilitate input / output and human-computer interaction. The electronic device 1000 may also include other components for implementing device functions, which will not be elaborated upon here.
[0065] In an exemplary embodiment, this application also provides a computer-readable storage medium storing at least one piece of computer program code, which is loaded and executed by the processor of an electronic device to enable the electronic device to implement any of the above-described browser script generation methods.
[0066] Optionally, the aforementioned computer-readable storage medium may be a read-only memory (ROM), a random access memory (RAM), a compact disc read-only memory (CD-ROM), a magnetic tape, a floppy disk, a flash memory, and an optical data storage device, etc.
[0067] In an exemplary embodiment, this application also provides a computer program product or computer program including computer instructions stored in a computer-readable storage medium. A processor of an electronic device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the electronic device to perform any of the browser scripting functions described above.
[0068] Optionally, the aforementioned computer-readable storage medium may be a read-only memory (ROM), a random access memory (RAM), a compact disc read-only memory (CD-ROM), magnetic tape, floppy disk, and optical data storage device, etc.
[0069] In an exemplary embodiment, a computer program or computer program product is also provided, which stores at least one computer instruction, which is loaded and executed by a processor to enable the computer to implement any of the above-described methods for causal evaluation of advertising placement.
[0070] It should be noted that all actions involving the acquisition of signals, information, or data in this application are carried out in compliance with the data protection laws and policies of the country where the application is located, and with authorization from the owner of the relevant device.
[0071] It should be understood that "multiple" as used in this article refers to two or more. "And / or" describes the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A alone, A and B simultaneously, or B alone. The character " / " generally indicates that the preceding and following related objects have an "or" relationship.
[0072] The sequence numbers of the embodiments in this application are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.
[0073] The above are merely exemplary embodiments of this application and are not intended to limit this application. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application shall be included within the protection scope of this application.
Claims
1. A method for generating browser script functionality, characterized in that, include: Responding to the script creation function in the browser's interactive interface, display the script generation interactive interface; Based on the natural language creation instructions entered in the script generation interactive interface, generate script code and display the script code along with execution controls and / or save controls associated with the script code; in response to a trigger instruction for the execution control, execute the script code in the runtime environment of the current page of the browser; Alternatively, in response to a trigger command for the save control, the generated script function can be stored.
2. The method according to claim 1, characterized in that, The script function creation operation includes: Enter a preset trigger identifier in the browser input area; or, select a script creation control in the browser toolbar or function panel.
3. The method according to claim 1, characterized in that, The function of storing the generated script includes: If the current session is not associated with an existing script function, a new script function is created; if the current session is associated with an existing script function, a storage mode option is displayed, and in response to a selection instruction for the storage mode option, the existing script function is updated or a new script function is created.
4. The method according to claim 1, characterized in that, The generated script code includes: The natural language creation instructions and the context information of the current page are input into a preset generation model to obtain the script code corresponding to the context information of the current page.
5. The method according to claim 1, characterized in that, The generated script code also includes: The generated raw code is encapsulated in a preset logic block to generate the script code; wherein the preset logic block includes an immediately invoked function expression or an exception handling block.
6. The method according to claim 1, characterized in that, The response to the trigger command for the save control further includes: The script configuration interface is displayed, which includes an effective scope option and a triggering strategy option. The effective scope option is used for specific Uniform Resource Locator or Domain Name matching rules, and the triggering strategy option is used to indicate automatic or manual triggering mode.
7. The method according to claim 1, characterized in that, The method further includes: In response to natural language modification instructions for the script code, updated script code is generated.
8. The method according to claim 1, characterized in that, The natural language creation instructions are determined in the following way: In response to a selection operation on the script code displayed in the historical dialogue messages, the script code is stored as a generated script function.
9. The method according to claim 1, characterized in that, The method further includes: If the current user is not logged in, a login tutorial will be triggered.
10. An electronic device comprising a memory and a processor, characterized in that, When the processor executes the computer program stored in the memory, it implements the method as described in any one of claims 1-9.