Create a gist now

Instantly share code, notes, and snippets.

// ==UserScript==
// @name TitleFixer - RIPE Database
// @namespace https://github.com/jeni4/
// @version 1.1.0
// @description Change the title to something meaningful
// @author Jeni4
// @match https://apps.db.ripe.net/search/lookup.html?source=ripe&key=*-RIPE&type=person
// @match https://apps.db.ripe.net/search/lookup.html?source=ripe&key=*&type=mntner
// @match https://apps.db.ripe.net/search/lookup.html?source=ripe&key=ORG-*-RIPE&type=organisation
// @grant none
// @UpdateURL https://gist.githubusercontent.com/Jeni4/3854c56c6431c6df5a395b1fddc7d6c2/raw/f4e7f684579dd7847e7fbcd29f538b138e4d3b01/TitleFixer_RIPE_Database.user.js
/**
* v1.1.0 2017-03-14 Added types maintainer and organization
* v1.0.0 2017-03-14 Initial Commit
*/
// ==/UserScript==
(function() {
'use strict';
var type,title,identity,website;
identity = document.getElementById( 'results' );
website = document.getElementById( 'logo' ).getAttribute( 'alt' );
// Person
if (location.href.match( /search\/lookup\.html\?source=ripe\&key\=([A-Z]{2})([0-9]+)\-RIPE\&type=person/ )) {
type = 'PERSON';
title = location.href.match( /([A-Z]{2})([0-9]+)\-RIPE/i )[0];
identity = identity.querySelector( 'ul.attrblock > li:nth-child(1)' );
}
// Maintainer
else if (location.href.match( /search\/lookup\.html\?source=ripe\&key\=([a-z0-9]+)\-mnt\&type=mntner/ )) {
type = 'MAINTAINER';
title = location.href.match( /([a-z0-9]+)\-mnt/i )[0];
identity = identity.querySelector( 'ul.attrblock > li:nth-child(2)' );
}
// Oranization
else if (location.href.match( /search\/lookup\.html\?source=ripe\&key\=ORG\-([A-Z]{2})([0-9]+)\-RIPE\&type=organisation/ )) {
type = 'ORGANIZATION';
title = location.href.match( /ORG\-([A-Z]{2})([0-9]+)\-RIPE/i )[0];
identity = identity.querySelector( 'ul.attrblock > li:nth-child(2)' );
}
title = title.toUpperCase();
identity = identity.innerHTML.split(":")[1].trim();
document.title = title + ' - ' + identity + ' - ' + type + ' - ' + website;
console.log("Title tag splurged - TitleFixer - RIPE Database v1.1");
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment