MediaWiki:Common.js: Difference between revisions
Jump to navigation
Jump to search
Admin 4 bbp (talk | contribs) No edit summary |
Admin 4 bbp (talk | contribs) No edit summary |
||
(6 intermediate revisions by the same user not shown) | |||
Line 15: | Line 15: | ||
window.location.href = window.location.href.replace('http://', 'https://'); | window.location.href = window.location.href.replace('http://', 'https://'); | ||
} | } | ||
else if (window.location.protocol === ' | //else if (window.location.protocol === 'https:' && logoutLink){ | ||
// console.log("redirect to http"); | |||
// window.location.href = window.location.href.replace('https://', 'http://'); | |||
} | //} | ||
const meta = document.createElement('meta'); | |||
meta.httpEquiv = 'Content-Security-Policy'; | |||
meta.content = 'upgrade-insecure-requests'; | |||
document.getElementsByTagName('head')[0].appendChild(meta); |
Latest revision as of 21:48, 21 November 2024
/* Any JavaScript here will be loaded for all users on every page load. */ var logoutLink = document.querySelector('a[href*="Special:UserLogout"]'); if (logoutLink) { console.log('Log out link found!'); } else { console.log('Log out link not found.'); } console.log("checking to redirect"); if (window.location.protocol === 'http:' && !logoutLink) { console.log("redirect to ssl"); window.location.href = window.location.href.replace('http://', 'https://'); } //else if (window.location.protocol === 'https:' && logoutLink){ // console.log("redirect to http"); // window.location.href = window.location.href.replace('https://', 'http://'); //} const meta = document.createElement('meta'); meta.httpEquiv = 'Content-Security-Policy'; meta.content = 'upgrade-insecure-requests'; document.getElementsByTagName('head')[0].appendChild(meta);