Javascript 如何在chrome扩展中保存值?

Javascript 如何在chrome扩展中保存值?,javascript,google-chrome,google-chrome-extension,google-chrome-storage,Javascript,Google Chrome,Google Chrome Extension,Google Chrome Storage,我想知道如何在chrome扩展中保存用户提供的输入。我已经看到了这个问题的其他答案,但idk为什么,但我不能这样做,所以请不要用chrome存储api链接回答,如果你能用适合我代码的chrome存储链接回答,谢谢。这是html: <input type="text" id="html_whook" class="input_whook" placeholder="Webhook"> &

我想知道如何在chrome扩展中保存用户提供的输入。我已经看到了这个问题的其他答案,但idk为什么,但我不能这样做,所以请不要用chrome存储api链接回答,如果你能用适合我代码的chrome存储链接回答,谢谢。这是html:

     <input type="text" id="html_whook" class="input_whook" placeholder="Webhook">
     <script src="./storage.js"></script>```


this is the js code, i was trying to do it:



window.onload = function() {
    function saveChanges () {
        let valore = document.getElementById('html_whook').value;

        chrome.storage.sync.set({'html_whook': valore}, function() {
            alert(valore);
        });
        
    };
}


```
这是js代码,我正在尝试:
window.onload=函数(){
函数saveChanges(){
让valore=document.getElementById('html_whook').value;
chrome.storage.sync.set({'html\u whook':valore},function(){
警戒(valore);
});
};
}

我修复了我的代码,现在看起来是这样,我也更改了html,我在控制台上也没有任何错误,但它仍然不起作用

        let valore = document.getElementById('discord_id').value;

        chrome.storage.sync.set({'discord_id': valore}, function() {
            alert(valore);
        });
        
    };


html:    ```    <img src="LOGOVERO.png" class="image" alt="logo">
        <h1 class="testo">Enter your key:</h1>
        <p><input type="text" class="rounded-input" id="key" placeholder="XXXX-XXXX-XXXX-XXXX"></input></p>
        <h1 class="testo2">Enter your Discord ID:</h1>
        <p><input type="text" class="rounded-input2" id="discord_id" placeholder="Example#0001"></input></p>
    </style>
        <p><a><button class="btn" id="save">AUTHENTICATE</a></p>

    </body> This is just a part of the html```
let valore=document.getElementById('discord_id')。值;
chrome.storage.sync.set({'discord_id':valore},function(){
警戒(valore);
});
};
html:`
输入您的密钥:

输入您的Discord ID:

鉴定

这只是html的一部分```
您是否收到任何错误或消息?请注意,弹出窗口是一个单独的窗口,因此它有自己的单独开发工具:在弹出窗口内单击鼠标右键,然后在菜单中选择“检查”。为什么函数
saveChanges
在onload事件处理程序中?另外,您希望从中获取值并保存,因为窗口刚刚加载,用户没有输入任何值。另外,是什么触发了
saveChanges
功能?表单
提交
或按钮
点击
?缺少这些详细信息,请使用详细信息更新您的问题。另外,检查您的浏览器控制台是否有任何错误(请注意@wOxxOm的建议,弹出式控制台不同于页面的控制台)。