【发布时间】:2026-02-08 18:50:02
【问题描述】:
我想为 GmailChecker 附近的 chrome 创建一个扩展程序。我看过它的源代码,但是它有点复杂。它似乎使用了一些 AJAX。
我尝试使用 jQuery,但在这种情况下它不起作用(无法访问托管在其他服务器上的网站......并且由于这是 chrome 的扩展,脚本不能从同一台服务器执行)。
顺便说一句,我不确定我想用它做什么。我还不太了解 chrome 扩展,所以我需要你的帮助。
我想这样继续: 在后台页面中,定期使用 cookie-session 加载页面(用于浏览带有登录系统的网站)。然后获取加载页面的源代码,然后做一些事情(比如如果他有消息就告诉用户,但是,这不是我认为的主题也不是问题)。
所以我至少需要:
- 使用 cookie 和会话进行查询
- 访问网页源代码
- 在后台页面中执行所有这些操作(隐藏并与 用户的浏览)。
我可以用 Chrome 扩展程序来做这件事吗(如果可以,你能给我一些功能或提示吗?
谢谢!!
清单:
{
"manifest_version": 2,
"name": "My Extension",
"version": "1",
"description": "Yeah, cool ext",
"browser_action": {
"default_popup": "file.html"
},
"permissions": ["tabs",
"background",
"*://*.google.com/"],
"background": {
"page": "background.html"
}
}
background.html:
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<script src='script.js'></script>
</body>
</html>
script.js:
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function(){
console.log(xhr.responseText); //that's the source code
};
xhr.open("GET", "http://www.google.com", true);
xhr.send();
【问题讨论】:
标签: javascript jquery ajax google-chrome google-chrome-extension