So it's been a minute since I've used Greasemonkey scripts and I'm probably forgetting to do something basic but...
What I want to do is when ever I navigate to https://beta.crunchyroll.com to instead redirect me to https://beta.crunchyroll.com/simulcasts/seasons/spring-2021 and I think my current code should do that but isn't for some reason.
// ==UserScript==
// @name Crunchyroll Redirect
// @version 1
// @grant none
// @include http://*.crunchyroll.*/*
// @include https://*.crunchyroll.*/*
// ==/UserScript==
var current_location = content.document.location;
if(current_location == "https://beta.crunchyroll.com"){
window.location.replace("https://beta.crunchyroll.com/simulcasts/seasons/spring-2021")
}
So where did I mess up?
You can simplify the logic.
https://beta.crunchyroll.com
, there is no point on running it on other pages@match
is more robust than @include
@run-at
to run at the earliest possibleHere is an example:
// ==UserScript==
// @name Crunchyroll Redirect
// @match *://beta.crunchyroll.com/*
// @version 1
// @grant none
// @run-at document-start
// ==/UserScript==
window.stop(); // stop loading
location.replace('https://beta.crunchyroll.com/simulcasts/seasons/spring-2021');