简体   繁体   中英

How can i save values in a chrome extension?

i want to know how can i save inputs given by users in the chrome extension. I have already seen other answers to this same question but idk why but i cant do it, so please dont answer with the chrome storage api link, if you can reply with the chrome storage link adapted to my code, thanks. This is the 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);
        });
        
    };
}

i kinda fixed my code and now it looks like this, i also changed html, i also dont have any errors on the console but it still doesnt work

        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```

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM