- Force https.
- Split domain pasted to username field to domain field.
- Optionally (disabled by default) convert domain dropdown to text input.
Last active
October 15, 2015 14:01
-
-
Save pyhedgehog/81c93f54c89ce5e5afdb to your computer and use it in GitHub Desktop.
Qip.Ru mail login domain fixer (v1)
This file contains 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
// ==UserScript== | |
// @name Qip.Ru mail login domain fixer | |
// @id qipruLogin@pyhedgehog.github.com | |
// @namespace https://gist.github.com/pyhedgehog/ | |
// @description Login domain fixer for https://qip.ru/ | |
// Can be used with KeePass - you should save complete email as username and domain will be splitted after insertion. | |
// @homepage https://gist.github.com/pyhedgehog/81c93f54c89ce5e5afdb/ | |
// @downloadURL https://gist.github.com/pyhedgehog/81c93f54c89ce5e5afdb/raw/qipruLogin.user.js | |
// @updateURL https://gist.github.com/pyhedgehog/81c93f54c89ce5e5afdb/raw/qipruLogin.meta.js | |
// @include https://qip.ru/* | |
// @include http://qip.ru/* | |
// @version 1 | |
// @grant none | |
// @run-at document-end | |
// ==/UserScript== |
This file contains 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
// ==UserScript== | |
// @name Qip.Ru mail login domain fixer | |
// @id qipruLogin@pyhedgehog.github.com | |
// @namespace https://gist.github.com/pyhedgehog/ | |
// @description Login domain fixer for https://qip.ru/ | |
// Can be used with KeePass - you should save complete email as username and domain will be splitted after insertion. | |
// @homepage https://gist.github.com/pyhedgehog/81c93f54c89ce5e5afdb/ | |
// @downloadURL https://gist.github.com/pyhedgehog/81c93f54c89ce5e5afdb/raw/qipruLogin.user.js | |
// @updateURL https://gist.github.com/pyhedgehog/81c93f54c89ce5e5afdb/raw/qipruLogin.meta.js | |
// @include https://qip.ru/* | |
// @include http://qip.ru/* | |
// @version 1 | |
// @grant none | |
// @run-at document-end | |
// ==/UserScript== | |
(function qipmail_domain_fixer() { | |
var debug = false; | |
var wantTextDomain = false; | |
if(debug)console.log('qipmail_domain_fixer'); | |
if(document.location.protocol == 'http:') { | |
var u = new URL(document.location.href); | |
u.protocol = 'https:'; | |
if(debug)console.log('qipmail_domain_fixer: redirect: ', u.href); | |
window.location = u; | |
return; | |
} | |
var logForm = document.getElementsByName('qip_login_form'); | |
if(debug)console.log('qipmail_domain_fixer: logForm=', logForm); | |
if(!logForm) return; | |
var userElem = logForm[0].elements['login']; | |
if(debug)console.log('qipmail_domain_fixer: login=', userElem); | |
var hostElem = logForm[0].elements['host']; | |
console.log('qipmail_domain_fixer: hostElem=', hostElem); | |
if(!hostElem || hostElem.tagName!='SELECT') return; | |
hostElem.removeAttribute("name"); | |
if(debug)console.log('qipmail_domain_fixer: host=', hostElem.value); | |
if(wantTextDomain) { | |
hostElem.insertAdjacentHTML('afterend','<input type="hidden" name="host" value="'+hostElem.value+'"/>'); | |
var newElem = hostElem.nextElementSibling; | |
if(debug)console.log('qipmail_domain_fixer: new host=', newElem.value); | |
hostElem.addEventListener('change', function() { | |
if(debug)console.log('qipmail_domain_fixer: hostElem.onchange'); | |
newElem.value = hostElem.value; | |
}); | |
newElem.addEventListener('change', function() { | |
if(debug)console.log('qipmail_domain_fixer: newElem.onchange'); | |
hostElem.value = newElem.value; | |
if(hostElem.onchange) | |
hostElem.onchange(); | |
}); | |
} | |
userElem.addEventListener('change', function() { | |
if(debug)console.log('qipmail_domain_fixer: userElem.onchange: ', userElem.value); | |
if(userElem.value.contains('@')) { | |
var user = userElem.value.split('@')[0]; | |
var domain = userElem.value.split('@')[1]; | |
if(debug)console.log('qipmail_domain_fixer: userElem.onchange: user=', user); | |
if(debug)console.log('qipmail_domain_fixer: userElem.onchange: domain=', domain); | |
hostElem.value = domain; | |
if(wantTextDomain) newElem.value = domain; | |
userElem.value = user; | |
if(hostElem.onchange) | |
hostElem.onchange(); | |
} | |
}); | |
if(userElem.value) { | |
var ev = document.createEvent('Event'); | |
ev.initEvent('change'); | |
userElem.dispatchEvent(ev); | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment