2024-07-29 21:27:01 +00:00
|
|
|
// ==UserScript==
|
|
|
|
// @name The Old New Thing link unfucker
|
2024-07-29 21:58:00 +00:00
|
|
|
// @version 3
|
2024-07-29 21:27:01 +00:00
|
|
|
// @grant none
|
|
|
|
// @match https://devblogs.microsoft.com/oldnewthing/*
|
|
|
|
// ==/UserScript==
|
|
|
|
const rewriteRules = [
|
2024-07-29 21:58:00 +00:00
|
|
|
[/^http:\/\/blogs.msdn.com(\/b)?\/oldnewthing\/archive\/([0-9]{4})\/([0-9]{2})\/([0-9]{2})\/[0-9]+.aspx(#.*)?$/,
|
|
|
|
'https://devblogs.microsoft.com/oldnewthing/$2$3$4-00/'],
|
2024-07-29 21:38:10 +00:00
|
|
|
[/^https:\/\/blogs.msdn.microsoft.com\//,
|
|
|
|
'https://devblogs.microsoft.com/'],
|
2024-07-29 21:27:01 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
for (const link of document.getElementsByTagName('a')) {
|
|
|
|
let target = link.href;
|
|
|
|
if (target === '') {
|
|
|
|
continue;
|
|
|
|
}
|
2024-07-29 21:39:18 +00:00
|
|
|
for (const [regex, replacement] of rewriteRules) {
|
2024-07-29 21:27:01 +00:00
|
|
|
target = target.replace(regex, replacement);
|
|
|
|
}
|
|
|
|
if (target !== link.href) {
|
|
|
|
link.href = target;
|
|
|
|
link.parentNode.insertBefore(document.createTextNode('𝌡'), link.nextSibling);
|
|
|
|
}
|
|
|
|
}
|