Overview
To put it simply: just like in a real textbook with the mark pen coloring point, you can use this script on any page to paint the focus.
Development reason: Every time in the Internet to see the information, will silently summed up a few important places, but read the information to write a blog when it is easy to forget the focus, so I developed this script.
Script flaw: (1) cannot refresh the webpage, otherwise the mark is gone. (2) Only the same text can be marked, not hyperlinks, text, references, highlighting together, but can be marked separately.
Demonstrate
Script code
First, you need to install the oil Monkey (Tampermonkey) plugin on the browser. 360 browsers can be found in the extension center. Other Browser installation method please own Baidu.
Finally, open the oil monkey-----Add a new script and copy the code in.
//==userscript==//@name Mark on web//@namespace http://tampermonkey.net///@version 0.1//@d Escription try-to-take over the world!//@author you//@match https://developer.mozilla.org/*//@match http://*/*//@match https://*/*//@grant none//@copyright 2018+, yang-zhou//==/userscript== (function () {' Use strict '; var funcgetselecttext = function () {var txt = '; if (document.selection) {txt = Document.selection.createRange (). text;//ie}else{txt = documen T.getselection (); } return txt.tostring (); }; var container = Container | | Document Container.onmouseup = function () {var txt = funcgetselecttext (); if (TXT) {Event.target.innerHTML =event.target.innerhtml.replace (txt, ' <span style= "Backgroun D-color:yellow "> ' +txt+ ' </span> '); } };}) ();
Note : Make sure that the oil monkey plugin is turned on when you open the Web page, and that the script I wrote is enabled.
Web Effects Demo<textarea id="text_test" rows="10" cols="100"><! DOCTYPE html><ptml> <pead></pead> <body> <p> How to use: With the mouse to select text, the selected text will be automatically painted yellow </ P> <script> var funcgetselecttext = function () {var txt = '; if (document.selection) {txt = Document.selection.createRange (). text;//ie}else{txt = documen T.getselection (); } return txt.tostring (); }; var container = Container | | Document Container.onmouseup = function () {var txt = funcgetselecttext (); if (TXT) {Event.target.innerHTML =event.target.innerhtml.replace (txt, ' <span style= "Backgroun D-color:yellow "> ' +txt+ ' </span> '); }};</script></body></ptml></textarea>
Develop an oil monkey script: Paint the selected text for any page