Last active
January 7, 2025 08:16
-
-
Save 0x04/b581e5900df36adfbc08aad29790228c to your computer and use it in GitHub Desktop.
This file contains hidden or 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 hidden or 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
const wpmElement = document.querySelector('.group.wpm .bottom') | |
const cpm = wpmElement.innerText | |
const wpm = wpmElement.getAttribute('aria-label').match(/\d+(?:\.\d+)? wpm/)[0].replace(/\s+wpm$/, '') | |
const acc = document.querySelector('.group.acc .bottom').innerText | |
const time = document.querySelector('.group.time .bottom .text').innerText | |
const lang = document.querySelector('.group.testType .bottom').innerText.split(/\n/).pop() | |
const keys = document.querySelector('.group.key .bottom').innerText | |
const cons = document.querySelector('.group.consistency .bottom').innerText | |
const text = `cpm ${cpm}/wpm ${wpm} - acc ${acc} - time ${time}, ${lang} - characters ${keys} - consistency ${cons}` | |
// Print and copy | |
console.log(text) | |
copy(text) |
This file contains hidden or 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