Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

170
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda