Page inactivation detection methods, systems, devices, and storage media

By monitoring network resource requests and determining page inactivity, combined with user behavior analysis and background interception technology, the data security problem during unattended operation was solved, and the security and resource utilization efficiency were improved.

CN120017326BActive Publication Date: 2026-11-10INSPUR ZHUOSHU BIG DATA IND DEV CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202510071265.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-01-16
Publication Date
2026-11-10
Estimated Expiration
2045-01-16

AI Technical Summary

Technical Problem

During periods of unattended operation, the data security of enterprises and users is at risk of being stolen, and existing technologies lack effective preventive measures, leading to information leakage and waste of resources.

Method used

By monitoring network resource requests, recording requests and time points, calculating waiting time, and determining page inactivity when the time exceeds a set threshold, the main thread is shut down. By combining user behavior data analysis to set time thresholds, unnecessary requests are intercepted using background scripts, and user information is cached and verified to ensure security.

Benefits of technology

It effectively reduces security risks, prevents information leakage, releases unused resources, and improves resource utilization efficiency and detection accuracy.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120017326B_ABST
    Figure CN120017326B_ABST
Patent Text Reader

Abstract

The present application relates to the technical field of computer, and specifically provides a page inactivation detection method, system, device and storage medium, comprising: listening to network resource request, recording network resource request and time node; based on system time and the time node of the latest network resource request, calculating waiting time; confirming that the waiting time exceeds the set time threshold, determining page inactivation and closing the corresponding main thread. The present application avoids information leakage and other problems caused by long-time non-operation of the page, and releases invalid resources to improve resource utilization efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of computer technology, and specifically relates to a method, system, device and storage medium for detecting page inactivity. Background Technology

[0002] In today's digital age, data security has become a top priority for both businesses and users. With the rapid development of information technology, the value of data is increasingly evident, encompassing a wide range of important information such as business secrets and user privacy. However, in real-world scenarios, especially during periods of unattended operation, data faces a significant risk of theft.

[0003] For businesses, if their server rooms, office areas, and other locations lack effective security measures during off-hours or holidays, hackers may take the opportunity to intrude into the network system and steal core data such as financial data, customer information, and research and development results. This could cause huge economic losses and reputational damage to the company, and may even affect its survival and development.

[0004] For users, personal computers and mobile devices can become targets for data thieves when unattended. Once personal information such as ID numbers, bank card details, and social media accounts is stolen, it can lead not only to financial losses but also to a series of serious problems such as identity theft and privacy breaches, causing significant disruption and security risks to users' lives. Therefore, both businesses and users must attach great importance to data security during periods of unattended operation and take effective preventative measures to ensure the safety and integrity of their data. Summary of the Invention

[0005] In view of the above-mentioned shortcomings of the prior art, the present invention provides a page inactivation detection method, system, device and storage medium to solve the above-mentioned technical problems.

[0006] In a first aspect, the present invention provides a method for detecting page inactivity, comprising: Listen for network resource requests and record the network resource requests and time points; Calculate the waiting time based on the system time and the time of the latest network resource request. If the waiting time exceeds the set time threshold, the page is deemed inactive and the corresponding main thread is shut down.

[0007] In an optional implementation, network resource requests are monitored, and the network resource requests and time points are recorded, including: Configure the network resource address to listen on; A background script is used to intercept network resource requests and extract the target address from the network resource request. If the target address matches the network resource address, the network resource request and the time node are recorded. Forward the network resource request.

[0008] In an optional implementation, network resource requests are monitored, and the network resource requests and time points are recorded, including: An asynchronous task queue is created, and network resource requests intercepted by the main thread are saved to the asynchronous task queue. The main thread then forwards the saved network resource requests. The background thread extracts the network resource address and sending time from the network resource request stored in the asynchronous task queue, and updates the sending time to the structure pre-built for the network resource address.

[0009] In an optional implementation, a background thread extracts the network resource address and sending time from network resource requests stored in an asynchronous task queue, and updates the sending time to a structure pre-built for the network resource address, including: Obtain the monitoring object, which includes one or more network resource addresses; Create a unique structure corresponding to the network resource address, and name the corresponding structure with the network resource address; A background thread extracts the network resource address and sending time from the network resource requests stored in the asynchronous task queue. If the background thread confirms that the extracted network resource address belongs to the listening object, it saves the extracted sending time to the corresponding structure.

[0010] In one optional implementation, the waiting time is calculated based on the system time and the time of the latest network resource request, including: Traverse the structure, calculate the time difference between the time in the structure and the current system time, and output the time difference as the waiting time of the corresponding listening object.

[0011] In an optional implementation, the method further includes: Acquire user behavior data, which includes access addresses and access times within a specified period; User behavior data is divided into multiple data groups based on the access address; Clustering is performed on multiple data groups to obtain multiple categories corresponding to each access address; Calculate the maximum difference in access time for each category; Calculate the average of the maximum differences belonging to the same access address, and set the average value as the time threshold corresponding to the access address.

[0012] In an optional implementation, after determining that the page is inactive, the method further includes: Add the network resource addresses of network resource requests that are determined to be page inactive to the block list; The script runs in the background to intercept network resource requests and matches the target address of the intercepted network resource requests with the network resource addresses in the interception list. If the target address matches a network resource address in the interception list, the intercepted network resource request will be cached in the interception task queue. If the target address matches the network resource address in the interception list, the intercepted network resource request will be forwarded normally. Set the maximum cache time for the interception task queue, obtain the cache time of network resource requests in the interception task queue, and delete the corresponding network resource requests if the cache time exceeds the maximum cache time. Receive user authentication information, confirm that the user authentication information is consistent with the standard authentication information cached locally, and forward the network resource request in the interception task queue.

[0013] In a second aspect, the present invention provides a page deactivation detection system, comprising: The listening module is used to listen for network resource requests and record network resource requests and time points; The timing module is used to calculate the waiting time based on the system time and the time of the latest network resource request. The determination module is used to determine if the waiting time exceeds a set time threshold, and then to determine if the page is inactive and close the corresponding main thread.

[0014] Thirdly, a device is provided, comprising: The memory is used to store the page deactivation detection program; A processor is configured to implement the steps of the page deactivation detection method as provided in the first aspect when executing the page deactivation detection program.

[0015] Fourthly, a computer-readable storage medium is provided, on which a page deactivation detection program is stored, wherein when the page deactivation detection program is executed by a processor, the page deactivation detection program implements the steps of the page deactivation detection method provided in the first aspect.

[0016] The beneficial effects of this invention are that the page inactivity detection method, system, device, and storage medium provided by this invention, by detecting and closing inactive pages, can reduce security risks and allow users to use the system with greater peace of mind, without worrying about information leakage or other problems caused by prolonged inactivity on pages, and also release ineffective resources, improving resource utilization efficiency. Furthermore, by analyzing user behavior data and setting time thresholds, inactive pages can be detected more rationally, improving detection accuracy.

[0017] Furthermore, the design principle of this invention is reliable, the structure is simple, and it has a very wide range of application prospects. Attached Figure Description

[0018] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, for those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0019] Figure 1 This is a schematic flowchart of a method according to an embodiment of the present invention.

[0020] Figure 2 This is a schematic block diagram of a system according to an embodiment of the present invention.

[0021] Figure 3 This is a schematic diagram of the structure of a device provided in an embodiment of the present invention. Detailed Implementation

[0022] To enable those skilled in the art to better understand the technical solutions of this invention, the technical solutions of the embodiments of this invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this invention, and not all embodiments. Based on the embodiments of this invention, all other embodiments obtained by those skilled in the art without creative effort should fall within the scope of protection of this invention.

[0023] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention pertains. The terminology used herein in the description of the invention is for the purpose of describing particular embodiments only and is not intended to be limiting of the invention.

[0024] The page deactivation detection method provided in this embodiment of the invention is executed by a computer device, and correspondingly, the page deactivation detection system runs in the computer device.

[0025] Figure 1 This is a schematic flowchart illustrating a method according to an embodiment of the present invention. Wherein, Figure 1 The executing entity can be a page deactivation detection system. Depending on different requirements, the order of the steps in this flowchart can be changed, and some can be omitted.

[0026] like Figure 1 As shown, the method includes: S1 listens for network resource requests and records the network resource requests and time points.

[0027] After the page has finished loading, the browser begins listening for all network resource requests by calling relevant APIs (such as the fetch event listener in web development). These requests include, but are not limited to, requests to load resources such as HTML files, CSS stylesheets, JavaScript scripts, images, and videos.

[0028] When each network resource request is detected, in addition to allowing the request to proceed normally, detailed information about the request should be recorded. This recording includes the request's URL, which identifies the target resource; the request method (e.g., GET, POST, PUT), used to understand the type of operation; and the request's initiation time, precisely recording the request's position on the system timeline. This time can be obtained by calling a system time-retrieval function (e.g., Date.now() in JavaScript) to get the current timestamp.

[0029] Recorded network resource request information and corresponding timestamps are stored in a specific data structure. You can choose to use an array, an object, or a database to store this information for later querying and analysis. For example, in JavaScript, you can create an array where each element is an object containing properties such as url, method, and timestamp to store the relevant request information and timestamps.

[0030] S2 calculates the waiting time based on the system time and the time of the latest network resource request.

[0031] At each point where the wait time needs to be calculated (which can be triggered at certain time intervals, such as every second), the current system time is obtained, and the timestamp is obtained by calling the system's time retrieval function. Simultaneously, the time of the latest network resource request is retrieved from previously stored records. If this is the first time the wait time is calculated, and no network resource requests have been recorded yet, the wait time is temporarily set to 0.

[0032] The waiting time is the difference between the current system time and the timestamp of the latest network resource request. For example, if the current system time timestamp is 1632456789000 and the timestamp of the latest network resource request is 1632456780000, then the waiting time is 1632456789000 - 1632456780000 = 9000 milliseconds (i.e., 9 seconds).

[0033] S3, if the waiting time exceeds the set time threshold, then the page is determined to be inactive and the corresponding main thread is closed.

[0034] Based on the application's business needs and user habits, set an appropriate time threshold. This threshold can be fixed, such as 10 minutes or 30 minutes; or it can be dynamically adjusted according to different page types or user operation history. For example, for pages that require real-time interaction, the time threshold can be set relatively short; while for pages that are primarily for browsing, the time threshold can be appropriately extended.

[0035] The calculated waiting time is compared with a set time threshold. If the waiting time exceeds the set time threshold, it indicates that no new network resource requests have occurred for a relatively long period of time. This likely means that the user has stopped interacting with the page, thus determining that the page is inactive.

[0036] Once a page is determined to be inactive, appropriate measures need to be taken to shut down the main thread. The methods for shutting down the main thread differ depending on the programming environment. In a web browser environment, the main thread can be stopped and related resources released by calling the `window.close()` method (under specific conditions) or by using Web Workers-related technologies.

[0037] In one embodiment of the present invention, based on step S1, the following will provide a possible embodiment and describe its specific implementation in a non-limiting manner.

[0038] Configure the network resource address to be monitored; intercept network resource requests using a background script, extract the target address from the network resource request, and if the target address matches the network resource address, record the network resource request and the time point; forward the network resource request.

[0039] Specifically, it includes the following steps: S101. Create an asynchronous task queue, save the network resource requests intercepted by the main thread to the asynchronous task queue, and forward the saved network resource requests.

[0040] In a specific example, the request processing flow based on Service Worker threads is as follows: In the JavaScript code on the main page, you first need to register the Service Worker: <!DOCTYPE html> <meta charset="UTF-8"> <script>if ('serviceWorker' in navigator) { navigator.serviceWorker.register('service - worker.js') .then(function (registration) { console.log('Service Worker 注册成功');}) .catch(function (error) { console.log('ServiceWorker 注册失败: ', error);});}< / script> .

[0041] (1) Create an asynchronous task queue: Define a global array taskQueue as an asynchronous task queue.

[0042] (2) Intercepting network resource requests: By listening to the fetch event, all network resource requests are intercepted in the Service Worker. When a request arrives, the request object is added to the taskQueue queue, and the event.respondWith method is used to continue forwarding the request to ensure that the request can proceed normally.

[0043] The following is another specific process for intercepting and saving requests: (1) Create a global asynchronous task queue to store intercepted network resource requests. In Python, this can be achieved using lists.

[0044] (2) Use the Flask framework to intercept network requests. Flask's routing system can capture all incoming requests.

[0045] (3) In the function that handles the request, add the request object to the task queue.

[0046] import asyncio async def save_to_queue(request): task_queue.append(request) print(f"Request {request.url} has been saved to the queue") async def handle_request(request): await save_to_queue(request) # Continue processing the request # Here you can forward the request or perform other processing according to the actual situation return "Request has been processed".

[0047] (4) In the handle_request function, after the request is saved to the queue, the request can continue to be forwarded.

[0048] if __name__ == '__main__': app.run(debug=True).

[0049] S102. Use a background thread to extract the network resource address and sending time from the network resource request stored in the asynchronous task queue, and update the sending time to the structure pre-built for the network resource address.

[0050] Obtain a listening object, which includes one or more network resource addresses; construct a unique corresponding structure for each network resource address and name the corresponding structure with the network resource address; use a background thread to extract the network resource address and sending time from the network resource requests stored in the asynchronous task queue, and if the background thread confirms that the extracted network resource address belongs to the listening object, it saves the extracted sending time to the corresponding structure.

[0051] In a specific example, the method of using Service Worker threads to listen for requests includes the following process: (1) Initialization section: Create an empty asynchronous task queue (taskQueue) to store intercepted network resource requests.

[0052] Define an array of listeningObjects, which contains one or more network resource addresses that need to be monitored.

[0053] Initialize resourceStructures objects to store the structure corresponding to each monitored network resource address.

[0054] (2) Intercept and forward the request: Use self.addEventListener('fetch',...) to listen for all network resource requests.

[0055] When a request is detected, the request object is added to the taskQueue and the request is forwarded using the event.respondWith method to ensure that the request can get a response normally.

[0056] (3) Background thread processing: Use setInterval to create a scheduled task that executes once per second, simulating a background thread.

[0057] Each time the task is executed, check if there are any requests in the taskQueue. If there are, retrieve a request from the queue.

[0058] Extract the requested URL (i.e., the network resource address) and the current time as the sending time.

[0059] Check if the extracted network resource address is in the `listeningObjects` array. If so, create or retrieve the corresponding structure for that address, and add the sending time to the `sendTimes` array of the structure.

[0060] The code example is as follows: / / Create an asynchronous task queue const taskQueue = []; / / Listening object, containing one or more network resource addresses const listeningObjects = [ 'https: / / example.com / api / data', 'https: / / example.com / images / logo.png' ]; / / A structure used to store network resource addresses and sending times const resourceStructures = {}; / / Listen for the fetch event and intercept network resource requests self.addEventListener('fetch', function (event) { const request = event.request; / / Save the request to the asynchronous task queue taskQueue.push(request); console.log('Request has been added to the queue:', request.url); / / The main thread forwards the saved network resource request event.respondWith( fetch(request) .then(response =>{ console.log('Request has been forwarded and a response has been received:', request.url); return response;}) .catch(error =>{ console.error('An error occurred while forwarding the request:', error);}) );}); / / Background thread periodically retrieves information from the asynchronous task queue setInterval(() =>{ if (taskQueue.length>0) { const request =taskQueue.shift(); const resourceAddress = request.url; const sendTime = newDate().getTime(); / / Confirm that the retrieved network resource address belongs to the listener object if(listeningObjects.includes(resourceAddress)) { / / Construct a unique structure corresponding to the network resource address, and name the structure with the network resource address. if (!resourceStructures[resourceAddress]) { resourceStructures[resourceAddress] = { sendTimes: []};} / / Save the extracted send time to the corresponding structure resourceStructures[resourceAddress].sendTimes.push(sendTime); console.log('Send time has been saved to the structure:', resourceAddress, sendTime);}}}, 1000).

[0061] In one embodiment of the present invention, based on step S2, the following will provide a possible embodiment and describe its specific implementation in a non-limiting manner.

[0062] S201. Add a scheduled task: Add a new setInterval scheduled task that executes every 5 seconds (adjustable according to actual needs).

[0063] Get the current system time currentTime at each execution.

[0064] S202. Traversing the structure: Use a for...of loop to iterate through each network resource address in the listeningObjects array.

[0065] Check if a structure corresponding to the network resource address exists in the resourceStructures object.

[0066] S203. Calculate the time difference: If a structure exists and the sendTimes array in the structure contains records, take the last send time from the array.

[0067] Calculate the difference between the current system time and the last transmission time, timeDiff.

[0068] S204. Output waiting time: Output the calculated time difference (timeDiff) in the format "the waiting time of the monitored object [resource address] is: [time difference] milliseconds".

[0069] If the sendTimes array is empty, it means that the listener object has not yet sent any records, and the corresponding prompt message will be output.

[0070] If the corresponding structure does not exist, a corresponding prompt message will also be output.

[0071] In one embodiment of the present invention, based on step S3, the following will provide a possible embodiment and describe its specific implementation in a non-limiting manner.

[0072] S301. Set time threshold.

[0073] (1) Data acquisition First, user behavior data is collected through logging or user behavior tracking systems. On the front end, browser APIs (such as the `history` object to record page visit history and `performance.now()` to get timestamps) can be used, combined with the storage and query capabilities of the backend database, to obtain user behavior data within a specified period. This specified period can be set according to specific business needs, such as the past week or month. User behavior data includes the addresses visited by users (such as complete URLs) and the corresponding access times; this data will serve as the basis for subsequent analysis.

[0074] (2) Data grouping After obtaining user behavior data, the data is divided according to the access address. This operation can be implemented using data structures and algorithms in programming languages. For example, in Python, a dictionary can be used to store data groups with different access addresses. The user behavior data list is iterated through, and for each data record, the access address is used as the key to add the record to the value list corresponding to that key. In this way, each key corresponds to an access address, and its value is a data group consisting of all access records for that address.

[0075] (3) Clustering Before clustering the data groups divided by access address, preprocessing is required. Since we are interested in the access time of a user to a specific access address within a specified period, the access time in each data group is extracted to form a time series. For example, for a data group of a certain access address, the extracted access time series might be [1600000000000, 1600000010000, 1600000020000,...], where these timestamps represent the specific time of each user's access to that address.

[0076] The time series data is converted into a format suitable for the DBSCAN algorithm. Typically, the DBSCAN algorithm processes points in two-dimensional or multi-dimensional space; here, we can consider each timestamp as a point in one-dimensional space. For ease of algorithm implementation, these timestamps are organized into a list, where each element is a list containing a single time value, for example, [[1600000000000], [1600000010000], [1600000020000],...].

[0077] Setting `epsilon` (neighborhood radius) defines the range of a point's neighborhood. In time series scenarios, `epsilon` represents the maximum time interval between two accesses. If two time intervals are less than or equal to `epsilon`, the two accesses are considered to belong to the same neighborhood. Determining the value of `epsilon` requires considering the business scenario and data characteristics. For example, if users frequently access a page within a short period, `epsilon` can be set relatively small; if the user's access intervals are likely to be large, `epsilon` needs to be appropriately increased. A suitable `epsilon` can be determined by experimenting with different values ​​and combining them with business understanding. For example, you could start by setting it to 60000 (representing 60 seconds) and then adjust it based on the clustering results.

