About
林德熙 - 微软最具价值专家和 .NET 基金会成员
德熙的其它内容平台
德熙的博客偶尔加载比较慢,以下油猴脚本可以将 https://blog.lindexi.com/post/
自动重定向到本站点
// ==UserScript==// @name lindexi blog redirect// @namespace blog.lindexi.com// @version 2024-11-06// @description add redirect to backup blog// @author You// @match *blog.lindexi.com/post/*// @icon https://www.google.com/s2/favicons?sz=64&domain=lindexi.com// @grant none// @run-at document-start// ==/UserScript==
(async function () { "use strict";
const oldUrlPrefix = "https://blog.lindexi.com/post/"; const newUrlPrefix = "https://lindexi-blog.jgrass.cc/posts/";
if (location.href.startsWith(oldUrlPrefix)) { let newUrl = location.href.replace(oldUrlPrefix, newUrlPrefix);
// Remove the .html extension if present if (newUrl.endsWith(".html")) { newUrl = newUrl.substring(0, newUrl.length - 5); }
// Check if the new URL is valid try { const response = await fetch(newUrl, { method: "HEAD" }); if (response.ok) { // If response is OK (200-299), redirect location.href = newUrl; } else { // Handle 404 or other errors if needed console.error(`Redirect URL Fail ${newUrl}`); console.error("Redirect URL returned an error:", response.status); } } catch (error) { console.error("Error fetching the new URL:", error); } }})();
站点使用 AstroPaper 搭建,部署在 vercel 上