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

177
Visualizações
How do I reorder google results after search? I want to create an extension that can reorder the results of a google search

I am trying to create an extention that can reorder google results if I search for something like "how to make a paper airplane". Right now I just want to be able to change 2 link's orders. For example my current code

var xpath = function(xpathToExecute){
  var result = [];
  var nodesSnapshot = document.evaluate(xpathToExecute, document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null );
  for ( var i=0 ; i < nodesSnapshot.snapshotLength; i++ ){
    result.push( nodesSnapshot.snapshotItem(i) );
  }
  return result;
}

var xps = xpath('//*[@id="rso"]/div')

finalDivs = []

for (var i = 0; i < xps.length; i += 1 ) {
    if (xps[i].className == 'g' || xps[i].className == 'hlcw0c') {
        finalDivs.push(xps[i])
    }
}

This allows me to obtain an object with all relevant div tags. I can then assign each div to a ranking by creating another object, but I am unsure how I can then reorder the search results based on these results. Is there a way to reinject the div order back into the webpage I am on? The code I am currently using is put into the sources tab like this:

Where code is being run

Any guidance is greatly appreciated!

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