`

Chrome extension sample

阅读更多
文件包结构:
icon.png // 插件图标
jquery-1.11.1.min.js //引入jQuery
manifest.json // 主配置文件
myscript.js // 针对页面操作的js
popup.html //弹出框页面


1.manifest.json
{
"name": "NewIssueNotify",
"version": "1.0",
"manifest_version":2,
"description": "Get new issue from aramark.",
"browser_action": {"default_icon": "icon.png","default_popup": "popup.html"},
"content_scripts": [//For page content
    {
      "matches": ["https://*/*"],
      "js": ["jquery-1.11.1.min.js", "myscript.js"]
    }
  ],
"permissions": [ "http://*/*", "https://*/*", "notifications" ]
}


2.popup.html
<!DOCTYPE HTML>
<html>
  <header>
    <script src="http://code.jquery.com/jquery-1.11.0.min.js"></script>
  </header>
<body>
  <div style="width:300px;height:100px;">
    <h1>Refresh the aramark issue page every 2 mins!!!</h1>
  </div>
</body>
</html>


3.myscript.js
function myrefresh(){
	console.log('Fire auto!!!');
	window.location.reload();
}

$(document).ready(function(){
	if($('.autoscroll input:first').val()==581){
		console.log('Go to sleep!');
		setTimeout("myrefresh()", 2*60*1000);
	}else{
		console.log('Fire!!!');
		alert('Fire!!!');
	}
});
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics