我正在为刮刀制作镀铬扩展程序我正在努力控制它等等。我有一个登录脚本在这里:
<?php
$username = $_GET['username'];
$password = $_GET['password'];
$pass = sha1($password);
$mysql = new mysqli("*" , "*" , "!!*" , "*");
$data = $mysql->query("SELECT * FROM `staff_section`.`logins` WHERE `staff_name` = '$username' && `staff_pass` = '$pass'");
echo $data->num_rows;
$mysql->close();
unset($data);
?>
我的Launch.js文件在这里:
chrome.app.runtime.onLaunched.addListener(function(){
chrome.app.window.create('window.html' , {
'outerBounds': {
'width' : 720,
'height' : 720
} ,
frame: 'none'
});
get("loginform").addEventListener('submit' , function(){
checkLogin(get("username").value , get("password").value);
});
});
function checkSession(){
if(Session.getSession("authorized") == false){
//Do nothing
}else{
}
}
function checkLogin(username , password){
var xmlhttp = new XMLHttpRequest();
xmlhttp.open("get" , "http://192.168.4.240/CHROME_APP_SERVER/ajax/login.php?username=" + username + "&password=" + password , false);
xmlhttp.send();
if(xmlhttp.responseText == "1"){
Session.start();
}else{
alert("Incorrect Credentials");
}
}
function get(id){
return document.getElementById(id);
}
我的Window.html文件在这里:
<html>
<title></title>
<script src="js/launch.js"></script>
<script src="js/session.js"></script>
<style>
</style>
<body bgcolor="#404040">
<div style="position:absolute;top:0px;left:0px;width:100%;height:50px;background:#171717;">
<img src="img/jejamesicon.ico" style="position:absolute;top:10px;left:10px;" width="30" height="30"/>
<p style="position:absolute;top:17.5px;left:55px;color:#fff;font-family:verdana;margin:0px;"></p>
</div>
<div style="position:absolute;top:60px;left:10px;right:10px;bottom:10px;text-align:center;">
<form id="loginform">
<input type="text" id="username" placeholder="Username"/>
<input type="password" id="password" placeholder="Password"/>
<input type="submit" value="Log In"/>
</form>
</div>
</body>
当我尝试登录XMLHttpRequest时,我得到的是:
Can't open same-window link to "chrome-extension://iflddlelmkkkeoehpghlblcmkkbgacpp/window.html?"; try target="_blank".
为什么我不能创建XMLHttpRequests?我在Manifest中设置了Permission:
{
"manifest_version" : 2,
"name": "J E James Scraper",
"description" : "J E James Cycles Scraper GUI",
"version" : "1.0",
"app" : {
"background" : {
"scripts" : ["js/launch.js"]
}
},
"icons" : {
"128" : "img/icon.png"
} ,
"permissions" : [
"http://192.168.4.240/*"
]
}
那么为什么我的Scraper不工作,登录脚本存储在
上面的指定网址上