CN114780881A - Method and device for labeling text content of browser and electronic equipment - Google Patents

Method and device for labeling text content of browser and electronic equipment Download PDF

Info

Publication number
CN114780881A
CN114780881A CN202210200478.3A CN202210200478A CN114780881A CN 114780881 A CN114780881 A CN 114780881A CN 202210200478 A CN202210200478 A CN 202210200478A CN 114780881 A CN114780881 A CN 114780881A
Authority
CN
China
Prior art keywords
text
node
browser
display effect
preset display
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202210200478.3A
Other languages
Chinese (zh)
Inventor
吴迪
万振华
王颉
李华
董燕
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Seczone Technology Co Ltd
Original Assignee
Seczone Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Seczone Technology Co Ltd filed Critical Seczone Technology Co Ltd
Priority to CN202210200478.3A priority Critical patent/CN114780881A/en
Publication of CN114780881A publication Critical patent/CN114780881A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/90Details of database functions independent of the retrieved data types
    • G06F16/95Retrieval from the web
    • G06F16/957Browsing optimisation, e.g. caching or content distillation
    • G06F16/9577Optimising the visualization of content, e.g. distillation of HTML documents

Landscapes

  • Engineering & Computer Science (AREA)
  • Databases & Information Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Data Mining & Analysis (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The invention discloses a method for labeling text contents of a browser, which comprises the following steps: acquiring text selection area information selected by a user; separating elements are carried out on text region selection information, and node nodes in the text region selection information are obtained; finding a head node and a tail node in the node nodes, traversing the DOM tree, and finding all intermediate text nodes between the head node and the tail node; adding a preset display effect to all the found node nodes, and replacing the original text region selection information; and storing the text selection area information added with the preset display effect. The invention also discloses a device for labeling the text content of the browser and electronic equipment. Compared with the prior art, the method and the device have the advantages that when a user browses text contents on the browser, the user can select a plurality of sections of characters, and the preset effect is still kept after the characters are refreshed and slid.

Description

Method and device for labeling text content of browser and electronic equipment
Technical Field
The invention relates to a browser page display browsing method, in particular to a method for labeling text contents of a browser.
Background
With the development of technology, the functions of the current web browser are more and more abundant, and the web browser is not only used for simply accessing a web page. Many people search for data on browsers and read documents. Most of the time, the user can slide the mouse to select the text to be copied, but only a certain text can be selected at the same time, and the selected text is lost before sliding again. Therefore, the existing browser text labeling has the following problems: different text contents cannot be selected more, the function of continuously highlighting a plurality of texts in a note is not available, and the selected text is lost after a page is refreshed or slid.
Therefore, a method and an apparatus for labeling text content of a browser are needed to solve the above problems.
Disclosure of Invention
The invention aims to provide a method, a device and electronic equipment for labeling text contents of a browser, which can select a plurality of sections of characters and still keep a preset effect after refreshing and sliding.
In order to achieve the above object, the present invention discloses a method for labeling text content of a browser, comprising: acquiring text selection area information selected by a user; separating elements are carried out on text region selection information, and node nodes in the text region selection information are obtained; finding a head node and a tail node in the node nodes, traversing a DOM tree, and finding all intermediate text nodes between the head node and the tail node; adding a preset display effect to all the found node nodes, and replacing the original text region selection information; and storing the text selection area information added with the preset display effect.
Preferably, "storing the selected text area information after adding the preset display effect" specifically stores the selected text area information after adding the preset display effect offline.
Specifically, the text selection area information after the preset display effect is added is stored in an offline mode through localStorage.
Preferably, the Selection API is used for obtaining the text Selection area information selected by the user; separating elements of the text selection information through the split text; applying a Dom label to all the found node nodes to add a preset display effect; replacing the original text selection area information with a replaceChild.
Preferably, the preset display effect is highlight display.
The invention also discloses a device for labeling the text content of the browser, which comprises a selection area acquisition unit, a node searching unit, a rendering display unit and a selection area storage unit, wherein the selection area acquisition unit is used for acquiring the text selection area information selected by a user; the node acquisition unit is used for carrying out separation elements on the text selection information to acquire node nodes in the text selection information; the node searching unit finds a head node and a tail node in the node nodes, traverses the DOM tree and finds all intermediate text nodes between the head node and the tail node; the rendering display unit is used for adding a preset display effect to all the found node nodes and replacing the original text selection information; and the selected area storage unit stores the text selected area information added with the preset display effect.
Preferably, the selected area storage unit stores the text selected area information added with the preset display effect in an off-line manner.
Specifically, the selected area storage unit stores the text selected area information to which the preset display effect is added in an off-line manner through localStorage.
Preferably, the Selection area obtaining unit obtains the text Selection area information selected by the user by using a Selection API; the node acquisition unit separates elements of the selected text information through the split text; and the rendering display unit applies a Dom label to all the found node nodes so as to add a preset display effect, and replaces the original text selection area information with the replaceChild. The invention adopts the browser plug-in and the API of the text to realize the preset effect display of the multi-section content of the browser network page, and can finely acquire each character selected by a user. Of course, the text selection area information under the dom can also be acquired by monitoring the dom.
Preferably, the preset display effect is highlight display.
The invention also discloses an electronic device, comprising: one or more processors; a memory; and one or more programs, wherein the one or more programs are stored in the memory and configured to be executed by one or more processors, the programs comprising instructions for performing the method of annotating browser text content as described above.
The invention also discloses a computer-readable storage medium comprising a computer program for use in conjunction with an electronic device having a memory, the computer program being executable by a processor to perform the method of annotating browser text content as described above.
Compared with the prior art, the method and the device have the advantages that when the user browses the browser page, after the user selects a plurality of text paragraphs or sentences on the page, the text information selected by the user can be marked by using special effects (preset display effects such as highlight), so that the user can mark handwriting on the browser, and the user can conveniently view article pages, novel pages and the like through the browser. Specifically, all node nodes (bytes or elements) in a text selection area selected by a user are obtained firstly, and then the DOM is traversed to render the preset effect on all the node nodes, so that the text selection area and the rendering have universality, can be compatible with browsers of various models, and are good in compatibility. On the other hand, after the text selection area is rendered and displayed, the rendered text information is stored, so that the selected text selection area still keeps the preset display effect after the webpage is refreshed and slid, and a plurality of text selection areas can be continuously selected, so that the plurality of text selection areas keep the preset display effect, and a user can carry out persistent storage labeling when browsing the text on the network page of the browser.
Moreover, the invention also realizes the preset effect display of the multi-section content of the browser network page by using the JS code and combining the browser plug-in and the API (Application Programming Interface) of the text, thereby further increasing the universality and the browser compatibility of the invention.
Drawings
FIG. 1 is a flow chart of a method of the present invention for annotating browser text content.
Fig. 2 is a flow chart of a method for labeling text contents of a browser in a preferred embodiment of the present invention.
Fig. 3 is a block diagram of the apparatus for labeling text contents in a browser according to the present invention.
FIG. 4 is a block diagram of an electronic device according to the present invention.
Detailed Description
In order to explain technical contents, structural features, and objects and effects of the present invention in detail, the following detailed description is given with reference to the accompanying drawings in conjunction with the embodiments.
Referring to fig. 1, the present invention discloses a method 100 for labeling text content of a browser, comprising the steps of: s11, obtaining the text selection area information selected by the user; s12, separating elements are carried out on the text region selection information to obtain node nodes in the text region selection information; s13 finding a head node and a tail node in the node nodes, traversing the DOM tree, and finding all intermediate text nodes between the head node and the tail node; s14, adding a preset display effect to all the found node nodes, and replacing the original text region selection information; s15 stores the selected region information of the text to which the preset display effect is added.
Preferably, step S15 specifically includes: the "storing the selected text area information after adding the preset display effect" is specifically storing the selected text area information after adding the preset display effect offline.
Referring to fig. 2, in step S11, text Selection information selected by the user is obtained using the Selection API.
Referring to fig. 2, in step S12, the text selection information is divided by split text.
Referring to fig. 2, in step S14, a Dom tag is applied to all the node nodes found to add a preset display effect, and the replaceChild is used to replace the original text selection information.
Referring to fig. 2, in step S15, the text selection information to which the preset display effect is added is stored offline by localStorage.
In this embodiment, the preset display effect is highlight display. That is, the highlighted Dom tag is applied to all the node nodes found in step S14. Of course, the preset display effect may also be other display effects, such as a flashing, font slanting, blackening, and other identification effects.
Referring to fig. 3, the present invention further discloses a device 200 for labeling text content of a browser, which includes a selection area obtaining unit 21, a node obtaining unit 22, a node searching unit 23, a rendering display unit 24, and a selection area storage unit 25, wherein the selection area obtaining unit 21 obtains text selection area information selected by a user; the node obtaining unit 22 performs a separation element on the text selection information to obtain a node in the text selection information; the node searching unit 23 finds a head node and a tail node in the node nodes, traverses the DOM tree, and finds all intermediate text nodes between the head node and the tail node; the rendering display unit 24 adds a preset display effect to all the found node nodes and replaces the original text region selection information; the selected area storage unit 25 stores the selected area information of the text to which the preset display effect is added.
Preferably, the selected area storage unit 25 stores the selected area information of the text with the preset display effect added in an off-line manner.
The selected area storage unit 25 stores the text selected area information to which the preset display effect is added in an offline manner through localStorage.
Wherein, the Selection obtaining unit 21 obtains the text Selection information selected by the user using the Selection API; the node acquisition unit 22 separates elements of the selected text information by split text; the rendering display unit 24 applies a Dom label to all the found node nodes to add a preset display effect, and replaces the original text selection area information with a replaceChild.
In this embodiment, the preset display effect is highlight display. That is, the rendering display unit 24 applies the highlighted Dom tag to all the node nodes found. Of course, the preset display effect may also be other display effects, such as a flashing, font slanting, blackening, and other identification effects.
Referring to fig. 4, the present invention also discloses an electronic device 300, including: one or more processors 31; a memory 32; and one or more programs 33, wherein the one or more programs 33 are stored in the memory 32 and configured to be executed by the one or more processors 31, the programs comprising instructions for performing the method of annotating browser text content as described above.
The invention also discloses a computer-readable storage medium comprising a computer program for use in conjunction with an electronic device having a memory, the computer program being executable by a processor to perform the method of annotating browser text content as described above.
The above disclosure is only for the purpose of illustrating the preferred embodiments of the present invention and is not to be construed as limiting the scope of the present invention, therefore, the present invention is not limited by the appended claims.

Claims (12)

1. A method for annotating textual content of a browser, comprising: the method comprises the following steps:
acquiring text selection area information selected by a user;
carrying out separation elements on the text selection information to obtain node nodes in the text selection information;
finding a head node and a tail node in the node nodes, traversing the DOM tree, and finding all intermediate text nodes between the head node and the tail node;
adding a preset display effect to all the found node nodes, and replacing the original text region selection information;
and storing the text selection area information added with the preset display effect.
2. The method of annotating textual content of a browser according to claim 1, wherein: the specific step of storing the text selection area information after the preset display effect is as follows: and storing the text selection area information added with the preset display effect in an off-line manner.
3. The method of annotating textual content of a browser according to claim 2, wherein: and offline storing the text selection area information added with the preset display effect through localStorage.
4. The method of annotating textual content of a browser according to claim 1, wherein: obtaining text Selection area information selected by a user by using a Selection API; separating elements of the text selection information through the split text; applying a Dom label to all the found node nodes to add a preset display effect; replacing the original text selection area information with a replaceChild.
5. The method of annotating textual content of a browser according to claim 1, wherein: the preset display effect is highlight display.
6. An apparatus for annotating browser text content, comprising:
the selected area acquisition unit is used for acquiring the selected area information of the text selected by the user;
the node acquisition unit is used for carrying out separation elements on the text selection information to acquire node nodes in the text selection information;
the node searching unit finds a head node and a tail node in the node nodes, traverses a DOM tree and finds all intermediate text nodes between the head node and the tail node;
the rendering display unit is used for adding a preset display effect to all the found node nodes and replacing the original text selection information;
and the selected area storage unit stores the text selected area information added with the preset display effect.
7. The apparatus for labeling text content in a browser according to claim 6, wherein said selection area storage unit stores the information of the selected area of the text to which the predetermined display effect is added off-line.
8. The apparatus for annotating browser text content according to claim 7, wherein: and the selected area storage unit stores the text selected area information added with the preset display effect in an off-line manner through a localStorage.
9. The apparatus for annotating browser text content according to claim 6, wherein: the Selection area acquisition unit acquires text Selection area information selected by a user by using a Selection API; the node acquisition unit separates elements of the selected text information through the split text; and the rendering display unit applies a Dom label to all the found node nodes to add a preset display effect, and replaces the original text selection area information with the replaceChild.
10. The apparatus for annotating browser text content according to claim 6, wherein: the preset display effect is highlight display.
11. An electronic device, characterized in that: the method comprises the following steps:
one or more processors;
a memory; and
one or more programs, wherein the one or more programs are stored in the memory and configured to be executed by one or more processors, the programs comprising instructions for performing the method of annotating browser text content according to any of claims 1-5.
12. A computer-readable storage medium comprising a computer program for use in conjunction with an electronic device having a memory, characterized in that: the computer program is executable by a processor to perform a method of annotating browser text content as claimed in any one of claims 1-5.
CN202210200478.3A 2022-03-01 2022-03-01 Method and device for labeling text content of browser and electronic equipment Pending CN114780881A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210200478.3A CN114780881A (en) 2022-03-01 2022-03-01 Method and device for labeling text content of browser and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210200478.3A CN114780881A (en) 2022-03-01 2022-03-01 Method and device for labeling text content of browser and electronic equipment

Publications (1)

Publication Number Publication Date
CN114780881A true CN114780881A (en) 2022-07-22

Family

ID=82422908

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210200478.3A Pending CN114780881A (en) 2022-03-01 2022-03-01 Method and device for labeling text content of browser and electronic equipment

Country Status (1)

Country Link
CN (1) CN114780881A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116522876A (en) * 2023-05-08 2023-08-01 北京中宏立达科技发展有限公司 Method and device for realizing PDF text labeling of webpages of fire fox browser

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116522876A (en) * 2023-05-08 2023-08-01 北京中宏立达科技发展有限公司 Method and device for realizing PDF text labeling of webpages of fire fox browser
CN116522876B (en) * 2023-05-08 2024-01-09 北京中宏立达科技发展有限公司 Method and device for realizing PDF text labeling of webpages of fire fox browser

Similar Documents

Publication Publication Date Title
CN110362370B (en) Webpage language switching method and device and terminal equipment
CN110083805B (en) Method and system for converting Word file into EPUB file
CN105677764B (en) Information extraction method and device
US20020059334A1 (en) Graphical data within documents
CN105446946B (en) Rearrangement method, system and the electronic reading terminal of format document
US10318646B2 (en) Generating a structured document guiding view
US20130185622A1 (en) Methods and systems for handling annotations and using calculation of addresses in tree-based structures
EP1868113A2 (en) Visualizing document annotations in the context of the source document
Cockburn et al. Issues of page representation and organisation in web browser's revisitation tools
CN105824830B (en) Method, client and equipment for displaying page
CN101271463A (en) Representation method and system of layout file logical structure information
CN109492177B (en) web page blocking method based on web page semantic structure
JP2012532395A (en) Selective content extraction
CN103166981A (en) Wireless webpage transcoding method and device
CN113515928B (en) Electronic text generation method, device, equipment and medium
CN104090869B (en) A kind of method and translation system for translating the network information
US20080282150A1 (en) Finding important elements in pages that have changed
CN103942211A (en) Text page recognition method and device
US20140325350A1 (en) Target area estimation apparatus, method and program
CN114780881A (en) Method and device for labeling text content of browser and electronic equipment
CN109558123B (en) Method for converting webpage into electronic book, electronic equipment and storage medium
CN114021042A (en) Webpage content extraction method and device, computer equipment and storage medium
CN112433995A (en) File format conversion method, system, computer equipment and storage medium
CN110390037B (en) Information classification method, device and equipment based on DOM tree and storage medium
CN107423271B (en) Document generation method and device

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination