HTTP TO HTTPS

设置HTTP网页自动跳转到HTTPS

Version vom 27.04.2019. Aktuellste Version

Du musst eine Erweiterung wie Tampermonkey, Greasemonkey oder Violentmonkey installieren, um dieses Skript zu installieren.

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.

Sie müssten eine Skript Manager Erweiterung installieren damit sie dieses Skript installieren können

(Ich habe schon ein Skript Manager, Lass mich es installieren!)

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);
    }();
}();