Commit 7dd959e7 authored by Zeyu DONG's avatar Zeyu DONG
Browse files

close the tab automatically

parent 6a446165
Loading
Loading
Loading
Loading
+14 −1
Original line number Diff line number Diff line
chrome.runtime.onMessage.addListener(
	function(request, sender, sendResponse) {
		if (request.storage == "all")
		if (request.command == "storage")
			sendResponse({username: localStorage.getItem('username'), 
						password: localStorage.getItem('password'), 
						auto: localStorage.getItem('autologin')});
		else if(request.command == "close")
			chrome.tabs.getSelected(function(tab) {
				chrome.tabs.getAllInWindow(function(tab2) {
					if(tab2.length > 1) {
						chrome.tabs.remove(tab.id);
					}
					else {
						chrome.tabs.update(tab.id, {
							url: "https://www.baidu.com/"
						});
					}
				});
			});
	}
);
if(localStorage.length!=3){
+3 −3
Original line number Diff line number Diff line
chrome.runtime.sendMessage({storage: "all"}, function(response) {
chrome.runtime.sendMessage({command: "storage"}, function(response) {
	if(response.auto=='true'){
		if(document.URL.indexOf("https://cas.sustc.edu.cn/cas/login") >= 0 )   
		{
@@ -17,7 +17,7 @@ chrome.runtime.sendMessage({storage: "all"}, function(response) {
		} 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/";
			chrome.runtime.sendMessage({command: "close"});
		}
	}
});
 No newline at end of file
+2 −1
Original line number Diff line number Diff line
@@ -7,7 +7,8 @@
"permissions": [
	"https://cas.sustc.edu.cn/", 
	"http://enet.10000.gd.cn:10001/", 
	"storage"],
	"storage",
	"tabs"],
"browser_action": {
	"default_title": "CAS Login",
	"default_icon": "icon.png",