HTTP TO HTTPS

设置HTTP网页自动跳转到HTTPS

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         HTTP TO HTTPS
// @namespace    https://zfdev.com/
// @version      0.1
// @description  设置HTTP网页自动跳转到HTTPS
// @author       ZFDev
// @include      /.*/
// @grant        GM_registerMenuCommand
// @grant        GM_getValue
// @grant        GM_setValue
// @run-at       document-start
// ==/UserScript==

!function() {
    "use strict";
    const t = location.host, e = "https:" === location.protocol, n = function isdefualtHttps() {
        if (e) {
            let e = GM_getValue(t);
            if (null === e) {
                return !0;
            }
            if (1 == e) {
                return !1;
            }
            return !0;
        }
        return !1;
    }();
    function setBtnStart() {
        trigger(), whetherJump() && toHTTPS();
    }
    function whetherJump() {
        if (e) {
            return !1;
        }
        return 1 == GM_getValue(location.host);
    }
    function trigger() {
        let e = GM_getValue(t), n = 1;
        null === e ? n = 1 : 1 == e && (n = 0), GM_setValue(t, n);
    }
    function toHTTPS() {
        if (e) {
            return;
        }
        let t = location.href.replace("http://", "https://");
        self.location.href = t;
    }
    !function main() {
        if (n) {
            return;
        }
        let r = "";
        if (whetherJump()) {
            if (r = "\u5173", !e) {
                return void toHTTPS();
            }
        } else {
            r = "\u5f00";
        }
        GM_registerMenuCommand("[ " + t + " ] - " + r, setBtnStart);
    }();
}();