Created
July 2, 2020 03:28
-
-
Save ayn/25c32feae3bb62b7ef0c8007c6afa646 to your computer and use it in GitHub Desktop.
sort turnip by prices desc on turnip exchange lol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var jq = document.createElement('script'); | |
jq.src = "https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"; | |
document.getElementsByTagName('head')[0].appendChild(jq); | |
// ... give time for script to load, then type (or see below for non wait option) | |
jQuery.noConflict(); | |
function sortUsingNestedText(parent, childSelector, keySelector) { | |
var items = parent.children(childSelector).sort(function(a, b) { | |
var vA = parseInt(jQuery(keySelector, a).text().substring(0, " Bells".length - 1)) | |
var vB = parseInt(jQuery(keySelector, b).text().substring(0, " Bells".length - 1)) | |
return (vA < vB) ? 1 : (vA > vB) ? -1 : 0; | |
}); | |
parent.append(items); | |
} | |
sortUsingNestedText(jQuery("div.grid.grid-flow-row.grid-cols-2.gap-8.justify-items-center.items-center.mb-4"), "div.note", "div div p") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment