Last active
February 4, 2020 18:49
-
-
Save luislobo14rap/36cb7d8a83849ccb65e02209dfede1a2 to your computer and use it in GitHub Desktop.
force-to-https.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// force-to-https.js v1 | |
function forceToHttps() { | |
if (location.protocol == 'http:') { | |
var linkHttps = location.href.replace('http', 'https'); | |
// via location | |
window.location.protocol = 'https:'; | |
window.location.href = linkHttps; | |
// via click | |
var a = document.createElement('a'); | |
a.setAttribute('href', linkHttps); | |
a.setAttribute('style', 'display: none !important;'); | |
a.click(); | |
// reinforce | |
setInterval(function() { | |
window.location.href = linkHttps; | |
a.click(); | |
}, 3500); | |
// via meta | |
var meta = document.createElement('meta'); | |
meta.setAttribute('content', '0;URL=' + linkHttps); | |
meta.setAttribute('http-equiv', 'refresh'); | |
(document.head || document.getElementsByTagName('head')[0]).append(meta); | |
}; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment