Planetemu.net - Show ROM ID at links to ROM pages

Parses all links and shows ROM ID before the link text, for all links to ROM description pages.

  1. // ==UserScript==
  2. // @name Planetemu.net - Show ROM ID at links to ROM pages
  3. // @author Denilson Sá
  4. // @namespace http://denilson.sa.nom.br/
  5. // @version 1.1
  6. // @description Parses all links and shows ROM ID before the link text, for all links to ROM description pages.
  7. // @grant none
  8. // @license Public domain
  9. // @include http://www.planetemu.net/*
  10. // @include http://planetemu.net/*
  11. // @include https://www.planetemu.net/*
  12. // @include https://planetemu.net/*
  13. // ==/UserScript==
  14.  
  15. Array.prototype.forEach.call(
  16. document.getElementsByTagName('a'),
  17. function (link) {
  18. if (link.textContent.trim() != '') {
  19. var url = link.getAttribute('href');
  20. var match = url.match(/action=showrom&id=([0-9]+)/);
  21. if (match) {
  22. var text = document.createTextNode('[' + match[1] + '] ');
  23. link.parentNode.insertBefore(text, link);
  24. }
  25. }
  26. }
  27. );