// @name lindexi blog redirect
// @namespace blog.lindexi.com
// @description add redirect to backup blog
// @match *blog.lindexi.com/post/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=lindexi.com
// @run-at document-start
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
const response = await fetch(newUrl, { method: "HEAD" });
// If response is OK (200-299), redirect
// Handle 404 or other errors if needed
console.error(`Redirect URL Fail ${newUrl}`);
console.error("Redirect URL returned an error:", response.status);
console.error("Error fetching the new URL:", error);