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:

Any guidance is greatly appreciated!