Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

139
Views
How do I make an alert box's input change the value in localstorage?

I'm trying to make a bookmarklet that modifies the "local storage" for a game online, but I want it to question the user the amount of "coins" the user wants via an alert.

This is the code

localStorage.setItem('mjs-drift-boss-game-v1.0.1-dailyreward',
 '{"sound":0.7,"music":0,"score":-3,"hasShownTutorial":true,"collectedCoin":999999,"cars":[0,1,2,3,4,5,6,7],"currentCar":7,"currentTip":0,"booster1":99999999,"booster2":9999999,"booster3":999999,"ko":0,"hasShownBoosterTutorial":true}')
alert('Modifed Game!')
location.reload();
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You can do something like this:

const data = JSON.parse(localStorage.getItem('mjs-drift-boss-game-v1.0.1-dailyreward'));
const coins = window.prompt('Set Coins', data.collectedCoin);

localStorage.setItem('mjs-drift-boss-game-v1.0.1-dailyreward',
'{"sound":0.7,"music":0,"score":-3,"hasShownTutorial":true,"collectedCoin":' + coins + ',"cars":[0,1,2,3,4,5,6,7],"currentCar":7,"currentTip":0,"booster1":99999999,"booster2":9999999,"booster3":999999,"ko":0,"hasShownBoosterTutorial":true}')
alert('Modifed Game!')
location.reload();

This way you get the last stored value pre filled and you can change it to the new value, which gets stored in localStorage.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!