Created
February 23, 2024 11:18
-
-
Save tewilove/fe203caae9046eb3b45551c7bee1bea4 to your computer and use it in GitHub Desktop.
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 Legacy QC link fixer | |
// @namespace http://tampermonkey.net/ | |
// @version 2024-02-23 | |
// @description Redirect invalid codeaurora URL to the codelinaro one. | |
// @author tewilove | |
// @match https://source.android.com/docs/security/bulletin/* | |
// @icon https://www.google.com/s2/favicons?sz=64&domain=tampermonkey.net | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
document.querySelectorAll('a[href]').forEach(function(link) { | |
var prefix = /https:\/\/source\.codeaurora\.org\/quic\//; | |
var url = link.href; | |
if (prefix.test(url)) { | |
// source.codeaurora.org/quic/ => git.codelinaro.org/clo/ | |
var newUrl = url.replace(prefix, 'https://git.codelinaro.org/clo/'); | |
// /commit/?id=xxx => /-/commit/xxx | |
newUrl = newUrl.replace(/\/commit\/\?id=/, '/-/commit/'); | |
link.href = newUrl; | |
} | |
}); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment