// ==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/* // @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/"); } // Handle link clicks for immediate redirection document.addEventListener('click', function(event) { let target = event.target; // Check if the clicked element is a link (anchor tag) if (target && target.tagName === 'A' && target.href) { let linkUrl = target.href; // If it's a Battle Cats Fandom page, redirect immediately if (isFandomPage(linkUrl)) { event.preventDefault(); // Prevent the default action (opening the link) // Extract the page name from the Fandom 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 Miraheze page window.location.replace(newUrl); } } }); })();