Last active
May 22, 2019 01:37
-
-
Save jangins101/4ab460d7ca19918207ebd43e47a16624 to your computer and use it in GitHub Desktop.
TamperMonkey Script for F5 DevCentral
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name F5 DevCentral Relaunch Enhancements | |
// @version 0.3 | |
// @description Adds a lot of useful features to the GUI in order to make access to different configuration items quicker | |
// @homepage https://gist.github.com/jangins101/4ab460d7ca19918207ebd43e47a16624 | |
// @updateURL https://gist.github.com/jangins101/4ab460d7ca19918207ebd43e47a16624/raw | |
// @downloadURL https://gist.github.com/jangins101/4ab460d7ca19918207ebd43e47a16624/raw | |
// @match https://devcentral.f5.com/* | |
// @run-at document-end | |
// @require http://code.jquery.com/jquery-latest.js | |
// @author Michael Jenkins (@jangins101) | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
var interval, iMax = 10, i = 1; | |
var regex = /^https:\/\/devcentral.f5.com\/wiki\/(.*?)\.(.*?)\.ashx/; | |
// These are the known mappings for old wiki pages and the new api pages | |
var table = { | |
"iRules": "irules", | |
"iControl": "icontrol-soap", | |
"iControlREST": "icontrol-rest", | |
"iHealth": "ihealth", | |
"iApp": "iapps", | |
"iRulesLX": "irules-lx" | |
}; | |
//$(window).on('load', function() { | |
var isDebug = true; | |
function dLog(msg) { if (isDebug) { console.log(msg); } } | |
// Create an interval that runs every second (up to iMax iterations) | |
// This is because the site dynamically loads content after the page load completes | |
interval = setInterval(function(){ | |
// JQuery selector to grab all A elements whose href starts with the url | |
var links = $('a[href^="https://devcentral.f5.com/wiki"]'); | |
dLog(" Count: " + links.length); | |
// Once we find links on the page that match (or hit the max # of iterations) clear the interval | |
if (links.length > 0 || i > iMax) { clearInterval(interval); } else { i++; } | |
links.each(function() { | |
debugger; | |
dLog(" Link: " + this.href); | |
// Update href attribute (if match found and table includes the match item category) | |
var m = this.href.match(regex); | |
if (m && table[m[1]]) { | |
this.href = "https://clouddocs.f5.com/api/" + table[m[1]] + "/" + m[2] + ".html"; | |
dLog(" >> " + this.href); | |
} | |
// Update the link text if its value is the URL | |
if (this.innerText.match(regex)) { this.innerText = this.href; } | |
}); | |
}, 1000); | |
//}); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment