Skip to content

Instantly share code, notes, and snippets.

@netravnen
Last active June 18, 2017 10:58
Show Gist options
  • Save netravnen/9afd246d8ec8d452d8930f56ebb5a3db to your computer and use it in GitHub Desktop.
Save netravnen/9afd246d8ec8d452d8930f56ebb5a3db to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name TitleFixer - Peeringdb.com
// @namespace https://github.com/netravnen/TitleFixer-PDB
// @version 0.1.1
// @description netravnen
// @author netravnen
// @match https://www.peeringdb.com/asn/*
// @match https://www.peeringdb.com/org/*
// @match https://www.peeringdb.com/ix/*
// @grant none
// @UpdateURL https://gist.github.com/netravnen/9afd246d8ec8d452d8930f56ebb5a3db/raw/f2deac6b491db7108b59c925b7e4b001fa4787ae/TitleFixer-Peeringdb-com.user.js
// ==/UserScript==
(function() {
'use strict';
var type,title,website,asnNumber,orgName,orgCountryCode,ixName,ixCountryCode;
website = document.querySelector( 'title' ).innerHTML;
// Asn
if (location.href.match( /asn\/([0-9]+)/ )) {
asnNumber = location.href.match( /([0-9]+)/i )[0];
type = 'asn';
title = type.toUpperCase() + asnNumber;
}
// Org
else if (location.href.match( /org\/([0-9]+)/ )) {
orgName = document.querySelector( '#view > div:nth-child(4) > div > div > div.col-md-8.col-sm-8.col-xs-10' ).innerHTML;
orgCountryCode = document.querySelector( '#view > div:nth-child(5) > div.col-md-6.col-sm-6.col-xs-12.view-left > div > div:nth-child(5) > div.view_value.col-xs-8.col-sm-7.col-md-8' ).innerHTML;
type = 'org';
title = orgName + ' | ' + orgCountryCode;
}
// Ix
else if (location.href.match( /ix\/([0-9]+)/ )) {
ixName = document.querySelector( '#view > div:nth-child(4) > div > div > div.col-md-8.col-sm-8.col-xs-10' ).innerHTML;
ixCountryCode = document.querySelector( '#view > div:nth-child(5) > div.col-md-6.col-sm-6.col-xs-12.view-left > div.view_fields > div:nth-child(4) > div.view_value.col-xs-8.col-sm-7.col-md-8' ).innerHTML;
type = 'ix';
title = ixName + ' | ' + ixCountryCode;
}
title = title.toUpperCase();
document.title = title + ' | ' + 'Type: ' + type.toUpperCase() + ' | ' + website;
console.log("Title tag splurged - TitleFixer - Peeringdb.com v0.1");
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment