Greasy Fork is available in English.

GGn Row Numbers in User Log

Add row numbers to the user log

  1. // ==UserScript==
  2. // @name GGn Row Numbers in User Log
  3. // @namespace none
  4. // @version 2
  5. // @description Add row numbers to the user log
  6. // @author ingts
  7. // @match https://gazellegames.net/user.php?*action=userlog*
  8. // ==/UserScript==
  9. const table = document.querySelector('#content > div > table')
  10. const tbody = table.querySelector('tbody')
  11. const page = new URL(location.href).searchParams.get('page')
  12. const startIndex = page ? (page - 1) * 50 : 0
  13. tbody.firstElementChild.insertAdjacentHTML('afterbegin', `<td style="width: 1px;"><strong>#</strong></td>`)
  14.  
  15. function number(tr) {
  16. tr.insertAdjacentHTML('afterbegin', `<td class="nobr"><span>${tr.rowIndex + startIndex}</span></td>`)
  17. }
  18.  
  19. tbody.querySelectorAll('tr:not(.colhead)').forEach(tr => {
  20. number(tr)
  21. })
  22.  
  23. new MutationObserver(mutations => {
  24. mutations.forEach(m => {
  25. number(m.addedNodes[0])
  26. })
  27. }).observe(table, {childList: true})