gpt4 book ai didi

javascript - 扩展 : chrome. 存储 SET

转载 作者:行者123 更新时间:2023-11-28 04:44:28 24 4
gpt4 key购买 nike

大家好:)

my other post where we solved the GET.好的,我让基地再次工作 - 我想。现在真不知道chrome存储的SET命令是怎么用的。

这应该设置/保存具有此 ID 的框中的值:“ts_id_js_html”

var input_id = document.getElementById("ts_id_js_html").value;
chrome.storage.local.set({"ts_id_js": input_id});

这是它(应该)从中获取值的地方:

<form>
<input id="ts_id_js_html" type="text" value="128856"></input>
<button id="execButton">Save/Load</button>
</form>

最佳答案

我实际上得到了它:

chrome.storage.local.set({"ts_id_js": input_id}, function (obj) { chrome.storage.local.get("ts_id_js", function (obj) { console.log("ts_id_js INSIDE func.test (这是你的ID吗?):"+ obj.ts_id_js);//这一行是为了控制台中的测试输出 });

现在唯一的问题是,由于某种原因,它无法在 chrome 扩展弹出窗口中获取输入。每当我尝试获取 ID 时,我需要先添加

chrome.storage.local.get("ts_id_js", function (obj) {

代码的前面,最后关闭

});

(如果其他人使用此代码,请不要忘记更改所有必要的部分!(ts_id_js、input_id、obj (obj.ts_id_js))

关于javascript - 扩展 : chrome. 存储 SET,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41038011/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com