今天搞了一个chrome的插件,实现自动登录.初次体验chrome的插件开发,好像还不错,呵呵~以后有时间研究一下.
manifest.json
{ "name": "auto login", "version": "1.0", "permissions": [ "tabs", "http://*/*", "https://*/*" ], "browser_action": { "default_title": "AutoLogin", "default_icon": "icon.png", "popup": "popup.html" } }
popup.html
<style>
body {
overflow: hidden;
margin: 0px;
padding: 0px;
background: white;
}
div:first-child {
margin-top: 0px;
}
div {
cursor: pointer;
text-align: center;
padding: 1px 3px;
font-family: sans-serif;
font-size: 0.8em;
width: 100px;
margin-top: 1px;
background: #cccccc;
}
div:hover {
background: #aaaaaa;
}
</style>
<script>
function login(username,password) {
chrome.tabs.executeScript(null,
{code:"document.getElementById('username').value = '"+username+"' "});
chrome.tabs.executeScript(null,
{code:"document.getElementById('password').value = '"+password+"' "});
chrome.tabs.executeScript(null,
{code:"document.getElementById('security').submit()"});
window.close();
}
</script>
<div οnclick="login('admin','admin')" >登录Admin</div>
<div οnclick="login('xielei','123123')" >登录xielei</div>
<div οnclick="login('fgs1','123123')" >登录fgs1</div>