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.

目前為 2016-04-08 提交的版本,檢視 最新版本

// ==UserScript==
// @name         Planetemu.net - Show ROM ID at links to ROM pages
// @author       Denilson Sá 
// @namespace    http://denilson.sa.nom.br/
// @version      1.2
// @description  Parses all links and shows ROM ID before the link text, for all links to ROM description pages.
// @grant        none
// @license      Public domain
// @include http://www.planetemu.net/*
// @include http://planetemu.net/*
// @include https://www.planetemu.net/*
// @include https://planetemu.net/*
// ==/UserScript==

(function() {
    Array.prototype.forEach.call(
        document.getElementsByTagName('a'),
        function (link) {
            if (link.textContent.trim() != '') {
                var url = link.getAttribute('href');
                var match = url.match(/action=showrom&id=([0-9]+)/);
                if (match) {
                    var text = document.createTextNode('[' + match[1] + '] ');
                    link.parentNode.insertBefore(text, link);
                }
            }
        }
    );
})();