Cross-platform document content processing system and method, client device and storage medium
By combining browser plugins and AI processing layers, cross-platform document content is decomposed and processed, solving cross-domain access restrictions and platform-specific interface issues. This enables efficient and complete document content extraction and conversion, improving the system's adaptability and maintainability.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-18
- Publication Date
- 2026-04-03
AI Technical Summary
Existing technologies for cross-platform document content extraction and conversion suffer from problems such as cross-domain access restrictions, platform-specific interface limitations, inconsistent document content formats, low efficiency in cross-domain image processing, and limited client processing capabilities, resulting in the inability to obtain complete document content and difficulties in real-time request analysis.
The system receives prompts from the client via a browser plugin, uses an AI processing layer to decompose the prompt word chain into multiple interrelated prompt word tasks, analyzes the browser's historical request records to generate valid request parameters, constructs a dependency graph and performs topological sorting, integrates document content, and processes cross-domain images on the client side to reduce network transmission overhead.
It improves the success rate and integrity of cross-platform document requests, automates and modularizes complex AI processing workflows, reduces maintenance costs and data privacy risks, and improves processing efficiency.
Smart Images

Figure CN121786282A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of document content processing, and in particular to a cross-platform document content processing system and method, client device and storage medium. Background Technology
[0002] In the field of cross-platform document content extraction and conversion, the industry has developed various technical solutions and products. These technologies mainly revolve around core needs such as web page content crawling, document format conversion, and browser extension development. For example, traditional web page content extraction technology, based on DOM (Document Object Model) parsing and HTTP request mechanisms, uses JavaScript methods to locate and extract web page elements. This type of technology relies on the browser's rendering engine to fully parse the HTML document structure. However, traditional web page content extraction technology faces problems such as cross-domain access restrictions (CORS policies), anti-crawler mechanisms (such as CAPTCHAs, IP restrictions, and request frequency control), difficulties in loading dynamic content (AJAX asynchronous loading), and complex permission verification. Similarly, PDF document content extraction technology, based on DOM (Document Object Model) parsing and HTTP request mechanisms, uses JavaScript methods to locate and extract web page elements. This type of technology relies on the browser's rendering engine to fully parse the HTML document structure, but its accuracy is limited when handling complex layouts, table recognition is difficult, and the quality of image content extraction is unstable. Existing document conversion tools, based on document format parsers and conversion engines, achieve document format conversion by defining mapping rules for input and output formats. They mainly support mutual conversion between static document formats, but cannot handle dynamically generated web page content, lack intelligent extraction of rich media content, do not support real-time content acquisition from online collaboration platforms, and have limited accuracy in converting complex layouts and styles.
[0003] Existing technologies have obvious limitations. Cross-domain resource access restrictions are a fundamental problem, making it impossible to obtain complete content. Platform-specific interface restrictions further exacerbate the difficulty of content acquisition. Inconsistent document content formats increase the complexity of processing. Cross-domain image processing is inefficient and incomplete. Limited client processing capabilities restrict the diversity of processing functions, and difficulties in real-time request analysis affect the platform's intelligence. Summary of the Invention
[0004] The purpose of this application is to provide a cross-platform document content processing method and system, client device and storage medium, which avoids the inability to obtain complete document content due to cross-domain access restrictions, and improves the success rate of cross-domain access requests and the integrity of cross-domain document processing.
[0005] In a first aspect, embodiments of this application provide a cross-platform document content processing method, the method comprising: receiving prompt content for accessing a target page input by a client device through a browser plugin, the prompt content including a prompt word chain and format conversion requirements; decomposing the prompt word chain into multiple interrelated prompt word tasks through an AI processing layer; dynamically generating valid request parameters for each prompt word task by analyzing the characteristics of the browser's historical request records; sequentially executing each prompt word task according to the valid request parameters of each prompt word task, and obtaining the document content corresponding to each prompt word task from the target page; integrating the document content obtained from all executed prompt word tasks to form multimodal data; performing format conversion on the multimodal data according to the format conversion requirements to generate a document processing result; and displaying the document processing result to the client device through the browser.
[0006] In some embodiments, the step of decomposing the prompt word chain into multiple interrelated prompt word tasks through the AI processing layer specifically includes: verifying the dependency relationship of each prompt word in the prompt word chain; decomposing the prompt word chain into multiple interrelated prompt word tasks according to the dependency relationship of each prompt word, and constructing a dependency graph of all prompt word tasks through an adjacency list storage algorithm; and determining the execution order and execution plan of each prompt word task through a topological sorting algorithm.
[0007] In some embodiments, the dependency graph construction algorithm is an adjacency list storage algorithm. This algorithm uses a node data structure of the dependency graph to store the dependencies of each prompt word task. The implementation method of this adjacency list storage algorithm includes: defining a node data structure of the dependency graph to represent the dependencies between each prompt word task; initializing all nodes of the dependency graph and adding all prompt word tasks to the corresponding nodes of the dependency graph; sequentially checking the dependencies between one prompt word task and other prompt word tasks; if one prompt word task references another prompt word task, adding an edge between the nodes representing the two prompt word tasks to represent their dependency, and updating the in-degree of the current node; using a depth-first search function to search all nodes to check if the current node has a circular dependency; if the current node has a circular dependency, placing the current node in a recursive stack; if the current node does not have a circular dependency, visiting all neighbor nodes of the current node; and performing a circular dependency check on each unvisited node using the depth-first search function until all prompt word tasks have no circular dependencies.
[0008] In some embodiments, the topology sorting algorithm is an algorithm that sorts all prompt word tasks based on the in-degree of nodes in the dependency graph. The implementation method of this algorithm includes: finding all nodes in the dependency graph with an in-degree of 0 and adding these nodes to a queue; processing the nodes in the queue sequentially, removing the node storing the prompt word task from the queue after each node is processed, and updating the in-degree of all neighboring nodes of that node; determining whether the final number of processed nodes is equal to the total number of nodes in the dependency graph; if the final number of processed nodes is not equal to the total number of nodes in the dependency graph, then the current node has a circular dependency, and the prompt word task for the current node is not executed; if the final number of processed nodes is equal to the total number of nodes in the dependency graph, then the current node does not have a circular dependency, the prompt word task for the current node is executed, and the execution result of the prompt word task is stored.
[0009] In some embodiments, the step of dynamically generating valid request parameters for each prompt word task based on the browser's historical request records specifically includes: the AI processing layer obtaining network request records through the browser's performance API; extracting target API requests from the network request records; using a pattern recognition algorithm to identify the pattern features of the target API requests; and generating valid request parameters for each prompt word task based on the pattern features of the target API requests.
[0010] In some embodiments, the pattern recognition algorithm includes a parameter frequency analysis algorithm and a time series analysis algorithm. The parameter frequency analysis algorithm includes: traversing all network request records, counting the occurrence frequency and value of each parameter in each network request record; calculating the frequency ratio of each parameter; and determining valid request parameters (including strings, numbers, Boolean values, and / or timestamps) by analyzing each parameter value when the frequency ratio of the parameter is greater than a predefined threshold. The time series analysis algorithm includes: sorting all access requests for prompt word tasks by timestamp, calculating the time interval between adjacent access requests; calculating the average interval and variance of each access request to obtain the coefficient of variation, and using the coefficient of variation to determine the time of each access request.
[0011] In some embodiments, the cross-platform document content processing method further includes: sequentially initiating access requests for each prompt word task to the target page through the AI processing layer; determining whether each prompt word task access request is successful; if the access request for a prompt word task is successful, the AI processing layer executes the prompt word task according to the valid request parameters of the prompt word task; if the access request for a prompt word task is unsuccessful, the data storage layer records the error information of the unsuccessful access request, and the browser plugin returns the error information to the client device.
[0012] In some embodiments, the AI processing layer determines whether the access request for each prompt word task is successful by verifying the access permissions of the target page and / or the compatibility of the target page with the browser plugin.
[0013] In some embodiments, the cross-platform document content processing method further includes: determining whether there are images in the document content corresponding to the executed prompt word task; if there are images in the document content, then processing to obtain the image data of the prompt word task across the images; if there are no images in the document content, then obtaining the text data of the prompt word task from the document content.
[0014] In some embodiments, the process of integrating the document content obtained from all executed prompt word tasks to form multimodal data specifically includes: integrating the text data and image data obtained from all executed prompt word tasks to form the multimodal data.
[0015] In some embodiments, the process of processing image data for obtaining prompt words across images specifically includes: parsing the HTML page structure from the document content of the target page; finding the image tag format from the HTML page structure; filtering invalid links on the target page to obtain valid URL addresses for the images; creating an image canvas element in the context of the target page and setting the cross-domain processing attribute of the image canvas element; determining whether the image for the executed prompt word task has been successfully loaded from the URL address; if the image requested by the executed prompt word task has been successfully loaded from the URL address, then drawing the loaded image onto the canvas; if the image requested by the executed prompt word task has not been successfully loaded from the URL address, then recording an error message indicating that the image loading was unsuccessful and returning the error message to the client device; converting the image data in the canvas into image binary data; generating a local storage path and replacing the URL address of the loaded image with the local storage path; saving the image binary data in the local storage path and updating the image resources in the local storage path.
[0016] In some embodiments, drawing the loaded image onto the canvas specifically includes: optimizing the loaded image using an image segmentation processing algorithm. The implementation method of the segmentation processing algorithm includes: cutting the photo into grid-like small blocks; calculating the image size of each small block to ensure that the last small block does not exceed the image boundary; creating an independent canvas for each small block and drawing each small block onto the corresponding canvas; performing performance optimization parameter processing on the pixel data of each small block; and reassembling all the processed small blocks into a complete image.
[0017] In some embodiments, drawing the loaded image onto the canvas specifically includes: performing performance optimization processing on the loaded image using an adaptive size control algorithm. The implementation method of the adaptive size control algorithm includes: obtaining the display pixel ratio of the client device and checking the available memory of the client device; calculating the maximum image size based on the performance of the client device and the available memory; calculating the aspect ratio based on the maximum image size to determine the optimal width and optimal height of the icon.
[0018] In some embodiments, converting the image data in the canvas into binary image data specifically includes: compressing the binary image data using an intelligent compression algorithm. The implementation method of the intelligent compression algorithm includes: calculating a specified compression ratio based on the original size and target size of the image; compressing the image to the specified compression ratio; estimating the size of the compressed image based on the number of pixels in the image; if the size of the compressed image is larger than the target size, adjusting to the minimum compression ratio based on the image type and image quality, and continuing to compress using a recursive compression function to reach the minimum compression ratio.
[0019] Secondly, embodiments of this application provide a cross-platform document content processing system. This system includes a browser plugin and an AI processing layer. The browser plugin includes a user interface and a prompt word extension unit. The AI processing layer includes a prompt word execution engine and an AI service unit. The user interface allows users to input prompt content for accessing a target page from a client device. This prompt content includes a prompt word chain and format conversion requirements. The prompt word extension unit receives the prompt content from the user interface and sends it to the prompt word execution engine. The prompt word execution engine decomposes the prompt word chain into multiple interrelated prompt word tasks and dynamically generates valid request parameters for each prompt word task by analyzing the characteristics of the browser's historical request records. The AI service unit executes each prompt word task sequentially according to its valid request parameters to obtain the document content corresponding to each prompt word task from the target page. The prompt word execution engine further integrates the document content obtained from all executed prompt word tasks to form multimodal data and performs format conversion on the multimodal data according to the format conversion requirements to generate document processing results. The prompt word expansion unit is also used to display the document processing results to the client device via the browser.
[0020] In some embodiments, the prompt word execution engine is further configured to: sequentially initiate access requests for each prompt word task to the target page, determine whether each prompt word task access request is successful, execute the prompt word task according to the valid request parameters of the prompt word task when the access request of the prompt word task is successful, and return the error information to the client device when the access request of the prompt word task is unsuccessful.
[0021] In some embodiments, the AI service unit is further configured to: determine whether there are images in the document content corresponding to the executed prompt word task; if there are images in the document content, process the image data of the prompt word task across the images; if there are no images in the document content, obtain the text data of the prompt word task from the document content.
[0022] In some embodiments, the cross-platform document content processing system further includes a data storage layer, which comprises a local storage unit and a cache manager. The local storage unit stores the prompt content and the browser's historical access records. The cache manager temporarily stores the document content obtained by the prompt word task and records error information indicating unsuccessful access requests for the prompt word task.
[0023] In some embodiments, the cross-platform document content processing system further includes an SDK abstraction layer, which includes an SDK interface and a permission management unit. The SDK interface is a standard SDK extension interface used to enable inter-platform communication. The permission management unit is used to manage access permissions across multiple platforms through the content scripts of the browser plugin.
[0024] Thirdly, embodiments of this application also provide a client device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the cross-platform document content processing method as described in any of the foregoing embodiments.
[0025] Fourthly, embodiments of this application also provide a computer-readable storage medium storing a computer program, wherein the computer program, when executed by a processor, implements the cross-platform document content processing method described in any of the foregoing embodiments.
[0026] Compared with existing technologies, the cross-platform document content processing method and system, client device, and storage medium provided in this application embodiment utilize the browser's performance API to obtain network request history. By analyzing the pattern characteristics of these network request records using a pattern recognition algorithm, it dynamically generates request parameters that conform to platform expectations. This adaptive dynamic adjustment of request parameters improves the success rate of accessing cross-platform document requests and automatically adapts to the interface characteristics of different platforms, thereby enhancing the system's adaptability to platform interface changes, reducing manual configuration workload, and lowering maintenance costs. Furthermore, this embodiment decomposes complex prompt word chains into multiple interrelated prompt word tasks, constructs a dependency graph and execution plan for all prompt word tasks, and ensures the correctness of the execution order through dependency graph management. This achieves automated execution of complex AI processing flows, realizes modular orchestration and management of AI processing flows, and improves the maintainability and reusability of AI processing flows. Furthermore, by leveraging browser extension permissions to directly create a Canvas element on the target page to handle cross-domain images, cross-domain access restrictions are avoided, preventing the inability to obtain complete document content. This allows for client-side image processing, thereby improving the integrity of cross-domain document processing. Compared to server proxy solutions, this cross-domain image processing method reduces network transmission overhead, improves processing efficiency, and lowers server costs and data privacy risks. Attached Figure Description
[0027] One or more embodiments are illustrated by way of example with reference numerals in the accompanying drawings. These illustrations do not constitute a limitation on the embodiments. Elements with the same reference numerals in the drawings are denoted as similar elements. Unless otherwise stated, the figures in the drawings are not to be limited by scale.
[0028] Figure 1 This is a schematic diagram of the architecture of a cross-platform document content processing system provided in an embodiment of this application; Figure 2 This is a data flow diagram of a cross-platform document content processing system provided in an embodiment of this application; Figure 3 This is a flowchart illustrating a cross-platform document content processing method provided in an embodiment of this application; Figure 4 yes Figure 3 A detailed flowchart illustrating the intelligent request splicing method in step S12. Figure 5 yes Figure 3 A detailed flowchart illustrating the cross-domain image processing method in step S18. Detailed Implementation
[0029] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the various embodiments of this application will be described in detail below with reference to the accompanying drawings. However, those skilled in the art will understand that many technical details have been provided in the various embodiments of this application to help readers better understand this application. However, the technical solutions claimed in this application can be implemented even without these technical details and various changes and modifications based on the following embodiments. The division of the various embodiments below is for the convenience of description and should not constitute any limitation on the specific implementation of this application. The various embodiments can be combined with and referenced by each other without contradiction.
[0030] participate Figure 1 As shown, Figure 1 This is a schematic diagram of the architecture of a cross-platform document content processing system provided in this application embodiment. In this embodiment, the cross-platform document content processing system 2 is installed and runs on the client device 1, realizing processing functions such as extraction, conversion, and integration of cross-platform document content. The cross-platform document content processing system 2 includes a browser plugin 21, an AI processing layer 22, a data storage layer 23, and an SDK abstraction layer 24. This embodiment adopts a browser four-layer architecture pattern, with each layer communicating with adjacent layers through standardized interfaces, ensuring loose coupling and high cohesion of the system, enabling the system to flexibly adapt to changes in the needs of different platforms while maintaining the stability of the core functions of the system.
[0031] The client device 1 includes, but is not limited to, a browser 10, a central processing unit 11, a memory 12, a display unit 13, and a network interface. In this embodiment, the client device 1 is an electronic device with data processing capabilities, including, but not limited to, mobile terminals such as smartphones, laptops, personal digital assistants (PDAs), and tablet PCs, as well as fixed terminals such as digital televisions and desktop computers. It should be noted that... Figure 1 Only client device 1 with the above-described components is shown; however, it should be understood that it is not required to implement all of the components shown, and more or fewer components may be implemented instead.
[0032] In this embodiment, the browser 10 is used to receive prompts input by the user and display webpage content, presenting the document content processing results to the user according to the format conversion requirements set by the user. The central processing unit 11 may be a central processing unit (CPU), microprocessor, controller, microcontroller, or other data processing chip. The central processing unit 11 is typically used to control the overall operation of the client device 1. In this embodiment, the central processing unit 11 is used to run computer program code stored in the memory 12 or process data, for example, running the computer program code constituting the cross-platform document content processing system 2 to implement the various functions of the domain cross-platform document content processing system of this application embodiment.
[0033] The memory 12 includes at least one type of computer-readable storage medium, including flash memory, hard disk, multimedia card, card-type memory (e.g., SD or DX memory), random access memory (RAM), static random access memory (SRAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), programmable read-only memory (PROM), magnetic memory, magnetic disk, optical disk, etc. In some embodiments, the memory 12 may be an internal storage unit of a computer device, such as the hard disk or memory of the client device 1. In other embodiments, the memory 12 may also be an external storage device of a computer device, such as a plug-in hard disk, smart media card (SMC), secure digital (SD) card, flash card, etc., equipped on the client device 1. In this embodiment, the memory 12 is typically used to store the operating system and various application software installed on the client device 1, such as the program code of the cross-platform document content processing system provided in this embodiment.
[0034] The display unit 13 can be a display screen, LED display, liquid crystal display, touch screen, or other display components. In this embodiment, the display unit 13 is used to display the browser 10 in the client device 1 and the web page content on the browser 10, as well as to display the cross-platform document content processing results to the user according to the format conversion requirements set by the user.
[0035] The network interface 14 may include a wireless network interface or a wired network interface, which is typically used to establish a network connection between the client device 1 and an external computer device (such as a file server). For example, it may be used to establish a data transmission channel and communication connection between the client device 1 and the external computer device. The network may be an intranet, the Internet, a 4G network, a 5G network, Bluetooth, Wi-Fi, or other wireless or wired networks.
[0036] In this embodiment, the browser plugin 21 includes a user interface (Popup interface) 211, a prompt word extension unit 212, and content scripts 23. The user interface 211 is a Popup interface that provides user interaction, used to receive user input and display processing results. Specifically, the user interface 211 is used for users to input prompt content from the client device 1 to access the target page. This prompt content includes a prompt word chain and format conversion requirements; the prompt word chain may include one or more prompt words. The prompt word extension unit 212 is used to process the prompt content input from the user interface 211 and to display the document processing results to the client device 1 through the browser 10. The prompt word extension unit 21 can expand the prompt words based on depth, breadth, or complexity, generating diverse prompt word results based on the prompt word chain input by the user. The content scripts 213 are used to perform content extraction on the target page, directly manipulating the page's document object model (DOM) structure, facilitating multi-platform expansion through the SDK abstraction layer 24.
[0037] The AI processing layer 22 includes a prompt execution engine 221 and an AI service unit 222. The prompt execution engine 221 can process user-defined prompts or prompt chains, supporting complex prompt logic arrangement. By decomposing complex prompt chains into multiple sequentially processed prompt tasks (i.e., Prompt tasks), and through the logical concatenation of structured prompts, it can achieve Prompt task decomposition, information transmission, and result integration. The prompt execution engine 221 is used to decompose the prompt chain into multiple interrelated Prompt tasks, analyze the characteristics of the browser 10's historical request records to generate valid request parameters for each Prompt task, integrate the image and text data obtained from all executed Prompt tasks to form multimodal data, and perform format conversion on the multimodal data according to format conversion requirements to generate document processing results. The AI service unit 222 is used to sequentially execute each Prompt task according to the valid request parameters of each Prompt task, obtaining the image and text data corresponding to each Prompt task from the target page.
[0038] The data storage layer 23 includes a local storage unit 231 and a cache manager 232. In this example, the local storage unit 231 is used to store user configurations (such as prompt word data and prompt chain data) and the browser 10's historical request records, supporting offline access to data in the memory 12 of the client device 1; the cache manager 232 is used to temporarily store the document content obtained by executing the Prompt task, record the error information of the Prompt task when the access request fails, and improve the platform's response speed by caching the extracted document content and AI processing results.
[0039] The SDK abstraction layer 24 includes an SDK interface 241 and a permission management unit 242. The SDK interface 241 is a standard SDKBase interface used to enable inter-platform communication and expansion across different platforms. The permission management unit 242 can be defined as a BrowserPermissionManager, used to manage access permissions across multiple platforms through the content script 21 of the browser plugin 21, such as requesting and using unified management of access permissions for various platforms.
[0040] This embodiment employs a four-layer architecture: browser plugin 21, AI processing layer 22, data storage layer 23, and SDK abstraction layer 24. Each layer communicates with adjacent layers through standardized interfaces, ensuring loose coupling and high cohesion of the cross-platform document content processing system 2 described in this embodiment. This allows the system 2 to flexibly adapt to changes in the needs of different platforms while maintaining the stability of system functions. The standardized SDK abstraction layer 24, through its plug-in architecture, supports integration with different web platforms, improving code reusability and system scalability. It simplifies the access process for other platforms, increases system development efficiency, and reduces system maintenance costs. By executing the main AI processing flow in the client browser, dependence on the server is reduced. Combined with a local caching strategy, this improves response speed, reduces network latency, provides offline processing capabilities, and lowers server load and operating costs.
[0041] refer to Figure 2 As shown, Figure 2 This is a data flow diagram of a cross-platform document content processing system provided in this embodiment. In this embodiment, the AI processing layer 22 decomposes the complex prompt chain into multiple interrelated prompt tasks, constructs a dependency graph and execution plan for all prompt tasks, and ensures the correctness of the execution order of each prompt task through dependency graph management.
[0042] (101) Setting a prompt word chain: The user clicks the extension icon in the toolbar of the browser 10 on the client device 1 to open the user interface 211 of the browser plugin 21, such as the Popup interface. In this user interface 211, a prompt word chain consisting of one or more prompt words can be set. The prompt word extension unit 212 receives the prompt word chain set by the user from the user interface 211 and sends the prompt word chain to the prompt word execution engine 221 of the AI processing layer 22 to check the dependencies of the prompt word chain.
[0043] (102) Verifying the dependencies of the prompt word chain: The prompt word execution engine 221 of the AI processing layer 22 checks the dependencies of each prompt word in the prompt word chain, decomposes the prompt word chain into multiple interrelated Prompt tasks according to the dependencies of each prompt word, and constructs a dependency graph of all Prompt tasks using a dependency graph construction algorithm (e.g., adjacency list storage algorithm). The prompt word execution engine 221 checks the dependencies of each prompt word in the prompt word chain to ensure the correctness of the dependencies of the Prompt tasks. In this embodiment, the prompt word execution engine 221 constructs a dependency graph of each Prompt task using an adjacency list storage algorithm to represent the dependencies between each Prompt task.
[0044] In this embodiment, the adjacency list storage algorithm uses an adjacency list storage graph structure to store each node of the Prompt task and the dependencies of each node. The prompt word execution engine 221 first defines the data structure of the dependency graph and initializes all nodes of the dependency graph, for example, using the name of the Prompt task as a node in the dependency graph. The prompt word execution engine 221 analyzes the variable references in the content of each Prompt task and establishes the dependencies between each Prompt task. For Prompt tasks with variable references ${promptName.field}, the prompt word execution engine 221 adds an edge from the node of that Prompt task to the node of the dependent Prompt task as a dependency relationship and uses a depth-first search (DFS) function to perform circular dependency detection.
[0045] Specifically, the implementation method using the adjacency list storage algorithm includes: defining a dependency graph data structure to represent the dependencies between Prompt tasks; initializing all nodes in the dependency graph, i.e., adding all Prompt tasks to the nodes of the dependency graph; analyzing the dependencies of each Prompt task, i.e., checking whether a Prompt task references other Prompt tasks; if a Prompt task exists and references other Prompt tasks (for example, if prompt A references the result of prompt B, then prompt A depends on prompt B), then an edge is added between the nodes. For example, if prompt B points to prompt A, it means that prompt A depends on prompt B, and the in-degree of the current node (i.e., the number of times it is depended on) is updated. For example, if the in-degree of prompt A is increased by 1, it means that there is one more dependency. The depth-first search function (DFS) is used to search all nodes along the dependency relationship to check whether the current node has a circular dependency. If the current node has a circular dependency, the current node is put into the recursion stack. If the current node does not have a circular dependency, all neighboring nodes (dependent Prompt tasks) are visited. Circular dependency checks are performed on each unvisited node to ensure that all Prompt tasks do not have circular dependencies.
[0046] (103) Constructing an execution plan: The prompt word execution engine 221 determines the execution order and execution plan of each Prompt task through a topological sorting algorithm (such as the Kahn algorithm), so that Prompt tasks with dependencies are executed first, ensuring the correctness of the execution order of each Prompt task. The topology sorting algorithm is a Kahn algorithm that sorts nodes based on their in-degree in the dependency graph. Its specific implementation includes the following steps: Find all nodes with an in-degree of 0 (nodes without dependencies, i.e., Prompt tasks without prerequisite tasks), and add these nodes to a queue; process the nodes in the queue sequentially, removing the node storing the Prompt task from the queue after processing each node, and updating the in-degree of all its neighbors; if the in-degree of a neighbor node becomes 0, add that node to the queue (i.e., if all prerequisite tasks for the node's Prompt task are completed, execute the node's Prompt task) and continue processing; check if all nodes have been processed, i.e., determine if the final number of processed nodes equals the total number of nodes in the dependency graph; if the final number of processed nodes does not equal the total number of nodes, it indicates that the current node being processed has a circular dependency, so the prompt task for that current node is not executed; if the final number of processed nodes equals the total number of nodes, it indicates that the current node being processed does not have a circular dependency, execute the current node's Prompt task, and store the execution result of the Prompt task. In this embodiment, the prompt word execution engine 221 uses the Kahn algorithm to sort the execution order of each Prompt task according to the dependency relationship, ensuring that the dependent Prompt tasks are executed first.
[0047] (104) Parsing Template Variables: The prompt word execution engine 221 parses the template variables in each Prompt task sequentially according to the execution order using a template variable parsing algorithm. It verifies the availability of template variables by recognizing variable reference syntax, avoiding references to undefined variables. For example, by recognizing references in the format {promptName.field} of the Prompt name, it can identify variable reference syntax and support complex variable paths. In this embodiment, the template variable parsing algorithm uses the predefined regular expression / \$\{([^}]+)\} / g to identify all variable references. By traversing the template string, it finds all matching variable references and then parses the variable paths, where variable paths are separated by dots. This template variable parsing algorithm supports nested attribute access and array indexing. Furthermore, this template variable parsing algorithm also supports complex path access, such as ${prompt1.result.data.items[0].name}, achieving multi-level nested access through recursive parsing.
[0048] (105) Replace Prompt Word: If the prompt word in the Prompt task is not defined, the prompt word execution engine 221 replaces the undefined prompt word in the Prompt task with the template variable, thereby avoiding referencing the undefined prompt word.
[0049] (106) Sending AI requests: The prompt word execution engine 221 generates its own AI requests in the order of the dependencies of each Prompt task, and sends the AI access request of each Prompt task to the AI service unit 222 in sequence, so that the AI service unit 222 executes each Prompt task in sequence.
[0050] (107) Execute AI requests and return execution results: AI service unit 222 executes each Prompt task sequentially. AI service unit 222 requests the target page to execute the Prompt task according to its AI request type, thereby obtaining the corresponding execution result. This execution result includes image data, table data, and text data from the target page. Furthermore, AI service unit 222 returns the corresponding execution result of the Prompt task to prompt word execution engine 221. In this embodiment, the AI request type refers to the type of target page that the Prompt task needs to access, such as TAPD, Enterprise Docs, etc. AI service unit 222 executes the access requests of each Prompt task in the order of their dependencies, thereby ensuring the logical correctness of each Prompt task's execution.
[0051] (108) Update execution context: The prompt word execution engine 221 dynamically updates the execution context based on the executed Prompt task, further ensuring the correct execution logic of each Prompt task and supporting the correct data transmission of each Prompt task.
[0052] (109) Storing Execution Results: The prompt execution engine 221 stores the execution results of the Prompt task, including image data and text data in the target page, in the local storage unit 231 of the data storage layer 23. In this embodiment, the cache management unit 52 of the data storage layer 23 can manage the storage space of the local storage unit 231. For example, when the storage space of the local storage unit 231 is insufficient, the storage space is released according to the execution order of the Prompt task so as to store the complete execution results of subsequent Prompt tasks, thereby ensuring the integrity of the execution results of each Prompt task.
[0053] (110) Forming and returning the final result: The prompt word execution engine 221 integrates the text data and image data of all Prompt tasks to form the final document processing result, and returns the final document processing result to the prompt word extension unit 212 of the browser plugin 21.
[0054] (111) Displaying the final result: The browser plugin displays the final document processing result on the display unit 13 of the client device 1. In this embodiment, the prompt word extension unit 2 of the browser plugin 21 receives the document processing result (e.g., the webpage content of the target webpage) returned by the prompt word execution engine 221 of the AI processing layer 22, and displays the document processing result on the display unit 13 of the client device 1 through the browser 10, such as an LED display, a liquid crystal display, a touch screen, etc.
[0055] In this embodiment, the prompt word execution engine 221 of the AI processing layer 22 constructs a dependency graph based on the dependency relationship of each Prompt task, ensuring the execution order of each Prompt task, supporting template variable references and conditional execution of Prompt tasks, realizing modular orchestration and management of AI processing flow for complex prompt word chains, and improving the maintainability and reusability of AI processing flow.
[0056] This application also provides an embodiment of a cross-platform document content processing method. (See reference...) Figure 3 As shown, Figure 3 This is a flowchart illustrating a cross-platform document content processing method provided in this embodiment. In this embodiment, the cross-platform document content processing method is applied to, for example... Figure 1 In the client device 1 shown, the computer program code instructions that implement the method are stored in the memory 12 of the client device 1 and can be executed by the central processing unit 11 of the client device 1 to implement the cross-platform document content processing method described in the embodiments of this application. The method includes the following steps, which are described in detail below.
[0057] Step S10: The browser plugin receives prompts from the client device requesting access to a target page. These prompts include a prompt chain, format conversion requirements, and the target page type. In this embodiment, the user on client device 1 clicks the extension icon in the browser 10 toolbar and opens the user interface 211 of the browser plugin 21, such as a Popup interface. The user inputs the prompts for accessing the target page from the user interface 211. These prompts may include, but are not limited to, a prompt chain, format conversion requirements, and the target page type, which may include, but is not limited to, TAPD, Enterprise Docs, etc. The prompt extension unit 212 of the browser plugin 21 receives the prompts from client device 1 containing a prompt chain, where the prompt chain consists of one or more prompts.
[0058] Step S11: The AI processing layer decomposes the prompt word chain into multiple interrelated prompt word tasks. In this embodiment, the prompt word execution engine 221 of the AI processing layer 22 decomposes the complex prompt word chain into multiple interrelated prompt word (Prompt) tasks, where each Prompt task has explicit inputs, outputs, and dependencies. The prompt word execution engine 221 verifies the dependencies of each prompt word in the prompt word chain, constructs the dependency graph of each Prompt task using a dependency graph construction algorithm (e.g., adjacency list storage algorithm), and determines the execution order and execution plan of each Prompt task using a topological sorting algorithm (e.g., Kahn algorithm), thereby ensuring that Prompt tasks with dependencies are executed first, guaranteeing the correctness of the execution order of each Prompt task.
[0059] Step S12 involves dynamically generating valid request parameters for each prompt task by analyzing the pattern characteristics of the browser's historical request records. In this embodiment, the prompt execution engine 221 of the AI processing layer 22 analyzes the real historical request records generated during normal user operations recorded by the browser 10's Performance API. Based on the parameter characteristics and change patterns of the historical request records, it analyzes the access request of each prompt task and then generates valid request parameters for each Prompt task that meet the access expectations of the target platform. This improves the browser 10's adaptability to changes in the target page (i.e., the target platform) interface, ensures the legitimacy and validity of accessing the target platform, and increases the success rate of accessing the target platform. For the method steps of step S12, please refer to [link to relevant documentation]. Figure 4 To provide further details.
[0060] In some embodiments, the prompt word execution engine 221 uses a pattern matching algorithm to find the best matching parameter with the highest similarity between the access request parameters of the current prompt word task and historical request records, and uses it as a valid request parameter. The implementation method of the pattern matching algorithm includes the following steps: traversing all historical request records to find the best matching parameter with the access request parameters of the current prompt word task; for example, a similarity exceeding 70% is considered a valid match; comparing the key similarity of the parameter names and the value similarity of the parameter values in the best matching parameter and the access request parameters, and weighting the key similarity and value similarity (e.g., key similarity accounts for 40%, value similarity accounts for 60%) as the valid request parameter for the current prompt word task. The browser plugin 21 finds the best match by calculating the similarity between the current parameter and historical request records, using Jaccard similarity to calculate the key matching degree, and using exact matching and similarity matching to calculate the value matching degree; for timestamps, values within 5 minutes of each other are considered similar; for numerical values, values within 10% of each other are considered similar. The final similarity calculation is a weighted score of key similarity and value similarity.
[0061] Step S13: The prompt execution engine initiates an access request for each prompt task to the target page. In this embodiment, the prompt execution engine 221 initiates an access request for each prompt task (Prompt task) to the same-origin context of the target page, utilizing the session state of the target page to ensure that the authentication of the Prompt task access request is successful. That is, the access request for each Prompt task is sent to the target webpage where the user is already logged in, so that it will not be rejected by the target webpage. In this embodiment, all prompt task access requests are executed in the context of the target page authorized by the user, thus ensuring the security policy of browser 10.
[0062] Step S14: Determine whether the access request for each prompt word task is successful. In this embodiment, the prompt word execution engine 221 of the AI processing layer 22 determines whether the access request for each Prompt task is successful by verifying the access permissions of the target page and / or the compatibility between the target page and the browser plugin 21. For example, if the access request of a Prompt task has legal access permissions to the target page and the browser plugin 21 supports the compatibility of the target page, then the access request can successfully access the target page; otherwise, if the access request of a Prompt task does not have legal access permissions to the target page, or the browser plugin 21 does not support the compatibility of the target page, then the access request cannot access the target page. If the access request of a prompt word task is successful, proceed to step S15; if the access request of a prompt word task is unsuccessful, proceed to step S23.
[0063] Step S15: The AI processing layer executes each prompt word task sequentially according to the valid request parameters of each prompt word task to obtain the document content corresponding to each prompt word task from the target page. In this embodiment, the prompt word execution engine 221 of the AI processing layer 22 executes each Prompt task sequentially according to the execution order and sends the corresponding AI request for each Prompt task to the AI service unit 222. The AI service unit 222 obtains the document content, such as HTML content, corresponding to each Prompt task from the target page according to its respective AI request. This HTML content includes, but is not limited to, various data types such as images, text, and tables. Specifically, the prompt word execution engine 221 first traverses the dependency graph of the topologically sorted Prompt task sequence to ensure that the dependencies of each Prompt task are correct. Then, the prompt word execution engine 221 replaces the prompt word variable of a Prompt task with a smart template variable to realize the data flow of the Prompt task. Next, it sends an AI request to the AI service unit 222 to obtain the HTML content corresponding to the Prompt task from the target page. Finally, the prompt word execution engine 221 dynamically updates the context of the execution target page to ensure that the Prompt task can reference the execution results that depend on it.
[0064] Step S16: Determine if the document content corresponding to each prompt word task contains images. In this embodiment, the AI service unit 222 searches for image resources in the HTML content corresponding to each prompt word task. Specifically, the AI service unit 222 searches for image resources based on the file extension or image tag format (e.g., IMG, PNG, JPEG, etc.). The AI service unit 222 determines whether images exist in the HTML content based on the file extension or image tag format of the HTML content. If images exist in the HTML content, the cross-image processing in step S17 is executed to obtain the image data for each prompt word task. This cross-image processing method will... Figure 5 The flowchart for cross-image processing is described in detail; if the HTML content does not contain images, then step S18 is executed.
[0065] Step S18: Directly obtain the text data of each prompt word task from the document content; In this embodiment, the AI service unit 222 receives text data obtained from the HTML document content, such as text data obtained from text content or table content.
[0066] Step S19: Integrate all obtained text and image data to form complete multimodal data. In this embodiment, AI service unit 222 integrates the text and image data obtained from executing all prompt word tasks to form complete multimodal data. The multimodal data includes text data, image data, and table data obtained from executing all prompt word tasks. AI service unit 222 combines processing technologies for multiple content types such as text, images, and tables, and uses AI models to achieve cross-modal content recognition and conversion. For example, AI service unit 222 uses multimodal large language models (such as GPT-4V, Claude3) to recognize text data, uses image recognition models to recognize image data, and uses table structure recognition algorithms to recognize image data.
[0067] In step S20, the AI processing layer converts the multimodal data according to the format conversion requirements to generate a document processing result. In this embodiment, the AI service unit 222 of the AI processing layer 22 converts the multimodal data according to the format conversion requirements in the prompt content input by the user from the client device 1 to generate a document processing result, and returns the document processing result to the prompt word extension unit 212 of the browser plugin 21 through the prompt word execution engine 22131.
[0068] In step S21, the browser plugin displays the document processing result to the client device. In this embodiment, the browser plugin 21 receives the document processing result (e.g., the webpage content of the target webpage) returned by the AI processing layer 22 and displays the document processing result on the display unit 13 of the client device 1 through the browser 10, such as an LED display, an LCD display, or a touch screen.
[0069] In step S22, the data storage layer records the error message of the unsuccessful access request in the local storage unit, and the browser plugin returns the error message to the client device. In this embodiment, the data storage layer 23 records the error message of the unsuccessful access request in the local storage unit 231, the browser plugin 21 returns the error message of the unsuccessful access request to the client device 1, and the display unit 13 of the client device 1 displays the error message of the unsuccessful access request on the browser 10 to inform the user of the error message that the target page cannot be accessed.
[0070] In this embodiment, the cross-platform document content processing method utilizes the browser's performance API to analyze historical network request records, identify API call patterns, and dynamically adjust request parameters, improving the system's adaptability to platform interface changes. This adaptive request pattern analysis, compared to a fixed request template, can automatically adapt to interface changes, improving system stability. Furthermore, by leveraging browser extension permissions to directly create Canvas elements on the target page for image processing, cross-domain access restrictions are avoided, achieving a pure client-side image processing solution. Compared to server proxy solutions, this Canvas cross-domain image processing reduces network transmission overhead, improves processing efficiency, and lowers server costs and data privacy risks. Moreover, this embodiment also provides a prompt word execution engine 221 that constructs a dependency graph based on the dependencies of each Prompt task, ensuring the execution order of each Prompt task and achieving modular orchestration and management of the AI processing flow. This Prompt task workflow orchestration scheme, through visual workflow design, lowers the development threshold for complex AI applications and improves the maintainability and reusability of the processing flow.
[0071] Furthermore, this application embodiment also provides an operation flow for the intelligent request splicing method applied to step S12 of the cross-platform document content processing method shown. (See reference...) Figure 4 As shown, Figure 4 yes Figure 3 A detailed flowchart of the intelligent request splicing process in step S12 is shown below. In this embodiment, the intelligent request splicing method identifies the pattern characteristics of specific API calls by analyzing the historical request records of the browser's performance API records, and dynamically generates request parameters that meet the platform's expectations based on these characteristics, thereby improving the request success rate. Step S12 of the intelligent request splicing method includes steps S121 to S124.
[0072] Step S121: Obtain network request records via the browser's performance API; In this embodiment, the prompt word execution engine 221 of the AI processing layer 22 uses the getEntriesByType('resource') function of the browser 10's performance API to obtain the resource loading history, thereby obtaining a complete historical request record. Since the browser 10 only obtains publicly available performance API data, this complies with the browser 10's security policy.
[0073] Step S122: Extract the target API request from the network request record; In this embodiment, the prompt word execution engine 221 filters out the target API request (such as opendoc) from the network request record of the browser 10 in order to identify the request type that needs to be analyzed.
[0074] Step S123: The pattern recognition algorithm is used to identify the pattern features of the target API request. In this embodiment, the prompt word execution engine 221 uses a request pattern recognition algorithm to identify pattern features such as the document ID, timestamp, URL, and request order of the target API request, determining the required and optional parameters of the target API request. The prompt word execution engine 221 extracts key request parameters of the target API request from the pattern features using the pattern recognition algorithm, identifies the changing trends of the request parameters based on their inherent patterns, and constructs parameter mapping relationships to establish the correlation between parameters. This embodiment automatically identifies the inherent patterns of request parameters using a pattern recognition algorithm, adapting to the dynamic changes of the platform interface without requiring manual maintenance.
[0075] In this embodiment, the pattern recognition algorithm can employ a parameter frequency analysis algorithm and a time series analysis algorithm. The parameter frequency analysis algorithm is used to statistically analyze the frequency and value distribution of each parameter in historical requests. This algorithm includes the following steps: traversing all historical requests, counting the occurrences and all possible values of each parameter; calculating the frequency ratio of each parameter (occurrences / total requests); parameters with a frequency greater than a predefined threshold (e.g., 0.8) are considered necessary parameters; and inferring the parameter type (e.g., string, number, boolean value, or timestamp) by analyzing the characteristics of the parameter values. The time series analysis algorithm is used to analyze the time intervals of requests. This algorithm includes the following steps: sorting all requests by timestamp and calculating the time interval between adjacent requests; calculating the average interval and variance to obtain the coefficient of variation (e.g., standard deviation / mean, with a predefined threshold range of 0.3-0.8); and using this coefficient of variation to determine the time pattern of API requests. A coefficient of variation less than 0.3 indicates regular requests, 0.3-0.8 indicates random requests, and greater than 0.8 indicates sudden requests. This analysis helps simulate the operation patterns of real users.
[0076] Step S124: Generate valid request parameters for each prompt word task based on the pattern features of the target API request. In this embodiment, the prompt word execution engine 221 extracts key request parameters from the pattern features of the target API request using a dynamic parameter generation algorithm, and dynamically generates valid request parameters for each prompt word task by identifying the inherent patterns of these request parameters. The dynamic parameter generation algorithm can be an intelligent interpolation algorithm, which generates new parameter values based on parameter type and historical values. For timestamp types, the intelligent interpolation algorithm analyzes the statistical characteristics of historical time intervals and uses a normal distribution to generate new timestamps that conform to historical patterns. For numerical types, the intelligent interpolation algorithm calculates the mean and standard deviation of historical values and then generates random values that conform to a normal distribution. For string types, the intelligent interpolation algorithm randomly selects or generates new parameter values based on pattern features from historical values. This embodiment uses a dynamic parameter generation algorithm to generate new request parameters based on learned patterns, ensuring the validity of each API request. This method does not require pre-defining a fixed request template, but adapts to changes in the platform interface by learning real user behavior, and its success rate far exceeds that of traditional fixed template solutions.
[0077] In this embodiment, client device 1 utilizes the performance API of browser 10 to obtain real network historical request records. The prompt word execution engine 221 analyzes the characteristics and patterns of these historical request records using a pattern recognition algorithm, dynamically generating new valid request parameters based on the analysis results. This adaptively adjusts the parameters, improving the system's adaptability. The prompt word execution engine 221 learns the request pattern characteristics generated by normal user operations through a pattern recognition algorithm, generating request parameters that meet platform expectations, thus improving request effectiveness. Browser 10 can automatically adapt to the interface characteristics of different platforms, reducing manual configuration workload and maintenance costs. All operations are executed within the user-authorized page context, adhering to the browser 10's security policy. It should be noted that the performance API can only obtain request records for the current page; cross-page requests require additional processing mechanisms, which will not be detailed in this embodiment.
[0078] This application embodiment also provides an operation flow for a cross-domain image processing method applied to step S18 of the cross-platform document content processing method shown. (See reference...) Figure 5 As shown, Figure 5 yes Figure 3A detailed flowchart of the cross-domain image processing method in step S17 is shown below. In this embodiment, the cross-domain image processing utilizes the access permissions of the content scripts 213 of the browser plugin 21, allowing the content scripts 213 to run within the context of the target page. This enables each Prompt task's access request to have access to the page's Document Object Model (DOM) and resources. The AI processing layer 22 can bypass cross-domain access restrictions and directly process image resources on the target page by creating a Canvas element within the context. Step S17, the cross-domain image processing method, includes steps S170 to S180.
[0079] Step S170: Parse the HTML structure from the document content of the target page; In this embodiment, the AI service unit 222 of the AI processing layer 22 uses DOMParser to parse the document content of the target page and identify the HTML page structure.
[0080] Step S171: Find the image tag format from the HTML page structure; In this embodiment, the AI service unit 222 uses querySelectorAll to find all image tag formats (such as IMG format, PNG format, JPEG format, etc.) to locate image resources.
[0081] Step S172: Filter invalid links on the target page to obtain valid URLs for the images; In this embodiment, the AI service unit 222 filters out invalid URLs and invalid links for the images and generates a local path identifier for each valid image, thereby ensuring the validity of the processed images. If the image link is empty or the image tag format is a non-standard URL link, the AI service unit 222 executes an image tag format downgrade mechanism. The implementation method of the image tag format degradation mechanism includes: checking the image file extension to detect the image tag format; determining the image tag format based on the URL and MIME type, and determining the image tag format based on the image file name suffix and file type; if browser 10 does not support a certain format, then selecting an image tag format that supports browser 10; prioritizing image tag formats with high compression efficiency through a format priority list, for example: WebP compression format is the best, PNG format is the second best, and JPEG format is the last best; if browser 10 supports the original image tag format, then AI service unit 222 uses the original image tag format; if browser 10 does not support the original image tag format, then AI service unit 222 selects a degradation format according to priority, that is, starting from the best image tag format (e.g., WebP compression format), finding the image tag format supported by browser 10 as the last image tag format to be degraded.
[0082] In the image tag format downgrade mechanism described in this embodiment, the AI service unit 222 first detects the tag format of the original image, and then selects the best image tag format according to the list of formats supported by the browser 10. For example, the AI service unit 222 prioritizes image tag formats with high compression efficiency (such as WebP compression format) from the format priority list. If the browser 10 does not support the image tag format, it downgrades to PNG format, and finally to JPEG format. Therefore, this image tag format downgrade strategy ensures compatibility in various browser environments.
[0083] Step S173: Create an image canvas element in the target page context; In this embodiment, the AI service unit 222 uses the access permissions of the content script 213 to create an image canvas element, i.e., an image Canvas element, in the target page context. Once the image Canvas element is created on the target page, the Prompt task request can have access permissions to access the image content on the target page.
[0084] Step S174: Set the cross-domain processing attribute of the image canvas element; In this embodiment, the AI service unit 222 sets the crossOrigin attribute of the image Canavs element to "anonymous", which instructs the browser 10 to make a cross-domain request but does not require the user login information as a setting credential.
[0085] Step S175: Determine whether the image was successfully loaded from the URL address; In this embodiment, the AI service unit 222 determines whether the image requested by the Prompt task was successfully loaded from the valid URL address of the image. If the image requested by the Prompt task was successfully loaded from the URL address, then step S176 is executed; if the image requested by the Prompt task was not successfully loaded from the URL address, then step S180 is executed.
[0086] Step S176: Draw the image onto the canvas; In this embodiment, the AI service unit 222 draws the cross-image onto the canvas and obtains complete pixel data access permissions for the image through the content script 213. This allows for various operations on the image, such as accessing images on a webpage and downloading images from the webpage. In this embodiment, the AI service unit 222 can use an image segmentation processing algorithm to optimize the downloaded cross-image, for example, cutting a large photo into many small pieces, processing them one by one, and discarding them after processing to save memory resources. The segmentation processing algorithm implementation method includes the following steps: cutting the photo into grid-like small pieces; calculating the image size of each small piece to ensure that the last small piece does not exceed the image boundary; creating an independent canvas for each small piece; drawing the small piece onto the corresponding canvas; performing performance optimization parameter processing on the pixel data of each small piece; and reassembling all the processed small pieces into a complete image. AI service unit 222 uses an adaptive size control algorithm to perform performance optimization parameter processing on the downloaded images. This adaptive size control algorithm can automatically adjust the optimal size for image processing based on the performance and memory size of client device 1. The algorithm implementation steps include: (A) Detecting device performance: obtaining the display pixel ratio of client device 1 (e.g., high-resolution screens require more memory), checking the available memory of client device 1, obtaining the available memory size from client device 1, and using 1GB as the default value if memory information cannot be obtained; (B) Calculating the maximum size: calculating the maximum image size based on the performance and available memory of client device 1, with each pixel occupying 4 bytes (RGBA, red, green, blue, transparency), and higher resolution screens requiring more memory due to pixel density; (C) Maintaining aspect ratio: calculating the aspect ratio of the image based on the maximum image size to determine the optimal width and corresponding height, obtaining the integer size of the image to ensure pixel alignment and avoid image distortion.
[0087] Step S177: Convert the canvas image data into binary image data. In this embodiment, the toDataURL or toBlob method is used to convert the canvas image data into binary image data. For example, the generated Blob data can be freely manipulated (e.g., saved and transmitted) without being restricted by cross-domain permissions. In some embodiments, the AI service unit 222 can compress the binary image data using an intelligent compression algorithm to reduce the image storage space. The implementation method of the intelligent compression algorithm includes the following steps: calculating a specified compression ratio based on the original size and target size of the image, for example, using a logarithmic function to calculate the specified compression ratio to ensure that the image size is within a reasonable range; compressing the image to the specified compression ratio; estimating the size of the compressed image based on the number of pixels in the image; if the compressed image is still too large (e.g., the compressed image is much larger than the target size), then adjusting the minimum compression ratio according to the image type and the required image quality, and continuing to compress using a recursive compression function to reach the minimum compression ratio.
[0088] Step S178: Generate a local storage path and replace the image's URL address with the local storage path; In this embodiment, the local storage unit 231 of the data storage layer 23 generates a local storage path for saving images and replaces the original URL address of the image with the local storage path to achieve localized management of image resources.
[0089] Step S179: Save the image binary data in the local storage path and update the image resources; In this embodiment, the local storage unit 231 saves the image binary data in the local storage path for subsequent use, ensuring the integrity of the image data; maintain the image resource structure, and support the unified management and access of image resources.
[0090] Step S180: Record the error message of image loading failure and return the error message to the client device; In this embodiment, when the image fails to load from the URL address, the AI service unit 222 records the error message of image loading failure and returns the error message to the client device 1.
[0091] The cross-domain image processing method provided in this embodiment creates a Canvas element in the context of the target page. By setting the cross-domain attribute of the image, browser 10 makes a cross-domain request but does not send user credentials. The image is drawn onto the Canvas and the Canvas content is converted into image binary data. The entire process is implemented directly on the client side, reducing reliance on server proxies and lowering network transmission overhead and deployment complexity. The content script 213 of browser plugin 2 executes code in the target page environment, utilizing the page's access permissions to process image resources, thus bypassing cross-domain access restrictions. Image processing is completed directly in the browser's memory, reducing network round-trip time compared to server proxy solutions. The processing is transparent to the user, requiring no complex configuration steps and simplifying the usage process. It should be noted that this cross-domain image processing solution requires the target website to support Cross-Origin Resource Sharing (CORS) or the image resource itself to allow cross-domain access; otherwise, a CORS error will be triggered.
[0092] Another embodiment of this application also relates to a client device, such as Figure 1 As shown, the client device 1 includes, but is not limited to, a browser 10, a processor 11, a memory 12, and a computer program stored on the memory 12 and executable on the processor 11. When the processor 11 executes the computer program, it implements any of the above embodiments of the cross-platform document content processing method described in this application.
[0093] Another embodiment of this application relates to a computer-readable storage medium storing a computer program. When executed by a processor, the computer program implements any of the above embodiments of the cross-platform document content processing method described in this application.
[0094] Those skilled in the art will understand that all or part of the steps in the methods of the above embodiments can be implemented by a computer program instructing related hardware. This computer program is stored in a storage medium and includes several program instructions to cause the processor (e.g., the central processing unit 11, microprocessor, single-chip microcomputer, etc. provided in this embodiment) of a computing device (which may be a computer, tablet computer, mobile phone, or other mobile terminal device, such as the client device 1 provided in this embodiment) to execute all or part of the steps of the cross-platform document content processing method described in the various embodiments of this application. The aforementioned computer-readable storage medium includes, but is not limited to, various storage media capable of storing computer program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0095] Those skilled in the art will understand that the above embodiments are specific examples of implementing the present invention, and in practical applications, various changes in form and detail may be made without departing from the spirit and scope of the present invention.
Claims
1. A cross-platform document content processing method, characterized in that, The method includes: The browser plugin receives prompts from the client device for accessing the target page. These prompts include a chain of prompt words and format conversion requirements. The AI processing layer decomposes the prompt word chain into multiple interrelated prompt word tasks; Analyze the characteristics of the browser's historical request records to generate valid request parameters for each prompt word task; Each prompt word task is executed sequentially based on the valid request parameters of each prompt word task, and the document content corresponding to each prompt word task is obtained from the target page; The document content obtained from all executed prompt word tasks is integrated to form multimodal data; The multimodal data is converted into a document based on the format conversion requirements. The browser displays the document processing results to the client device.
2. The cross-platform document content processing method according to claim 1, characterized in that, The step of decomposing the prompt word chain into multiple interrelated prompt word tasks through an AI processing layer specifically includes: Verify the dependencies of each prompt word in the prompt word chain; The prompt word chain is decomposed into multiple interconnected prompt word tasks based on the dependencies of each prompt word, and a dependency graph of all prompt word tasks is constructed using an adjacency list storage algorithm; and The execution order and execution plan for each prompt word task are determined by a topological sorting algorithm.
3. The cross-platform document content processing method according to claim 2, characterized in that, The dependency graph construction algorithm is an adjacency list storage algorithm. This algorithm uses the node data structure of the dependency graph to store the dependency relationship of each prompt word task. The implementation method of this adjacency list storage algorithm includes: Define the node data structure of the dependency graph to represent the dependency relationship between each prompt word task; Initialize all nodes of the dependency graph and add all prompt word tasks to the corresponding nodes of the dependency graph; Check the dependencies between one of the cue word tasks and the other cue word tasks in turn; If one of the prompt word tasks references other prompt word tasks, then add an edge between the nodes representing the two prompt word tasks to indicate their dependency relationship, and update the in-degree of the current node. Use a depth-first search function to search all nodes to check if the current node has a circular dependency; If the current node has a circular dependency, then put the current node into the recursion stack; If the current node does not have circular dependencies, then visit all neighboring nodes of the current node; For each unvisited node, perform a circular dependency check using the depth-first search function until all prompt word tasks are free of circular dependencies.
4. The cross-platform document content processing method according to claim 2, characterized in that, The topology sorting algorithm is an algorithm that sorts all prompt word tasks based on the in-degree of nodes in the dependency graph. The implementation method of this algorithm includes: Find all nodes with an in-degree of 0 in the dependency graph and add them to the queue; The nodes in the queue are processed sequentially. For each node processed, the node storing the prompt word task is removed from the queue, and the in-degree of all neighboring nodes of that node is updated. Determine whether the final number of nodes processed is equal to the total number of nodes in the dependency graph; If the final number of nodes processed is not equal to the total number of nodes in the dependency graph, then the current node has a circular dependency, and the prompt word task for the current node will not be executed. If the final number of nodes processed is equal to the total number of nodes in the dependency graph, then the current node does not have a circular dependency, the prompt word task for the current node is executed, and the execution result of the prompt word task is stored.
5. The cross-platform document content processing method according to claim 1, characterized in that, The step of dynamically generating valid request parameters for each prompt word task based on the browser's historical request records specifically includes: The AI processing layer obtains network request records through the browser's performance API; Extract the target API request from the network request record; Pattern recognition algorithms are used to identify the pattern features of the target API request; Valid request parameters for each prompt word task are generated based on the pattern characteristics of the target API request.
6. The cross-platform document content processing method according to claim 5, characterized in that, The pattern recognition algorithm includes a parameter frequency analysis algorithm and a time series analysis algorithm, wherein: The implementation method of the parameter frequency analysis algorithm includes: traversing all network request records, counting the occurrence frequency and parameter value of each parameter in the network request record; calculating the frequency ratio of each parameter; when the frequency ratio of the parameter is greater than a predefined threshold, determining the valid request parameter by analyzing each parameter value, which includes strings, numbers, boolean values and / or timestamps; The implementation steps of the time series analysis algorithm include: sorting all access requests for prompt word tasks by timestamp, calculating the time interval between adjacent access requests; calculating the average interval and variance of each access request to obtain the coefficient of variation, and using the coefficient of variation to determine the time pattern of each access request.
7. The cross-platform document content processing method according to claim 1, characterized in that, The method also includes: The AI processing layer sequentially sends access requests for each prompt word task to the target page. Check each prompt word task individually to see if the access request was successful; If the access request for the prompt word task is successful, the AI processing layer executes the prompt word task according to the valid request parameters of the prompt word task. If the access request for the prompt word task fails, the error message of the failed access request is recorded through the data storage layer and returned to the client device through the browser plugin.
8. The cross-platform document content processing method according to claim 7, characterized in that, The AI processing layer determines whether the access request for each prompt word task is successful by verifying the access permissions of the target page and / or the compatibility between the target page and the browser plugin.
9. The cross-platform document content processing method according to claim 1, characterized in that, The method also includes: Determine if the document content corresponding to the prompt word task being executed contains images; If the document content contains images, then process the images to obtain the image data for the prompt word task. If the document content does not contain images, then the text data for the prompt word task is obtained from the document content.
10. The cross-platform document content processing method according to claim 9, characterized in that, The process of integrating the document content obtained from all executed prompt word tasks to form multimodal data specifically includes: integrating the text data and image data obtained from all executed prompt word tasks to form the multimodal data.
11. The cross-platform document content processing method according to claim 9, characterized in that, The image data for the task of obtaining prompt words across images specifically includes: The HTML page structure is parsed from the document content of the target page; Find the image tag format from the HTML page structure; Filter out invalid links on the target page to obtain valid URLs for the images; Create an image canvas element in the context of the target page, and set the cross-domain processing attribute of the image canvas element; Determine whether the image for the executed prompt word task has been successfully loaded from the URL address; If the image requested by the prompt word task is successfully loaded from the URL address, the loaded image will be drawn onto the canvas. If the image requested by the executed prompt word task is not successfully loaded from the URL address, an error message indicating that the image failed to load is recorded and the error message is returned to the client device. Convert the image data in the canvas into binary image data; Generate a local storage path and replace the URL of the loaded image with that local storage path; The binary data of the image is saved in the local storage path, and the image resources in the local storage path are updated.
12. The cross-platform document content processing method according to claim 11, characterized in that, The step of drawing the loaded image onto the canvas specifically includes: optimizing the loaded image using an image segmentation processing algorithm, wherein the implementation method of the segmentation processing algorithm includes: Cut the photograph into grid-like pieces; Calculate the image size of each small block to ensure that the last small block does not exceed the image boundary; Create a separate canvas for each small block, and draw each small block onto the corresponding canvas; Perform performance optimization parameter processing on each small block of pixel data; and Reassemble all the processed small pieces into a complete image.
13. The cross-platform document content processing method according to claim 11, characterized in that, The step of drawing the loaded image onto the canvas specifically includes: performing performance optimization processing on the loaded image using an adaptive size control algorithm, wherein the implementation method of the adaptive size control algorithm includes: Obtain the display pixel ratio of the client device and check the available memory of the client device; The maximum image size is calculated based on the client device's performance and available memory; and The aspect ratio is calculated based on the maximum image size to determine the optimal width and height of the icon.
14. The cross-platform document content processing method according to claim 11, characterized in that, The step of converting the image data in the canvas into binary image data specifically includes: compressing the binary image data using an intelligent compression algorithm, wherein the implementation method of the intelligent compression algorithm includes: The specified compression ratio is calculated based on the original size and target size of the image; Compress the image to the specified compression ratio; Estimate the size of the compressed image based on the number of pixels in the image; If the compressed image size is larger than the target size, the compression ratio is adjusted to the minimum based on the image type and quality, and then a recursive compression function is used to continue compression until the minimum compression ratio is reached.
15. A cross-platform document content processing system, characterized in that, The system includes a browser plugin and an AI processing layer. The browser plugin includes a user interface and a prompt word extension unit. The AI processing layer includes a prompt word execution engine and an AI service unit, wherein: The user interface is used to allow users to input prompts for accessing the target page from the client device. The prompts include prompt word chains and format conversion requirements. The prompt word expansion unit is used to input prompt content from the user interface and send the prompt content to the prompt word execution engine; The prompt word execution engine is used to decompose the prompt word chain into multiple interrelated prompt word tasks and analyze the characteristics of the browser's historical request records to generate valid request parameters for each prompt word task. The AI service unit is used to sequentially execute each prompt word task according to the valid request parameters of each prompt word task and obtain the document content corresponding to each prompt word task from the target page; The prompt word execution engine is also used to integrate the document content obtained from all executed prompt word tasks to form multimodal data, and to perform format conversion on the multimodal data according to the format conversion requirements to generate document processing results; The prompt word expansion unit is also used to display the document processing result to the client device through the browser.
16. The cross-platform document content processing system according to claim 15, characterized in that, The prompt word execution engine is also used to: sequentially initiate access requests for each prompt word task to the target page, determine whether each prompt word task access request is successful, execute the prompt word task according to the valid request parameters of the prompt word task when the access request of the prompt word task is successful, and return the error information to the client device when the access request of the prompt word task is unsuccessful.
17. The cross-platform document content processing system according to claim 15, characterized in that, The AI service unit is also used to: determine whether there are images in the document content corresponding to the executed prompt word task; if there are images in the document content, process the image data of the prompt word task across the images; if there are no images in the document content, obtain the text data of the prompt word task from the document content.
18. The cross-platform document content processing system according to claim 15, characterized in that, The system also includes a data storage layer, which comprises local storage units and a cache manager, wherein: The local storage unit is used to store the prompt content and the browser's historical request records; The cache manager is used to temporarily store the document content obtained by the prompt word task, and to record error information of prompt word tasks that fail to access the document.
19. The cross-platform document content processing system according to claim 15, characterized in that, The system also includes an SDK abstraction layer, which comprises SDK interfaces and a permission management unit, wherein: The SDK interface is a standard SDK extension interface used to enable communication between multiple platforms. The permission management unit is used to manage access permissions across multiple platforms through the content scripts of browser plugins.
20. A client device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the cross-platform document content processing method as described in any one of claims 1 to 14.
21. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program, wherein the computer program, when executed by a processor, implements the cross-platform document content processing method according to any one of claims 1 to 14.