HTTP TO HTTPS

设置HTTP网页自动跳转到HTTPS

  1. // ==UserScript==
  2. // @name HTTP TO HTTPS
  3. // @namespace https://zfdev.com/
  4. // @version 0.1
  5. // @description 设置HTTP网页自动跳转到HTTPS
  6. // @author ZFDev
  7. // @include /.*/
  8. // @grant GM_registerMenuCommand
  9. // @grant GM_getValue
  10. // @grant GM_setValue
  11. // @run-at document-start
  12. // ==/UserScript==
  13.  
  14. !function() {
  15. "use strict";
  16. const t = location.host, e = "https:" === location.protocol, n = function isdefualtHttps() {
  17. if (e) {
  18. let e = GM_getValue(t);
  19. if (null === e) {
  20. return !0;
  21. }
  22. if (1 == e) {
  23. return !1;
  24. }
  25. return !0;
  26. }
  27. return !1;
  28. }();
  29. function setBtnStart() {
  30. trigger(), whetherJump() && toHTTPS();
  31. }
  32. function whetherJump() {
  33. if (e) {
  34. return !1;
  35. }
  36. return 1 == GM_getValue(location.host);
  37. }
  38. function trigger() {
  39. let e = GM_getValue(t), n = 1;
  40. null === e ? n = 1 : 1 == e && (n = 0), GM_setValue(t, n);
  41. }
  42. function toHTTPS() {
  43. if (e) {
  44. return;
  45. }
  46. let t = location.href.replace("http://", "https://");
  47. self.location.href = t;
  48. }
  49. !function main() {
  50. if (n) {
  51. return;
  52. }
  53. let r = "";
  54. if (whetherJump()) {
  55. if (r = "\u5173", !e) {
  56. return void toHTTPS();
  57. }
  58. } else {
  59. r = "\u5f00";
  60. }
  61. GM_registerMenuCommand("[ " + t + " ] - " + r, setBtnStart);
  62. }();
  63. }();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址