Override browser "Find" feature

Not without the help of a browser-specific extension I think, if at all. This is a process that is entirely outside the JavaScript context.


To disable the effect pf the find feature, you can use this Jquery Plugin.

It can also be done with plain JavaScript, as follows:

        function disableFind() {
            var all = document.getElementsByTagName("*");
            var end = false;
            for(let idx in all){
                let currentElement = all[idx];
                let html = currentElement.innerHTML;
                if(!html) continue;
                let newHTML = "";
                for(var i = 0; i < html.length; i++) {
                    newHTML += html[i];
                    if (html[i] == '<') end = true;
                    if (html[i] == '>') end = false ;
                    if (end == false) {
                        newHTML += '<span style="position:absolute; left:-9999px;">.</span>';
                    }
                    if (html[i] == ' ') newHTML += ' ';   // insert a space if the current character is a space
                }
                currentElement.innerHTML = newHTML;
            }


        }

Additionally, you can prevent the default behavior of CTRL/CMD+F, with the following code:

 window.addEventListener("keydown", function(e){
     if(e.which == 70 && (e.ctrlKey || e.metaKey)) e.preventDefault(); 
  });