// ==UserScript== // @name The Battle Cats Fandom --> Miraheze // @namespace https://github.com/dinosw // @version 0.2 // @description Redirects The Battle Cats Fandom wiki to the new Miraheze wiki. // @author dinosw // @match https://battle-cats.fandom.com/wiki/* // @match *://*.fandom.com/* // @grant none // @downloadURL none // ==/UserScript== (function() { 'use strict'; // Function to check if a URL is a Battle Cats Fandom page function isFandomPage(url) { return url.startsWith("https://battle-cats.fandom.com/wiki/"); } // Modify link clicks to redirect instantly document.addEventListener('click', function(event) { let target = event.target; // Check if the clicked element is an anchor (link) if (target && target.tagName === 'A' && target.href) { const linkUrl = target.href; // If it's a Battle Cats Fandom page, redirect if (isFandomPage(linkUrl)) { event.preventDefault(); // Prevent the default action (open the link) // Extract the page name from the URL const pageName = linkUrl.replace("https://battle-cats.fandom.com/wiki/", ""); // Create the new Miraheze URL const newUrl = `https://battlecats.miraheze.org/wiki/${pageName}`; // Redirect to the new Miraheze URL window.location.href = newUrl; } } }); })();