Commit 44f7e067 authored by Zeyu DONG's avatar Zeyu DONG
Browse files

make enter to submit data and add checking the existence of 'fm1'

parent 97a094d7
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
chrome.runtime.sendMessage({command: "storage"}, function(response) {
	if(response.auto=='true'){
		if(document.URL.indexOf("https://cas.sustc.edu.cn/cas/login") >= 0 )   
		if(document.URL.indexOf("https://cas.sustc.edu.cn/cas/login") >= 0 && document.getElementById('fm1') != null)
		{
			if(document.getElementById('fm1').firstElementChild.tagName!="DIV"){
				console.log('login...');
+15 −5
Original line number Diff line number Diff line
@@ -4,9 +4,17 @@ function change(){
	if(user!=''&&pass!=''){
		localStorage.setItem('username', user);
		localStorage.setItem('password', pass);	
	}
		document.getElementById('ok').setAttribute('style', 'color:#00EC00;');
	}
}
function enterPress(){
	if(event.keyCode==13){
		change();
	}
	else{
		document.getElementById('ok').setAttribute('style', 'display: none;');
	}
}
function auto(){
	localStorage.setItem('autologin', this.checked);
}
@@ -21,5 +29,7 @@ function load(){
document.addEventListener('DOMContentLoaded', function () {
	document.getElementById('change').addEventListener('click', change);
	document.getElementById('auto').addEventListener('change', auto);
	document.getElementById('username').addEventListener('keydown', enterPress);
	document.getElementById('password').addEventListener('keydown', enterPress);
	load();
});
 No newline at end of file
+3 −3

File changed.

Contains only whitespace changes.