[0078] Setting `minPts` (minimum number of points) indicates the minimum number of points a neighborhood must contain to constitute a core point. In user access behavior analysis, `minPts` can be used to filter out isolated or potentially anomalous accesses. For example, if `minPts` is set to 3, then a neighborhood must have at least 3 access timestamps to be considered a core point. Similarly, the value of `minPts` needs to be adjusted based on the specific situation; you can start with smaller values, such as 2 or 3, and observe the clustering effect.

[0079] Initialize the DBSCAN algorithm by passing the prepared time series data and the set epsilon and minPts parameters. The algorithm begins to traverse each point in the dataset. For each point, it calculates the number of points in its neighborhood. If the number of points in the neighborhood is greater than or equal to minPts, the point is marked as a core point; if the number of points in the neighborhood is less than minPts and the point is not a neighbor of any core point, it is marked as a noise point; if a point is a neighbor of a core point but is not a core point itself, it is marked as a boundary point. Starting from a core point, the algorithm connects all points belonging to the same cluster using breadth-first search (BFS) or depth-first search (DFS) to form a cluster. This cluster represents the access request generated by a user's continuous usage behavior. During the traversal, the core point continuously expands its neighborhood, adding points within that neighborhood to the same cluster. The above steps are repeated until all points are marked as part of a cluster or noise points.

[0080] After the DBSCAN algorithm completes, it will produce multiple clustering results and some noisy points. The noisy points can be ignored based on business requirements.

[0081] For each cluster, the access time points it contains are mapped back to the original data records. This yields the set of access requests generated by a single, uninterrupted user activity at that access address. For example, if a cluster contains time points [1600000000000, 1600000010000, 1600000020000], by searching the original data records, the specific access request information corresponding to these time points can be obtained, such as the request parameters and request type.

