Last active
March 25, 2024 13:13
-
-
Save 0x04/b581e5900df36adfbc08aad29790228c to your computer and use it in GitHub Desktop.
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 HTMLElement | |
*/ | |
let current = $0 | |
do { | |
if (current.hasAttribute('id')) { | |
break | |
} | |
} | |
while (current = current.parentElement) | |
console.log(current); |
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
// sort gog whishlist | |
var rowsParent = $('.account__products--wishlist:not(.ng-hide)') | |
var rowsSorted = [...rowsParent.querySelectorAll('.product-row-wrapper')] | |
var getDiscount = row => parseFloat(row.querySelector('.price-text--discount').textContent) | |
var getPrice = row => parseFloat(row.querySelector('.product-state__price').textContent) | |
var applySort = (getFn, direction = 1) => { | |
rowsSorted.sort((a, b) => (getFn(b) - getFn(a)) * direction) | |
for (var i = 0, l = rowsSorted.length; i < l; i++) { | |
rowsParent.appendChild(rowsSorted[i]) | |
} | |
} | |
// applySort(getDiscount) | |
applySort(getPrice, -1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment