Stackoverflow.com redirect to archive.org

Auto redirect Stackoverflow to archive.org when super ultra low user experience Cloudflare captcha detected.

目前為 2024-10-11 提交的版本,檢視 最新版本

  1. // ==UserScript==
  2. // @name Stackoverflow.com redirect to archive.org
  3. // @namespace https://wsl.moe/
  4. // @version 2024-10-11
  5. // @description Auto redirect Stackoverflow to archive.org when super ultra low user experience Cloudflare captcha detected.
  6. // @license WTFPL
  7. // @author You
  8. // @match https://*.stackexchange.com/*
  9. // @match https://*.stackoverflow.com/*
  10. // @grant none
  11. // ==/UserScript==
  12.  
  13. (function() {
  14. 'use strict';
  15. let executeCount = 0;
  16. let intervalId = 0;
  17.  
  18. intervalId = setInterval(() => {
  19. if (executeCount > 10) {
  20. clearInterval(intervalId);
  21. }
  22. if (
  23. document.body.innerText.indexOf('Ray ID: ') !== -1 &&
  24. document.getElementsByTagName('a')[0].href.indexOf('utm_source=challenge') !== -1 &&
  25. document.body.innerHTML.indexOf('/cdn-cgi/challenge-platform/') !== -1
  26. ) {
  27. const origUrl = location.href;
  28. location.href = 'https://web.archive.org/web/' + origUrl;
  29. }
  30. executeCount += 1;
  31. }, 2000);
  32. })();