I am developing a userscript that redirects insecure pages (HTTP) to the https: version.
// ==UserScript==
// @name Secure Redirect
// @namespace http://tampermonkey.net/
// @version 0.1
// @description A simple userscript that redirects pages to https:.
// @author You
// @match *
// @grant none
// ==/UserScript==
(function() {
'use strict';
window.onload=()=>{
if (location.protocol != "https:") {
window.location.href = "https:" + window.location.href.substring(window.location.protocol.length);
}
};
})();
Please tell me if it works and what I can improve on. My GitHub repo for this project is here.