alextzval / Corregir enlaces información centros https://appweb.edu.gva.es/

// ==UserScript==
// @name         Corregir enlaces información centros https://appweb.edu.gva.es/
// @namespace    CorregirEnlacesAppweb.edu.gva.es/
// @version      0.2
// @description  Corregir enlaces a centros en https://appweb.edu.gva.es/
// @license      GPL-3.0-or-later
// @license      MIT
// @author       You
// @match        https://appweb.edu.gva.es/*/*
// @grant        none
// ==/UserScript==

// ==OpenUserJS==
// @author alextzval
// ==/OpenUserJS==


(function() {
    "use strict";

    document.addEventListener('mousemove', seleccionaParrafos);

    function seleccionaParrafos() {
        var localidades = document.querySelectorAll('p.mesInfo');

        if(localidades.length>0) {
            for(var i=0; i<localidades.length; i++) {
                localidades[i].addEventListener('click', clickLocalidades);
            }
        }

        function clickLocalidades(e) {
            var url = this.querySelector('a').getAttribute('href').split('codi=')[1];
            console.log(url);
            url = 'http://www.ceice.gva.es/abc/i_guiadecentros/es/centro.asp?codi='+ url;

            this.querySelector('a').setAttribute('href', url);
            this.removeEventListener('click', clickLocalidades);
        }

    }
})();