[0082] (4) Calculate the maximum difference For each cluster obtained by the DBSCAN algorithm (i.e., the set of access requests generated by a user's continuous usage behavior), find the earliest and latest access times.

[0083] The difference between the latest access time and the earliest access time is calculated; this difference represents the maximum difference in access times within that cluster. This maximum difference reflects the longest duration a user spent accessing that address during this uninterrupted usage session.

[0084] (5) Calculate the average value and set the time threshold. Calculate the average of the maximum differences across all categories belonging to the same access address. Sum the maximum differences calculated for each category, then divide by the number of categories to obtain the average. This average is the time threshold corresponding to that access address. In this way, a personalized time threshold is set for each access address, reflecting the user's behavioral patterns and time interval characteristics at that address.

[0085] S302. Compare the waiting time of the monitored object obtained in S2 with the corresponding time threshold. If the waiting time reaches the time threshold, the page is determined to be inactive.

[0086] For each listener object, its waiting time is compared with the corresponding time threshold. If the waiting time is greater than or equal to the time threshold, it means that the user has not performed any new operation on that listener object (access address) for a sufficiently long time, which meets the criteria for page inactivity.

[0087] Once the waiting time for a certain monitored object reaches a certain threshold, the page associated with that monitored object is determined to be inactive. This inactivity status can be recorded in the program using a flag or state variable for subsequent operations.

[0088] S303. Close the main process of the inactive page.

[0089] In a browser environment, each page typically corresponds to an independent process (or in some cases, a thread). The main process associated with an inactive page can be identified using browser-provided APIs (such as the chrome.tabsAPI in Chrome to obtain page-related information).

[0090] Once the main process of the inactive page is identified, appropriate measures should be taken to shut it down. In a browser environment, the `chrome.tabs.remove()` method (for Chrome extensions) or the `window.close()` method (in regular web page scripts, under specific conditions) can be used to close the corresponding page process. Alternatively, a Service Worker thread can be used to communicate with the main thread, informing it to execute relevant exit logic, validation logic, and other specific operations.

[0091] Based on the above embodiments, to avoid service interruption caused by closing the main thread and the need for users to log in again, a buffering mechanism is set up in one embodiment, specifically including: 1. Add the network resource address of the network resource request that is determined to be a dead page to the block list.

[0092] When a page is determined to be inactive (based on previously set time thresholds and other conditions), the network resource addresses of the network resource requests related to that page are recorded for subsequent interception. In the page inactivity determination logic module, once a page is determined to be inactive, the network resource addresses of all network resource requests generated by that page are obtained. These addresses can be recorded while listening for network resource requests; for example, in the previous Service Worker's fetch event listener, we could maintain a global variable to store the request address information for each page.

[0093] The obtained network resource addresses are added to a dedicated intercept list. This intercept list can be an array or a more complex data structure, such as a hash table, for fast lookup and matching. For example, in JavaScript: / / Define the interception list let interceptionList = []; / / Assume the pageInactive function is the function to determine if a page is inactive function pageInactive(pageRequests) { / / pageRequests is an array of all network resource request addresses generated by this page interceptionList = interceptionList.concat(pageRequests);}.

[0094] 2. Use a background script to intercept network resource requests and match the target address of the intercepted network resource requests with the network resource addresses in the interception list.

[0095] The Service Worker thread in S1 is used to intercept requests for specific network resources.

[0096] In a Service Worker environment, all network resource requests are intercepted by listening for fetch events. Other application environments also have corresponding network request interception mechanisms. For example, in a Service Worker: self.addEventListener('fetch', function (event) { const targetAddress= event.request.url; / / Perform address matching const isMatch = interceptionList.some(address =>targetAddress.includes(address)); if (isMatch) { / / Perform the operation after matching} else { / / If not matching, forward the request normally event.respondWith(fetch(event.request));}}).

[0097] The intercepted network resource request's target address is compared with each network resource address in the interception list. String matching methods, such as the `includes` function (in JavaScript), can be used to determine if the target address contains an address from the interception list. If a match is found, the request needs further processing; otherwise, it is forwarded normally.

[0098] 3. If the target address matches the network resource address in the interception list, the intercepted network resource request will be cached in the interception task queue.

[0099] When a target address is found to match a network resource address in the interception list, the request is temporarily cached for later processing.

[0100] To store intercepted network resource requests, create a data structure in memory; this data structure is called the interception task queue. This can be implemented using arrays, linked lists, or queue data structures. For example, in JavaScript, an array can be used: let interceptionTaskQueue = [].

[0101] Add the successfully matched network resource request to the interception task queue. Simultaneously, record the cache time of this request for subsequent time management. For example: `self.addEventListener('fetch', function (event) { const targetAddress= event.request.url; const isMatch = interceptionList.some(address =>targetAddress.includes(address)); if (isMatch) { const requestWithTime = {request: event.request, cacheTime: new Date().getTime()};interceptionTaskQueue.push(requestWithTime); / / Here you can choose not to forward the request directly and wait for subsequent processing} else { event.respondWith(fetch(event.request));}})`

[0102] 4. If the target address matches a network resource address in the interception list, the intercepted network resource request will be forwarded normally. In some cases, even if the target address matches a network resource address in the block list, the request still needs to be forwarded normally to ensure that certain essential functions can operate correctly. This is because some requests are necessary for page recovery or are public requests that do not affect security.

[0103] After matching the target address, it's necessary to determine whether the request can be forwarded normally based on certain predefined rules. These rules are based on the request type (e.g., the HTTP method is GET and the requested resource is a static resource), request parameters, etc. For example: self.addEventListener('fetch', function (event) { const targetAddress= event.request.url; const isMatch = interceptionList.some(address =>targetAddress.includes(address)); if (isMatch) { const request =event.request; / / Determine that the request type is GET and the requested resource is a specific static resource if(request.method === 'GET'&&request.url.match( / \.css|\.js|\.png|\.jpg / )) {event.respondWith(fetch(request));} else { const requestWithTime = {request: event.request, cacheTime: new Date().getTime()};interceptionTaskQueue.push(requestWithTime);}} else { event.respondWith(fetch(event.request));}}).

[0104] 5. Set the maximum cache time for the interception task queue, obtain the cache time of network resource requests in the interception task queue, and delete the corresponding network resource requests if the cache time exceeds the maximum cache time.

[0105] To prevent excessive memory consumption from the intercepted request queue, cache time needs to be managed. A reasonable maximum cache time should be set based on business needs and system resource availability. This time can be a fixed value or dynamically adjusted according to different request types or system states. For example, a maximum cache time of 5 minutes (300,000 milliseconds) can be set.

[0106] Periodically check the cache time of each network resource request in the interception task queue. This check can be performed periodically using the `setInterval` function (in JavaScript). For each request, calculate the difference between the current time and the cache time; if the difference exceeds the maximum cache time, remove the request from the interception task queue.

[0107] 6. Receive user verification information, confirm that the user verification information is consistent with the standard verification information cached locally, and forward the network resource request in the interception task queue.

[0108] The user interface provides a verification mechanism that allows users to enter verification information. This information can be a password, verification code, fingerprint, etc. After the user enters the verification information, it is sent to the backend for verification. On the frontend, verification information can be sent to the backend via form submission or a specific API call.

[0109] In the background, the received user authentication information is compared with locally cached standard authentication information. The locally cached standard authentication information can be the password set during user registration or authentication data generated through other security mechanisms. If they match, the user's identity is considered legitimate, and the network resource request in the interception task queue can be forwarded. For example: / / Assuming the receiveVerificationInfo function receives user verification information function receiveVerificationInfo(userInfo) { const storedInfo = localStorage.getItem('standardVerificationInfo'); if (userInfo === storedInfo) { / / Verification successful, forward the request in the interception task queue interceptionTaskQueue.forEach(requestWithTime =>{ fetch(requestWithTime.request) .then(response =>{ / / process the response}) .catch(error =>{console.error('Error forwarding request:', error);});}); / / Clear the interception task queue interceptionTaskQueue = [];} else { console.log('User verification failed');}}.

[0110] In some embodiments, the page deactivation detection system may include multiple functional modules composed of computer program segments. The computer programs for each program segment in the page deactivation detection system may be stored in the memory of a computer device and executed by at least one processor to perform (see details). Figure 1 (Description) Functionality for page inactivity detection.

[0111] In this embodiment, the page inactivity detection system can be divided into multiple functional modules based on its functions, such as... Figure 2 As shown. The system's functional modules may include: a monitoring module, a timing module, and a decision module. The module referred to in this invention is a series of computer program segments that can be executed by at least one processor and perform a fixed function, stored in memory. In this embodiment, the functions of each module will be detailed in subsequent embodiments.

[0112] The listening module is used to listen for network resource requests and record network resource requests and time points; The timing module is used to calculate the waiting time based on the system time and the time of the latest network resource request. The determination module is used to determine if the waiting time exceeds a set time threshold, and then to determine if the page is inactive and close the corresponding main thread.

[0113] Figure 3 The page deactivation detection method provided in the embodiments of this application can be applied to devices. Those skilled in the art will understand that the device structure involved in the embodiments of this invention does not constitute a limitation on the device. A device may include more or fewer components than illustrated, or combine certain components, or have different component arrangements. In the embodiments of this invention, the device includes, but is not limited to, laptop computers, desktop computers, workbenches, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The device may also represent various forms of mobile devices, such as personal digital processors, cellular phones, smartphones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the embodiments of this application described and / or claimed herein.

[0114] The device 300 may include a processor 310, a memory 320, and a communication unit 330. These components communicate via one or more buses. Those skilled in the art will understand that the server structure shown in the figure does not constitute a limitation of the present invention. It may be a bus topology or a star topology, and may include more or fewer components than shown, or combine certain components, or have different component arrangements.

[0115] The memory 320 can be used to store execution instructions of the processor 310. The memory 320 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic storage, flash memory, magnetic disk, or optical disk. When the execution instructions in the memory 320 are executed by the processor 310, the device 300 is able to perform some or all of the steps in the above method embodiments.

[0116] The processor 310 serves as the control center of the storage device, connecting various parts of the electronic device via various interfaces and lines. It executes software programs and / or modules stored in the memory 320, and calls data stored in the memory to perform various functions of the electronic device and / or process data. The processor can be composed of integrated circuits (ICs), such as a single packaged IC or multiple packaged ICs with the same or different functions connected together. For example, the processor 310 may consist only of a central processing unit (CPU). In this embodiment of the invention, the CPU may have a single processing core or include multiple processing cores.

[0117] The communication unit 330 is used to establish a communication channel, enabling the storage device to communicate with other devices. It can receive user data sent by other devices or send user data to other devices.

[0118] The present invention also provides a computer storage medium, wherein the computer storage medium may store a program, which, when executed, may include some or all of the steps provided in the embodiments of the present invention. The storage medium may be a magnetic disk, an optical disk, read-only memory (ROM), or random access memory (RAM), etc.

[0119] Those skilled in the art will clearly understand that the techniques in the embodiments of the present invention can be implemented using software plus necessary general-purpose hardware platforms. Based on this understanding, the technical solutions in the embodiments of the present invention, or the parts that contribute to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium such as a USB flash drive, a portable hard drive, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk, or any other medium capable of storing program code. It includes several instructions to cause a computer device (which may be a personal computer, a server, or a second device, network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention.

[0120] The same or similar parts between the various embodiments in this specification can be referred to mutually. In particular, the device embodiments are basically similar to the method embodiments, so the description is relatively simple, and the relevant parts can be referred to the description in the method embodiments.

[0121] In the embodiments provided by this invention, it should be understood that the disclosed systems and methods can be implemented in other ways. For example, the system embodiments described above are merely illustrative. For instance, the division of modules is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple modules or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between systems or modules may be electrical, mechanical, or other forms.

[0122] The modules described as separate components may or may not be physically separate. The components shown as modules may or may not be physical modules; that is, they may be located in one place or distributed across multiple network modules. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs.

[0123] In addition, the functional modules in the various embodiments of the present invention can be integrated into one processing module, or each module can exist physically separately, or two or more modules can be integrated into one module.

[0124] Although the present invention has been described in detail with reference to the accompanying drawings and preferred embodiments, the present invention is not limited thereto. Various equivalent modifications or substitutions can be made to the embodiments of the present invention by those skilled in the art without departing from the spirit and essence of the invention, and such modifications or substitutions should all be within the scope of the present invention. Any variations or substitutions that can be easily conceived by those skilled in the art within the technical scope disclosed in the present invention should also be covered within the protection scope of the present invention.

Claims

1. A method for detecting page inactivity, characterized in that, include: After the page loads, listen for network resource requests and record the network resource requests and their timestamps. The waiting time is calculated based on the system time and the time of the latest network resource request, with each set time interval. If the waiting time exceeds the set time threshold, the page is determined to be inactive and the corresponding main thread is closed. Monitor network resource requests and record the network resource requests and time points, including: An asynchronous task queue is created, and network resource requests intercepted by the main thread are saved to the asynchronous task queue. The main thread forwards the saved network resource requests to ensure that the requests can be processed normally. The background thread extracts the network resource address and sending time from the network resource requests stored in the asynchronous task queue, and updates the sending time to the structure pre-built for the network resource address; The method involves using a background thread to extract network resource addresses and sending times from network resource requests stored in an asynchronous task queue, and updating the sending time to a pre-constructed structure for the network resource address, including: Obtain the monitoring object, which includes one or more network resource addresses; Create a unique structure corresponding to the network resource address, and name the corresponding structure with the network resource address; The background thread extracts the network resource address and sending time from the network resource requests stored in the asynchronous task queue. If the background thread confirms that the extracted network resource address belongs to the listening object, it saves the extracted sending time to the corresponding structure. The waiting time is calculated based on the system time and the time of the latest network resource request, including: Traverse the structure. If there is a record in the structure, calculate the time difference between the last time recorded in the structure and the current system time, and output the time difference as the waiting time of the corresponding listening object.

2. The method according to claim 1, characterized in that, Monitor network resource requests and record the network resource requests and time points, including: Configure the network resource address to listen on; A background script is used to intercept network resource requests and extract the target address from the network resource request. If the target address matches the network resource address, the network resource request and the time node are recorded. Forward the network resource request.

3. The method according to claim 1, characterized in that, The method further includes: Acquire user behavior data, which includes access addresses and access times within a specified period; User behavior data is divided into multiple data groups based on the access address; Clustering is performed on multiple data groups to obtain multiple categories corresponding to each access address; Calculate the maximum difference in access time for each category; Calculate the average of the maximum differences belonging to the same access address, and set the average value as the time threshold corresponding to the access address.

4. The method according to claim 1, characterized in that, After determining that the page is inactive, the method further includes: Add the network resource addresses of network resource requests that are determined to be page inactive to the block list; The script runs in the background to intercept network resource requests and matches the target address of the intercepted network resource requests with the network resource addresses in the interception list. If the target address matches a network resource address in the interception list, the intercepted network resource request will be cached in the interception task queue. If the target address matches the network resource address in the interception list, the intercepted network resource request will be forwarded normally. Set the maximum cache time for the interception task queue, obtain the cache time of network resource requests in the interception task queue, and delete the corresponding network resource requests if the cache time exceeds the maximum cache time. Receive user authentication information, confirm that the user authentication information is consistent with the standard authentication information cached locally, and forward the network resource request in the interception task queue.

5. A page deactivation detection system, characterized in that, include: The listening module is used to listen for network resource requests after the page has finished loading, and to record the network resource requests and time points. The timing module is used to calculate the waiting time at each set interval, based on the system time and the time of the latest network resource request. The determination module is used to determine that the page is inactive and close the corresponding main thread if the waiting time exceeds the set time threshold. Monitor network resource requests and record the network resource requests and time points, including: An asynchronous task queue is created, and network resource requests intercepted by the main thread are saved to the asynchronous task queue. The main thread forwards the saved network resource requests to ensure that the requests can be processed normally. The background thread extracts the network resource address and sending time from the network resource requests stored in the asynchronous task queue, and updates the sending time to the structure pre-built for the network resource address; The method involves using a background thread to extract network resource addresses and sending times from network resource requests stored in an asynchronous task queue, and updating the sending time to a pre-constructed structure for the network resource address, including: Obtain the monitoring object, which includes one or more network resource addresses; Create a unique structure corresponding to the network resource address, and name the corresponding structure with the network resource address; The background thread extracts the network resource address and sending time from the network resource requests stored in the asynchronous task queue. If the background thread confirms that the extracted network resource address belongs to the listening object, it saves the extracted sending time to the corresponding structure. The waiting time is calculated based on the system time and the time of the latest network resource request, including: Traverse the structure. If there is a record in the structure, calculate the time difference between the last time recorded in the structure and the current system time, and output the time difference as the waiting time of the corresponding listening object.

6. A page deactivation detection device, characterized in that, include: The memory is used to store the page deactivation detection program; A processor, configured to implement the steps of the page deactivation detection method as described in any one of claims 1-4 when executing the page deactivation detection program.

7. A computer-readable storage medium storing a computer program, characterized in that, The readable storage medium stores a page deactivation detection program, which, when executed by a processor, implements the steps of the page deactivation detection method as described in any one of claims 1-4.

Citation Information

Patent Citations

  • Page control method and device, electronic equipment and computer readable storage medium

    CN114629673A

  • Page exception processing method and device, equipment and storage medium

    CN119088467A