我一直在做一些研究,由于某种原因无法找到一个很好的例子显示这一点,我开始怀疑它是否有可能.
我要做的是让我的扩展程序在Google电子表格中写入数据,以便将工作表用作数据库.
有没有人有任何我可以遵循的文件?考虑到Spreadsheet API似乎不允许JavaScript,甚至可能吗?
谢谢.
对XMLHttpRequests不是很熟悉,但正在使用 Google Chrome 扩展中的跨域功能。这很好用(我可以确认我得到了我需要的适当数据),但我似乎无法将它存储在 'response' 变量中。
我很感激任何帮助。
function getSource() {
var response;
var xmlhttp;
xmlhttp=new XMLHttpRequest();
xmlhttp.onreadystatechange=function() {
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
response = xmlhttp.responseText;
//IM CORRECTLY SET HERE
}
//I'M ALSO STILL WELL SET HERE
}
//ALL OF A SUDDEN I'M UNDEFINED.
xmlhttp.open("GET","http://www.google.com",true);
xmlhttp.send();
return response;
}
Run Code Online (Sandbox Code Playgroud) 我觉得我错过了一些非常明显的东西,但我一直在寻找各处,似乎无法使这项工作成功.简而言之,我想将一个小的Javascript脚本转换为chrome扩展,以使其更易于使用.
该脚本只是从textArea读取文本,修改脚本并将其输出到div中.它在独立运行时可以与任何浏览器完美配合,但在作为Chrome扩展程序运行时似乎不想工作
这是文件(我基本上试图转换示例):
的manifest.json
{
"manifest_version": 2,
"name": "One-click Kittens",
"description": "This extension demonstrates a 'browser action' with kittens.",
"version": "1.0",
"browser_action": {
"default_icon": "icon.png",
"default_popup": "popup.html"
},
"permissions": [
"https://secure.flickr.com/"
]
}
Run Code Online (Sandbox Code Playgroud)
popup.html
<!doctype html>
<html>
<head>
<title>Getting Started Extension's Popup</title>
<style>
body {
min-width: 357px;
overflow-x: hidden;
}
img {
margin: 5px;
border: 2px solid black;
vertical-align: middle;
width: 75px;
height: 75px;
}
</style>
<!--
- JavaScript and HTML must be in separate files: see our Content …Run Code Online (Sandbox Code Playgroud)