Sleazy Fork is available in English.

Nhentai.net Errors Automatically resolve

Automatically resolves "403 - CSRF Token Invalid" or "429 Too Many Requests" or "404 - Not Found" displayed on nhentai.net web pages. (Script assisted by ChatGPT)

  1. // ==UserScript==
  2. // @name Nhentai.net Errors Automatically resolve
  3. // @name:zh-TW Nhentai.net 錯誤自動排除
  4. // @name:zh-CN Nhentai.net 错误自动排除
  5. // @version 1.1
  6. // @description Automatically resolves "403 - CSRF Token Invalid" or "429 Too Many Requests" or "404 - Not Found" displayed on nhentai.net web pages. (Script assisted by ChatGPT)
  7. // @description:zh-TW 自動解決 nhentai.net 網頁上顯示 "403 – CSRF Token Invalid" 或 "429 Too Many Requests" 或 "404 – Not Found"(此腳本由ChatGPT協助撰寫)
  8. // @description:zh-CN 自动解决 nhentai.net 网页上显示 "403 – CSRF Token Invalid" 或 "429 Too Many Requests" 或 "404 – Not Found"(此脚本由ChatGPT协助撰写)
  9. // @author 特務E04
  10. // @match https://nhentai.net/*
  11. // @require https://code.jquery.com/jquery-3.6.0.min.js
  12. // @noframes
  13. // @supportURL https://github.com/jmsch23280866/Nhentai-403-404-429-automate/issues
  14. // @license MIT
  15. // @namespace https://github.com/jmsch23280866
  16. // ==/UserScript==
  17.  
  18. (function() {
  19. 'use strict';
  20.  
  21. // 檢查網頁是否顯示 "403 – CSRF Token Invalid" 或 "ERR_CACHE_MISS"
  22. function checkFor403OrCacheMiss() {
  23. if ($('body:contains("403 – CSRF Token Invalid")').length > 0 || $('body:contains("ERR_CACHE_MISS")').length > 0) {
  24. console.log("Detected 403 – CSRF Token Invalid or ERR_CACHE_MISS, changing URL from https to http in 2 seconds...");
  25. setTimeout(function() {
  26. let newUrl = window.location.href.replace(/^https:/, 'http:');
  27. window.location.href = newUrl; // 將網址中的 https 改為 http 並重新加載
  28. }, 1000); // 1秒後修改網址並重新加載
  29. }
  30. }
  31.  
  32. // 檢查網頁是否顯示 "429 Too Many Requests"
  33. function checkFor429() {
  34. if ($('body:contains("429 Too Many Requests")').length > 0) {
  35. console.log("Detected 429 Too Many Requests, refreshing in 2 seconds...");
  36. setTimeout(function() {
  37. location.reload(); // 普通重新整理
  38. }, 1000); // 1秒後重新整理
  39. }
  40. }
  41.  
  42. // 檢查網頁是否顯示 "404 – Not Found"
  43. function checkFor404() {
  44. if ($('body:contains("404 – Not Found")').length > 0) {
  45. console.log("Detected 404 – Not Found, redirecting to Web Archive in 2 seconds...");
  46. setTimeout(function() {
  47. let currentUrl = window.location.href;
  48. let archiveUrl = 'https://web.archive.org/web/' + currentUrl;
  49. window.location.href = archiveUrl; // 跳轉到 Web Archive 的對應頁面
  50. }, 1000); // 1秒後跳轉
  51. }
  52. }
  53.  
  54. // 當頁面加載完成後檢查一次
  55. document.addEventListener('DOMContentLoaded', function() {
  56. checkFor403OrCacheMiss();
  57. checkFor429();
  58. checkFor404();
  59. });
  60. })();