Disclosure of Invention
The application aims to provide a method for restoring a webpage watermark, a computer readable storage medium and computer equipment, and aims to solve the problem that a tracing means of a user for changing the webpage watermark is lacked.
In a first aspect, the present application provides a method for restoring a watermark of a web page, including:
generating watermark elements on the opened webpage, and storing the patterns of the watermark elements;
acquiring user information logged in by a user before opening a webpage;
monitoring whether a Document Object Model (DOM) element changes or not, and binding a processing function; the processing function is used for detecting whether the watermark elements are changed or not by monitoring the patterns of the watermark elements, obtaining opened webpage information and user information and recovering the states of the watermark elements;
if no change occurs, the processing function is not triggered; if the watermark elements are changed, triggering a processing function to check whether the watermark elements are changed;
if the watermark element is changed, the watermark element is restored through the stored style of the watermark element, and a watermark element change message and user information causing the watermark element change are sent to the back-end server.
Further, the user information is information registered in real name or information of account number inside the company.
Further, the method further comprises: and the back-end server sends the watermark element change message and the user information causing the watermark element change to a responsible person.
Further, the sending the watermark element change message and the user information causing the watermark element change to the backend server specifically includes: the processing function encrypts and disguises the watermark element change message and the user information causing the watermark element change into a common request to be sent to the back-end server, and the back-end server analyzes the request to obtain the watermark element change message and the user information causing the watermark element change.
Further, the method further comprises: when the network is disconnected and the analysis request fails, the analysis request is stored, and the analysis request is reinitiated after the network is recovered.
Further, the generating of the watermark element on the opened webpage and the storing of the style of the watermark element specifically include: generating a picture of the watermark element by using a JavaScript canvas object, setting a unique id value for the watermark element, and storing the style of the current watermark element in a background database, wherein the style is written on an inner link in a form of highest priority.
Further, the watermark element is changed by deleting the watermark element or modifying the style of the watermark element; the pattern of the watermark element is modified such that the id and/or the inline of the watermark element is changed.
Further, the monitoring whether the DOM element of the document object model changes specifically includes: monitoring a Document Object Model (DOM) element through a variable observer MutationObserver of JavaScript;
the change is that: the characteristics of the DOM elements of the document object model are changed, or the nodes of the text are changed, or one or a plurality of combinations of the sub-elements are added or deleted.
Further, the method further comprises: if the JavaScript is forbidden before the webpage is loaded, the content on the webpage is not loaded;
the variable observer multimedia observer is initialized before the content on the webpage is loaded out, and if the JavaScript is forbidden after the content on the webpage is loaded out, the variable observer multimedia observer will normally run;
and if the memory is cleared, clearing the content on the webpage.
In a second aspect, the present application provides a computer-readable storage medium storing a computer program, which when executed by a processor implements the steps of the method for restoring a watermark of a web page.
In a third aspect, the present application provides 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, which when executing the computer programs implement the steps of the method of restoring a watermark of a web page.
In the method, whether a DOM element of a document object model is changed or not is monitored through a JavaScript change observer, if the DOM element is changed, a processing function is triggered, the monitoring performance is improved, and the defects of a traditional polling method are avoided; and simultaneously, tracing the real identity of the user with the element watermark change through the real name grade of the user.
Detailed Description
In order to make the purpose, technical solution and beneficial effects of the present application more clear and more obvious, 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 merely illustrative of the present application and are not intended to limit the present application.
In order to explain the technical solution described in the present application, the following description will be given by way of specific examples.
Referring to fig. 1, a method for restoring a web watermark according to an embodiment of the present application includes the following steps: it should be noted that, if the result is substantially the same, the method for restoring the web page watermark is not limited to the flow sequence shown in fig. 1.
S101, generating watermark elements on an opened webpage, and storing the patterns of the watermark elements;
s102, obtaining user information logged in by a user before the user opens a webpage;
s103, monitoring whether a Document Object Model (DOM) element changes or not, and binding a processing function; the processing function is used for detecting whether the watermark elements are changed or not by monitoring the patterns of the watermark elements, obtaining opened webpage information and user information and recovering the states of the watermark elements;
s104, if the change does not occur, the processing function is not triggered; if the watermark element is changed, triggering a processing function to check whether the watermark element is changed;
and S105, if the watermark elements are changed, restoring the watermark elements according to the stored watermark element patterns, and sending watermark element change information and user information causing the watermark element change to a back-end server.
The web page includes HTML, CSS, and JavaScript.
In an embodiment of the present application, the user information is information registered in a real name or information about an internal account of a company.
In an embodiment of the present application, the method further includes: and the back-end server sends the watermark element change message and the user information causing the watermark element change to a responsible person.
In an embodiment of the present application, the sending the watermark element change message and the user information causing the watermark element change to the backend server specifically includes: the processing function encrypts and disguises the watermark element change message and the user information causing the watermark element change into a common request to be sent to the back-end server, and the back-end server analyzes the request to obtain the watermark element change message and the user information causing the watermark element change.
In an embodiment of the present application, the method further includes: when the network is disconnected and the analysis request fails, the analysis request is stored, and the analysis request is reinitiated after the network is recovered.
In an embodiment of the present application, the generating a watermark element on an open web page and storing a style of the watermark element specifically includes: generating a picture of the watermark element by using a JavaScript canvas object, setting a unique id value for the watermark element, and storing the style of the current watermark element in a background database, wherein the style is written on an inner link in a form of highest priority.
In an embodiment of the present application, the watermark element change is that the watermark element is deleted or that the pattern of the watermark element is modified; the pattern of the watermark element is modified such that the id and/or the inline of the watermark element is changed.
In an embodiment of the present application, the monitoring whether a document object model DOM element changes specifically includes: monitoring a Document Object Model (DOM) element through a variable observer MutationObserver of JavaScript;
the change is that: the characteristics of the DOM elements of the document object model change, or the text nodes change, or one or a combination of several of the sub-elements are added or deleted.
In an embodiment of the present application, the method further includes: if the JavaScript is forbidden before the webpage is loaded, the content on the webpage is not loaded;
the variable observer multimedia observer is initialized before the content on the webpage is loaded out, and if the JavaScript is forbidden after the content on the webpage is loaded out, the variable observer multimedia observer will normally run;
and if the memory is cleared, clearing the content on the webpage.
An embodiment of the present application provides a computer-readable storage medium, which stores a computer program, and when the computer program is executed by a processor, the computer program implements the steps of the method for restoring a watermark of a web page provided in an embodiment of the present application.
Fig. 2 shows a specific block diagram of a computer device provided in an embodiment of the present application, where the computer device 100 includes: one or more processors 101, a memory 102, and one or more computer programs, wherein the processors 101 and the memory 102 are connected by a bus, the one or more computer programs are stored in the memory 102 and configured to be executed by the one or more processors 101, and the processor 101 implements the steps of the method of restoring a web page watermark as provided by an embodiment of the present application when executing the computer programs.
The computer equipment comprises a server, a terminal and the like. The computer device may be a desktop computer, a mobile terminal or a vehicle-mounted device, and the mobile terminal includes at least one of a mobile phone, a tablet computer, a personal digital assistant or a wearable device.
In the embodiment of the application, whether a DOM element of a document object model is changed or not is monitored through a JavaScript change observer, and if the DOM element is changed, a processing function is triggered, so that the monitoring performance is improved, and the defects of the traditional polling method are overcome; and simultaneously, tracing the real identity of the user with the element watermark changed through the real name grade of the user.
Those skilled in the art will appreciate that all or part of the steps in the methods of the above embodiments may be implemented by associated hardware instructed by a program, which may be stored in a computer-readable storage medium, and the storage medium may include: read Only Memory (ROM), Random Access Memory (RAM), magnetic or optical disks, and the like.
The above description is only exemplary of the present application and should not be taken as limiting the present application, as any modification, equivalent replacement, or improvement made within the spirit and principle of the present application should be included in the protection scope of the present application.