Javascript, Indented code |
---|
| const url = new URL(window.location);
if (url.hostname === "docs.djangoproject.com") {
let urlparts = url.href.split("/");
urlparts[3] = "en";
urlparts[4] = "stable";
window.location.assign(urlparts.join("/"));
}
|
Javascript, Bookmarklet |
---|
| javascript:(function()%7Bconst%20url%20%3D%20new%20URL(window.location)%3Bif%20(url.hostname%20%3D%3D%3D%20%22docs.djangoproject.com%22)%20%7Blet%20urlparts%20%3D%20url.href.split(%22%2F%22)%3Burlparts%5B3%5D%20%3D%20%22en%22%3Burlparts%5B4%5D%20%3D%20%22stable%22%3Bwindow.location.assign(urlparts.join(%22%2F%22))%3B%7D%7D)()
|
That works
This new version automatically redirects to the English language because anyway who uses other languages?
Javascript, Indented code |
---|
| var url = new URL(location),
value = url.pathname.trimStart(5),
version = value.split("/")[2],
lang = value.split("/")[1],
next = value.replace([lang, version].join("/") + "/", ""),
hash = url.hash,
version = "stable";
location.assign("https://docs.djangoproject.com/en/" + version + next + hash);
|
Javascript, Bookmarklet |
---|
| javascript:var url=new URL(location),value=url.pathname.trimStart(5),version=value.split("/")[2],lang=value.split("/")[1],next=value.replace([lang,version].join("/")+"/",""),hash=url.hash,version="stable";location.assign("https://docs.djangoproject.com/en/"+version+next+hash);
|
Note
If the page you’re at doesn’t exist in the latest stable version you’ll get redirected to a 404, if it happens, use the version change feature on Django’s documentation*