-
-
Save jangins101/20fbe69cf792d57e343cd484b500ddc6 to your computer and use it in GitHub Desktop.
TamperMonkey Script for F5 DevCentral - Auto redirect old wiki URLs to new location
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 Wiki Redirect | |
// @version 0.2 | |
// @description Rewrite direct wiki requests | |
// @author Michael Jenkins (@jangins101) | |
// @homepage https://gist.github.com/jangins101/20fbe69cf792d57e343cd484b500ddc6 | |
// @updateURL https://gist.githubusercontent.com/jangins101/20fbe69cf792d57e343cd484b500ddc6/raw | |
// @downloadURL https://gist.githubusercontent.com/jangins101/20fbe69cf792d57e343cd484b500ddc6/raw | |
// @match https://devcentral.f5.com/wiki* | |
// @match https://devcentral.f5.com/Wiki* | |
// @match https://devcentral.f5.com/s/wiki* | |
// @match https://devcentral.f5.com/s/Wiki* | |
// @require http://code.jquery.com/jquery-latest.js | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
var isDebug = true; | |
function dLog(msg) { if (isDebug) { console.log(msg); } } | |
var regex = /^https:\/\/devcentral.f5.com\/(?:s\/)?wiki\/(.*?)\.(.*?)\.ashx/i; | |
var table = { | |
"iRules": "irules", | |
"iControl": "icontrol-soap", | |
"iControlREST": "icontrol-rest", | |
"iHealth": "ihealth", | |
"iApp": "iapps", | |
"iRulesLX": "irules-lx" | |
}; | |
if (isDebug) { debugger; } | |
var cUrl = document.location; | |
dLog("Original:" + cUrl); | |
var match = cUrl.href.match(regex); | |
if (match) { | |
dLog(console.log(match)); | |
if (table[match[1]]) { | |
dLog("Section: " + match[1] + " >> " + table[match[1]]); | |
var nUrl = "https://clouddocs.f5.com/api/" + table[match[1]] + "/" + match[2] + ".html"; | |
dLog(" Replace: " + nUrl); | |
location.replace(nUrl); | |
} | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment