🏠 Home 

nyaa_tosho_archive_404

nyaa 404 go to tosho


Install this script?
  1. // ==UserScript==
  2. // @name nyaa_tosho_archive_404
  3. // @version 1.0.0
  4. // @namespace guyman
  5. // @description nyaa 404 go to tosho
  6. // @author guyman
  7. // @license MIT
  8. // @match https://nyaa.si/view/*
  9. // @grant GM_xmlhttpRequest
  10. // @run-at document-start
  11. // ==/UserScript==
  12. (function () {
  13. 'use strict';
  14. GM_xmlhttpRequest({
  15. method: 'HEAD',
  16. url: window.location.href,
  17. onload: function (response) {
  18. if (response.status === 404) {
  19. const banner = document.createElement('div');
  20. banner.innerHTML = '<div style="background-color: blue; color: white; padding: 10px; position: fixed; top: 0; left: 0; width: 100%; z-index: 9999;" id="404toarchive-banner">Redirecting to archived version, please wait...</div>';
  21. document.body.appendChild(banner);
  22. GM_xmlhttpRequest({
  23. method: 'GET',
  24. url: `https://cache.animetosho.org/nyaasi/view/${window.location.href.replace("https://nyaa.si/view/", "")}`,
  25. onload: function (response) {
  26. const text = response.responseText;
  27. if (text) {
  28. if (text.includes("Specified ID not found")) {
  29. document.getElementById('404toarchive-banner').innerText = 'This torrent is not archived on animetosho.';
  30. } else {
  31. window.location.replace(`https://cache.animetosho.org/nyaasi/view/${window.location.href.replace("https://nyaa.si/view/", "")}`);
  32. }
  33. }
  34. },
  35. onerror: function (error) {
  36. console.error('Error fetching data:', error);
  37. }
  38. });
  39. }
  40. },
  41. onerror: function (error) {
  42. console.error('Error:', error);
  43. }
  44. });
  45. })();