Method for reducing webpage watermark, computer readable storage medium and computer device
By monitoring changes in webpage DOM elements, generating and saving the style of watermark elements, the problem of high resource consumption in webpage watermark detection is solved, and efficient watermark recovery and user identity tracing are achieved.
Patent Information
- Application Number
- CN202210743288.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-06-28
- Publication Date
- 2025-12-23
- Estimated Expiration
- 2042-06-28
AI Technical Summary
In existing technologies, methods for detecting webpage watermarks consume computer resources, resulting in a poor user experience, and lack effective means of tracing user identity.
By using JavaScript change observers to listen for changes in DOM elements, the style of the watermark element is generated and saved. A handler function is bound to detect changes to the watermark element, and the watermark element state is restored and the user's identity is traced when a change is detected.
It improves detection performance, reduces computing resource consumption, and enables real-time monitoring of watermark elements and traceability of user identity.
Smart Images

Figure CN115033877B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application belongs to the field of image processing, and particularly relates to a method for restoring a webpage watermark, a computer readable storage medium and a computer device. BACKGROUND
[0002] A developer of a WEB webpage uses a polling technique to determine whether a watermark element on the webpage is deleted or modified, that is, uses JavaScript to continuously check whether the watermark element on the webpage exists every fixed time, and checks whether the style of the watermark element is changed.
[0003] However, this method consumes a lot of computer resources and may cause lag, which affects the user experience; high-frequency polling may cause the page of the user to lag, which greatly affects the user experience; and there is a lack of means for tracing the identity of a person who destroys the watermark. SUMMARY
[0004] The present application aims to provide a method for restoring a webpage watermark, a computer readable storage medium and a computer device, and aims to solve the problem of lacking means for tracing a user who changes a webpage watermark.
[0005] In a first aspect, the present application provides a method for restoring a webpage watermark, comprising:
[0006] generating a watermark element on an opened webpage, and saving the style of the watermark element;
[0007] obtaining user information logged in by a user before opening the webpage;
[0008] binding a processing function by listening to whether a Document Object Model (DOM) element is changed; the processing function is used for detecting whether the watermark element is changed by monitoring the style of the watermark element, and obtaining the opened webpage information and the user information, and restoring the state of the watermark element;
[0009] if no change occurs, the processing function is not triggered; if a change occurs, the processing function is triggered to check whether the watermark element is changed;
[0010] if the watermark element is changed, the watermark element is restored by using the saved style of the watermark element, and a watermark element change message and user information causing the change of the watermark element are sent to a backend server.
[0011] Further, the user information is real-name registered information or company internal account information.
[0012] Further, the method further comprises: the backend server sends the watermark element change message and the user information causing the change of the watermark element to a person in charge.
[0013] Further, the sending the watermark element change message and the user information causing the watermark element change to the backend server specifically comprises: the processing function encrypts the watermark element change message and the user information causing the watermark element change and sends the encrypted watermark element change message and the user information causing the watermark element change to the backend server as a normal request, and the backend server parses the request to obtain the watermark change message and the user information causing the watermark element change.
[0014] Further, the method further comprises: when the network is disconnected, the parsing request fails, the parsing request is saved, and the parsing request is reinitiated after the network is recovered.
[0015] Further, the generating the watermark element on the opened webpage and saving the style of the watermark element specifically comprises: generating a picture of the watermark element by using a canvas object of JavaScript, setting a unique id value for the watermark element, and saving the style of the current watermark element in a database in the background, wherein the style is written on an inline in a form of a highest priority.
[0016] Further, the watermark element change is that the watermark element is deleted or the style of the watermark element is modified; and the style of the watermark element is modified as the id and / or the inline of the watermark element are changed.
[0017] Further, the listening to whether the Document Object Model (DOM) element is changed specifically comprises: listening to the Document Object Model (DOM) element by using a MutationObserver of JavaScript.
[0018] The change refers to one or a combination of the following: a change in a characteristic of a Document Object Model (DOM) element, a change in a text node, or addition or deletion of a sub-element.
[0019] Further, the method further comprises: if the JavaScript is disabled before the webpage is loaded, not loading the content on the webpage.
[0020] The MutationObserver is initialized before the content on the webpage is loaded, and if the JavaScript is disabled after the content on the webpage is loaded, the MutationObserver will normally run.
[0021] If the memory is cleared, the content on the webpage is cleared.
[0022] In a second aspect, the application provides a computer readable storage medium, which stores a computer program, and the computer program is executed by a processor to implement the steps of the method for restoring a watermark of a webpage.
[0023] In a third aspect, the present application provides a computer device, comprising: one or more processors, a memory, and one or more computer programs, wherein the processor and the memory are connected through a bus, the one or more computer programs are stored in the memory and configured to be executed by the one or more processors, and the processor executes the computer program to implement the steps of the method for restoring the watermark of a webpage.
[0024] In the present application, the document object model (DOM) element is monitored by a mutation observer of JavaScript to determine whether the element is changed, and a processing function is triggered if the element is changed, thereby improving the monitoring performance and avoiding the defects of the traditional polling method. Meanwhile, the real identity of the user who changes the element watermark is traced through the user real-name level. BRIEF DESCRIPTION OF DRAWINGS
[0025] Figure 1 is a flowchart of the method for restoring the watermark of a webpage provided by an embodiment of the present application.
[0026] Figure 2 is a specific structural block diagram of the computer device provided by an embodiment of the present application. DETAILED DESCRIPTION
[0027] In order to make the objectives, technical solutions and advantages of the present application clearer, the present application is further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and do not limit the present application.
[0028] In order to illustrate the technical solutions of the present application, the following specific embodiments are used for illustration.
[0029] Please refer to Figure 1 The method for restoring the watermark of a webpage provided by an embodiment of the present application comprises the following steps: it should be noted that the method for restoring the watermark of a webpage provided by the present application is not limited to the flow order shown in the following steps as long as the same result is achieved. Figure 1
[0030] S101, generating a watermark element on an opened webpage and saving the style of the watermark element;
[0031] S102, obtaining the user information logged in before the user opens the webpage;
[0032] S103, monitoring whether the document object model (DOM) element is changed and binding a processing function; the processing function is used to detect whether the watermark element is changed by monitoring the style of the watermark element, and obtain the information of the opened webpage and the user information, and restore the state of the watermark element;
[0033] S104, if no change occurs, the processing function is not triggered; if a change occurs, the processing function checks whether the watermark element is changed;
[0034] S105, if the watermark element is changed, the watermark element is restored by the saved style of the watermark element, and a watermark element change message and user information causing the watermark element change are sent to the backend server.
[0035] The webpage includes HTML, CSS and JavaScript.
[0036] In an embodiment of the present application, the user information is real-name registered information or company internal account information.
[0037] In an embodiment of the present application, the method further includes that the backend server sends the watermark element change message and the user information causing the watermark element change to the person in charge.
[0038] In an embodiment of the present application, the sending of the watermark element change message and the user information causing the watermark element change to the backend server specifically includes that the processing function encrypts the watermark element change message and the user information causing the watermark element change and sends them to the backend server as a normal request, and the backend server parses the request to obtain the watermark change message and the user information causing the watermark element change.
[0039] In an embodiment of the present application, the method further includes that when network disconnection occurs, the parsing request fails, the parsing request is saved, and the parsing request is reinitiated after the network recovers.
[0040] In an embodiment of the present application, the generation of the watermark element on the opened webpage and the saving of the style of the watermark element specifically include that a canvas object of JavaScript is used to generate a picture of the watermark element, a unique id value is set for the watermark element, and the style of the current watermark element is saved in a background database, and the style is written on an inline in the form of the highest priority.
[0041] In an embodiment of the present application, the watermark element change is that the watermark element is deleted or the style of the watermark element is modified; and the style of the watermark element is modified as the id and / or inline of the watermark element are changed.
[0042] In an embodiment of the present application, the listening to whether the Document Object Model (DOM) element is changed specifically includes that a MutationObserver of JavaScript is used to listen to the Document Object Model (DOM) element.
[0043] The change refers to a change in a property of a Document Object Model (DOM) element, a change in a text node, or a combination of one or more of adding or deleting a child element.
[0044] In an embodiment of the present application, the method further comprises: if the JavaScript is disabled before the webpage is loaded, not loading the content on the webpage.
[0045] The MutationObserver is initialized before the content on the webpage is loaded, and the MutationObserver will normally run if the JavaScript is disabled after the content on the webpage is loaded.
[0046] If the memory is cleared, the content on the webpage is cleared.
[0047] An embodiment of the present application provides a computer readable storage medium, which stores a computer program, and the computer program is executed by a processor to implement the steps of the method for restoring a webpage watermark provided by an embodiment of the present application.
[0048] Figure 2 A specific structure block diagram of a computer device provided by an embodiment of the present application is shown, and the computer device 100 comprises one or more processors 101, a memory 102, and one or more computer programs, wherein the processor 101 and the memory 102 are connected through a bus, the one or more computer programs are stored in the memory 102 and are configured to be executed by the one or more processors 101, and the processor 101 executes the computer program to implement the steps of the method for restoring a webpage watermark provided by an embodiment of the present application.
[0049] The computer device comprises a server and a terminal, etc. The computer device can be a desktop computer, a mobile terminal, or a vehicle-mounted device, and the mobile terminal comprises at least one of a mobile phone, a tablet computer, a personal digital assistant, or a wearable device, etc.
[0050] In an embodiment of the present application, the document object model (DOM) element is listened to by a mutation observer of JavaScript to determine whether the element is changed, and if the element is changed, a processing function is triggered, the listening performance is improved, and the defects of a traditional polling method are avoided. Meanwhile, through a user real name level, the real identity of a user who changes an element watermark is traced.
[0051] Those skilled in the art can understand that all or part of the steps of various methods in the above embodiments can be completed by a program instructing relevant hardware, and the program can be stored in a computer readable storage medium, which can include Read Only Memory (ROM), Random Access Memory (RAM), a magnetic disk or an optical disk, etc.
[0052] The above description is merely the preferred embodiments of the present application, and is not intended to limit the present application. Any modification, equivalent replacement and improvement made within the spirit and principle of the present application shall fall within the scope of protection of the present application.
Claims
1. A method of reducing a watermark of a web page, characterized by, The method comprises the following steps: generating a watermark element on an opened webpage and saving the style of the watermark element, wherein the style of the watermark element comprises an id and an inline of the watermark element; obtaining user information logged in by a user before opening the webpage; binding a processing function by monitoring whether a Document Object Model (DOM) element is changed; the processing function is used to detect whether the watermark element is changed by monitoring the style of the watermark element, and obtain the opened webpage information and the user information, and restore the state of the watermark element; if no change occurs, the processing function is not triggered; if a change occurs, the processing function is triggered to check whether the watermark element is changed; if the watermark element is changed, the watermark element is restored by using the saved style of the watermark element, and a watermark element change message and user information causing the change of the watermark element are sent to a backend server.
2. The method of claim 1, wherein, The user information is real-name registered information or company internal account information. The method further comprises: the backend server sends the watermark element change message and the user information causing the change of the watermark element to a person in charge.
3. The method of claim 1, wherein, The sending of the watermark element change message and the user information causing the change of the watermark element to the backend server specifically comprises: the processing function encrypts and disguises the watermark element change message and the user information causing the change of the watermark element as a normal request and sends the request to the backend server, and the backend server parses the request to obtain the watermark change message and the user information causing the change of the watermark element.
4. The method of claim 3, wherein, The method further comprises: when a network disconnection occurs, the parsing request fails, the parsing request is saved, and the parsing request is reinitiated after the network is restored.
5. The method of claim 1, wherein, The generating of the watermark element on the opened webpage and the saving of the style of the watermark element specifically comprise: a picture of the watermark element is generated by using a canvas object of JavaScript, a unique id value is set for the watermark element, and the style of the current watermark element is saved in a background database, wherein the style is written in an inline in a form of a highest priority.
6. The method of claim 1, wherein, The change of the watermark element is that the watermark element is deleted or the style of the watermark element is modified; and the modification of the style of the watermark element is that the id and / or the inline of the watermark element are changed.
7. The method of claim 5, wherein, The monitoring of whether the DOM element is changed specifically comprises: the monitoring of whether the DOM element is changed is performed by using a MutationObserver of JavaScript. The change refers to one or a combination of the following situations: a characteristic of the DOM element is changed, a text node is changed, or a sub-element is added or deleted.
8. The method of claim 1, wherein, The method further comprises: if JavaScript is disabled before a webpage is loaded, contents on the webpage are not loaded. The MutationObserver is initialized before the contents on the webpage are loaded, and the MutationObserver normally operates if JavaScript is disabled after the contents on the webpage are loaded. If memory is cleared, the contents on the webpage are cleared.
9. A computer-readable storage medium storing a computer program, the computer program comprising instructions that, when executed by a computer, cause the computer to perform the method of any one of claims 1 to 8. The computer program is executed by a processor to implement the steps of the method for restoring the watermark of the webpage according to any one of claims 1 to 8.
10. A computer device comprising: One or more processors, a memory, and one or more computer programs, the processors and the memory being connected by a bus, wherein the one or more computer programs are stored in the memory and configured to be executed by the one or more processors, characterized in that the processors implement the steps of the method of restoring a web page watermark according to any one of claims 1 to 8 when executing the computer programs.
Citation Information
Patent Citations
Page data acquisition method and device, equipment and computer readable storage medium
CN111046317A
Webpage display method and device, equipment and storage medium
CN113704656A