User:Kalan/sslswitch.js
Note: After publishing, you may have to bypass your browser's cache to see the changes.
- Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
- Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
- Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5.
// Whole Wikimedia
$(function(){
var secureurl = {
en:'Secure URL',
de:'Sichere URL',
ru:'Безопасный URL'
}
var insecureurl = {
en:'Insecure URL',
de:'Unsichere URL',
ru:'Небезопасный URL'
}
// updated manually from [[Special:Sitematrix]]
var metas = '$advisory$auditcom$board$chair$chapcom$comcom$commons$exec' +
'$grants$incubator$internal$meta$office$otrs-wiki$quality$s' +
'earchcom$sources$spcom$species'
var swAddress
var swMatches = document.URL.match(/http:\/\/([^.]+)\.([^.]+)\..*?\/(.*)/)
var swTo = -1
if (swMatches) {
swAddress = 'https://secure.wikimedia.org/' +
(metas.indexOf('$' + swMatches[1] + '$') != -1 ? 'wikipedia' : swMatches[2]) +
'/' + swMatches[1] + '/' + swMatches[3]
swTo = 1
} else {
swMatches = document.URL.match(/https:\/\/.*?\/([^.\/]+)\/([^.\/]+)\/(.*)/)
swAddress = 'http://' + swMatches[2] + '.' +
(metas.indexOf('$' + swMatches[2] + '$') != -1 ? 'wikimedia' : swMatches[1]) +
'.org/' + swMatches[3]
swTo = 0
}
document.getElementById('p-logo').innerHTML =
'<a id="sslicon" style="display:block;position:absolute;left:3px;top:3px' +
';width:16px;height:16px;" href="' + swAddress + '" title="' +
(swTo == 0 ? insecureurl[wgUserLanguage] : secureurl[wgUserLanguage]) +
'"><img src="http://upload.wikimedia.org/wikipedia/commons/' +
(swTo == 0 ? 'c\/c5\/Lock_break':'6\/69\/Lock_go') +
'.png" width="16" height="16" alt="" /></a>' +
document.getElementById('p-logo').innerHTML
})