Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

171
Vistas
How do I get this bookmarklet to not highlight all of the same instances but only the one I have selected?

How do I get this bookmarklet to not highlight all of the same instances but only the one I have selected? If possible could you add another script or way to make it so you can unhighlight it by selecting the text again? I would prefer to just start out with my original problem.

javascript: (function() {
    var els, i, txt = "";
    if (window.getSelection) {
        txt = window.getSelection();
    } else if (document.getSelection) {
        txt = document.getSelection();
    } else if (document.selection) {
        txt = document.selection.createRange().text;
    } else {
        txt = "";
    }
    if (txt) {
        txt = txt.toString();
    }
    if (!txt || txt.length == 0) {
        els = document.querySelectorAll(".hiColor");
        i = els.length;
        while (i--) {
            els[i].style.backgroundColor = "";
            els[i].className = "";
        }
        return null;
    }

    function searchNode(node, te, len) {
        var pos, skip = 0,
            spannode, middlebit, endbit, middleclone;
        if (node.nodeType == 3) {
            pos = node.data.toUpperCase().indexOf(te);
            if (pos >= 0) {
                spannode = document.createElement("SPAN");
                spannode.className = "hiColor";
                middlebit = node.splitText(pos);
                endbit = middlebit.splitText(len);
                middleclone = middlebit.cloneNode(true);
                spannode.appendChild(middleclone);
                middlebit.parentNode.replaceChild(spannode, middlebit);
                skip = 1;
            }
        } else if (node.nodeType == 1 && node.childNodes && node.tagName.toUpperCase() != "SCRIPT" && node.tagName.toUpperCase != "STYLE") {
            for (var child = 0; child < node.childNodes.length; ++child) {
                child = child + searchNode(node.childNodes[child], te, len);
            }
        }
        return skip;
    }
    searchNode(document.body, txt.toUpperCase(), txt.length);
    els = document.querySelectorAll(".hiColor");
    if (els && els.length) {
        for (var i = 0; i < els.length; i++) {
            els[i].style.backgroundColor = "lime";
        }
    }
    return null;
})();

Images↓

What I want it to do What it Does do

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda