これは私の popup.html です:
<!DOCTYPE html>
<html lang="en">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
<script src="script.js"></script>
<script src="popup.js"></script>
<head>
<meta charset="utf-8">
<title> Chrome Extension</title>
<link rel="stylesheet" href="style.css" />
</head>
<body id="container">
<div id="left">
<form>
<div class="input-wrapper">
<input type="text" id="query" />
<button id="openBackgroundWindow">Open background window</button>
</div>
<input type="submit" id="button" value="Search" alt="Loading" />
</form>
<!-- rest of the code will follow this -->
<!-- other code above -->
<div id="results">
<ul id="results-list">
<!-- this gets populated -->
</ul>
</div>
</div> <!-- end #left -->
</body>
</html>
これは私の popup.js です:
$("#openBackgroundWindow").click(function(){
login();
chrome.extension.sendRequest({ msg: "login" });
});
function openNextPage(){
var bg = chrome.extension.getBackgroundPage().openNextPage();
}
function pageRender(){
console.log("no user")
if (localStorage.getItem("username") == null){
console.log("no user")
}
function codeAddress() {
document.getElementById('button').style.visibility='hidden';
}
}
function login(){
var xhr = new XMLHttpRequest();
xhr.open("POST", "http://localhost:3000/login", true);
xhr.onreadystatechange = function() {
if (xhr.readyState == 4) {
// JSON.parse does not evaluate the attacker's scripts.
var resp = JSON.parse(xhr.responseText);
}
}
xhr.send();
}
これは私の background.js です:
function login(){
var xhr = new XMLHttpRequest();
xhr.open("POST", "http://localhost:3000/login", true);
xhr.onreadystatechange = function() {
if (xhr.readyState == 4) {
// JSON.parse does not evaluate the attacker's scripts.
var resp = JSON.parse(xhr.responseText);
}
}
xhr.send();
}
chrome.extension.onRequest.addListener(
function(request, sender, sendResponse){
print "hello";
if(request.msg == "login") login();
}
);
background.js の login() 関数も、popup.js の login 関数も呼び出されていません。何が問題になる可能性がありますか?