Skip to content

Instantly share code, notes, and snippets.

@troyp
Last active July 8, 2023 12:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save troyp/af213761b4d205708b225be31b16c70c to your computer and use it in GitHub Desktop.
Save troyp/af213761b4d205708b225be31b16c70c to your computer and use it in GitHub Desktop.
javascript:(function()%7Blet%20table%20%3D%20document.querySelector(%22div%3Etable%22)%3B%0Alet%20list%20%3D%20document.createElement(%22ul%22)%3B%0Alet%20rows%20%3D%20%5B...table.rows%5D.slice(2)%3B%0Atable.parentElement.appendChild(list)%3B%0Arows.forEach(r%3D%3E%7B%0A%20%20%20%20let%20li%20%3D%20document.createElement(%22li%22)%3B%0A%20%20%20%20let%20name%20%3D%20r.cells%5B0%5D.textContent%3B%0A%20%20%20%20let%20rating%20%3D%20r.cells%5B1%5D.textContent%3B%0A%20%20%20%20let%20color%20%3D%20r.cells%5B0%5D.firstChild.style.color%3B%0A%20%20%20%20li.style.color%20%3D%20color%3B%0A%20%20%20%20li.innerText%20%3D%20%60%24%7Bname%7D%20%24%7Brating%7D%60%3B%0A%20%20%20%20list.appendChild(li)%3B%0A%7D)%3B%7D)()
javascript:(function()%7Bconst%20stars%20%3D%20%5B%0A%20%20%20%20%5B%22%22%2C%20%22%22%5D%2C%0A%20%20%20%20%5B%22%E2%98%85%E2%98%86%E2%98%86%E2%98%86%E2%98%86%22%2C%20%22%23cc0000%22%5D%2C%0A%20%20%20%20%5B%22%E2%98%85%E2%98%85%E2%98%86%E2%98%86%E2%98%86%22%2C%20%22%23ff7700%22%5D%2C%0A%20%20%20%20%5B%22%E2%98%85%E2%98%85%E2%98%85%E2%98%86%E2%98%86%22%2C%20%22%23e6ad00%22%5D%2C%0A%20%20%20%20%5B%22%E2%98%85%E2%98%85%E2%98%85%E2%98%85%E2%98%86%22%2C%20%22green%22%5D%2C%0A%20%20%20%20%5B%22%E2%98%85%E2%98%85%E2%98%85%E2%98%85%E2%98%85%22%2C%20%22blue%22%5D%2C%0A%5D%3B%0A%0Afunction%20ratingIndex(rating)%20%7B%0A%20%20%20%20const%20match%20%3D%20rating.match(%2F%5B%E2%98%85%E2%98%86%5D%2B%2F)%3F.%5B0%5D%3B%0A%20%20%20%20switch%20(match)%20%7B%0A%20%20%20%20%20%20%20%20case%20%22%E2%98%85%E2%98%86%E2%98%86%E2%98%86%E2%98%86%22%3A%20return%201%3B%20break%3B%0A%20%20%20%20%20%20%20%20case%20%22%E2%98%85%E2%98%85%E2%98%86%E2%98%86%E2%98%86%22%3A%20return%202%3B%20break%3B%0A%20%20%20%20%20%20%20%20case%20%22%E2%98%85%E2%98%85%E2%98%85%E2%98%86%E2%98%86%22%3A%20return%203%3B%20break%3B%0A%20%20%20%20%20%20%20%20case%20%22%E2%98%85%E2%98%85%E2%98%85%E2%98%85%E2%98%86%22%3A%20return%204%3B%20break%3B%0A%20%20%20%20%20%20%20%20case%20%22%E2%98%85%E2%98%85%E2%98%85%E2%98%85%E2%98%85%22%3A%20return%205%3B%20break%3B%0A%20%20%20%20%20%20%20%20default%3A%20return%200%3B%0A%20%20%20%20%7D%0A%7D%0A%0Alet%20table%20%3D%20document.getElementsByTagName(%22table%22)%5B0%5D%3B%0Alet%20rows%20%3D%20%5B...table.rows%5D.slice(2)%3B%0Aconst%20summary%20%3D%20document.createElement(%22table%22)%3B%0Asummary.id%20%3D%20%22summary-table%22%3B%0Atable.parentElement.appendChild(summary)%3B%0Aconst%20thead%20%3D%20document.createElement(%22thead%22)%3B%0Asummary.appendChild(thead)%3B%0Alet%20tr%20%3D%20document.createElement(%22tr%22)%3B%0Aconst%20RatingCell%20%3D%20document.createElement(%22th%22)%3B%0ARatingCell.textContent%20%3D%20%22Rating%22%3B%0Aconst%20FeatCell%20%3D%20document.createElement(%22th%22)%3B%0AFeatCell.textContent%20%3D%20%22Feats%22%3B%0Atr.appendChild(RatingCell)%3B%0Atr.appendChild(FeatCell)%3B%0Athead.appendChild(tr)%3B%0Aconst%20tbody%20%3D%20document.createElement(%22tbody%22)%3B%0Asummary.appendChild(tbody)%3B%0Alet%20i%3B%0Afor%20(i%20of%20%5B5%2C4%2C3%2C2%2C1%5D)%20%7B%0A%20%20%20%20let%20tr%20%3D%20document.createElement(%22tr%22)%3B%0A%20%20%20%20tr.style.color%20%3D%20stars%5Bi%5D%5B1%5D%3B%0A%20%20%20%20tbody.appendChild(tr)%3B%0A%20%20%20%20let%20th%20%3D%20document.createElement(%22th%22)%3B%0A%20%20%20%20th.textContent%20%3D%20stars%5Bi%5D%5B0%5D%3B%0A%20%20%20%20tbody.rows%5B5-i%5D.appendChild(th)%3B%0A%20%20%20%20let%20feats%20%3D%20document.createElement(%22th%22)%3B%0A%20%20%20%20tbody.rows%5B5-i%5D.appendChild(feats)%3B%0A%7D%0Arows.forEach(r%3D%3E%7B%0A%20%20%20%20let%20name%20%3D%20r.cells%5B0%5D.textContent%3B%0A%20%20%20%20let%20rating%20%3D%20ratingIndex(r.cells%5B1%5D.textContent)%3B%0A%20%20%20%20tbody.rows%5B5-rating%5D.children%5B1%5D.textContent%20%2B%3D%20%60%24%7Bname%7D%2C%20%60%3B%0A%7D)%3B%0A%5B...tbody.rows%5D.forEach(r%20%3D%3E%20r.children%5B1%5D.textContent%20%3D%20r.children%5B1%5D.textContent.replace(%2F%2C%20%24%2F%2C%20%22%22))%3B%7D)()%3B
@troyp
Copy link
Author

troyp commented Jul 8, 2023

The first one lists feats one per line with colour-coding. The order is the same as in the original table, so sort it before using bookmarklet.
The second one collects feats into a table by rating.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment