Commit c3492401 authored by Zeyu DONG's avatar Zeyu DONG
Browse files

frist commit

parents
Loading
Loading
Loading
Loading

background.js

0 → 100644
+15 −0
Original line number Diff line number Diff line
chrome.runtime.onMessage.addListener(
	function(request, sender, sendResponse) {
		if (request.storage == "all")
			sendResponse({username: localStorage.getItem('username'), 
						password: localStorage.getItem('password'), 
						auto: localStorage.getItem('autologin')});
	}
);
if(localStorage.length!=3){
	console.log('init...');
	localStorage.setItem('autologin', false);
	localStorage.setItem('username', '');
	localStorage.setItem('password', '');
}
 No newline at end of file

content.js

0 → 100644
+19 −0
Original line number Diff line number Diff line
if(document.URL.indexOf("https://cas.sustc.edu.cn/cas/login") >= 0 )   
{
	chrome.runtime.sendMessage({storage: "all"}, function(response) {
		var user = response.username;
		var pass = response.password;
		var auto = response.auto;
		if(auto=='true'){
			document.getElementById('username').value = response.username;
			document.getElementById('password').value = response.password;
			document.getElementsByName('submit')[0].click();
		}
	});
} else if(document.URL.indexOf("http://enet.10000.gd.cn:10001/sz/sz112/transfer.jsp") >= 0 ) {
	document.getElementsByTagName('input')[0].click();
} else if(document.URL.indexOf("http://enet.10000.gd.cn:10001/sz/sz112/index.jsp") >=0 ){
	window.location.href="https://www.baidu.com/";
	window.close();
}
 No newline at end of file

icon.png

0 → 100644
+23.5 KiB
Loading image diff...

manifest.json

0 → 100644
+27 −0
Original line number Diff line number Diff line
{
"name": "CAS Login",
"version": "0.1",
"manifest_version": 2,
"description": "Auto login cas",
"icons": { "128": "icon.png" },
"permissions": [
	"https://cas.sustc.edu.cn/", 
	"http://enet.10000.gd.cn:10001/", 
	"storage"],
"browser_action": {
	"default_title": "CAS Login",
	"default_icon": "icon.png",
	"default_popup": "popup.html"
},
"background": {
    "scripts": ["background.js"]
},
"content_scripts": [
    {
      "matches": ["https://cas.sustc.edu.cn/cas/*", "http://enet.10000.gd.cn:10001/*"],
      "js": ["content.js"], 
	  "run_at": "document_end"
    }
  ]
}
 No newline at end of file

popup.html

0 → 100644
+27 −0
Original line number Diff line number Diff line
<html>
	<head>
		<title>popup</title>
		<script src='popup.js'></script> 
		<style>
			body {width:250px;}
		</style>
	</head>
	<body>
	<table>
		<tr>
			<td>Username:</td>
			<td><input type="text" id="username"></td>
		</tr>
		<tr>
			<td>Password:</td>
			<td><input type="password" id="password"></td>
		</tr>
		<tr>
			<td><button type="button" id="change">Save</button></td>
			<td id="ok" style="display:none;">OK<td>
		</tr>
	</table> 
		<input type="checkbox" id="auto">Enable auto login</input>
	</body>
</html>
 No newline at end of file