export Data in localStorage for later re-import

后端 未结 5 664
既然无缘
既然无缘 2021-01-31 00:22

I want to export a few items from my localStorage to save it externally but in a format so that I can import it again later.

My attempt was to write executable code that

5条回答
  •  盖世英雄少女心
    2021-01-31 01:01

    Just a modernized version of @iceLord answer.

    Just run this in the console, it will put the code to restore the localStorage back into your clipboard.

    copy(`Object.entries(${JSON.stringify(localStorage)})
    .forEach(([k,v])=>localStorage.setItem(k,v))`)
    

    Bookmarklet version

    javascript:prompt(`localStorage from ${location.host}${new Date().toLocaleString()}`, `/* localStorage from ${location.host}${new Date().toLocaleString()}*/Object.entries(  ${JSON.stringify(localStorage)}).forEach(([k,v])=>localStorage.setItem(k,v))`)
    

提交回复
热议问题