Discussions » Development

Export GM.setValue Storage data?

§
Posted: 23-12-2021

I made Popup diconary it shows a meaning of a selected English words via iframe dicionary website, and it's record search history with GM.setValue feature with a Timestamp in storage pannel. as like

{
    "Creators": "2021-12-21",
    "parseInt": "2021-12-22",
    "spaces": "2021-12-23"
}

Currently I'm looking for a way export this data or open it as new pannel to users can make their own word book.
I'm googling it but can't find clue yet.
Any helpful links or suggestion would be glad. thanks.

§
Posted: 23-12-2021

GM.getValue?

§
Posted: 23-12-2021

GM.getValue?

My mind was so foggy after non stop coding today.
It would be good to load with getValue and transit it to txt or something.
Thanks!

§
Posted: 23-12-2021
const downloadBtn = document.createElement('a');
const downloadData = '123';
const fileName = '321';

document.body.appendChild(downloadBtn);
downloadBtn.innerText = 'Download';

downloadBtn.addEventListener('click', () => {
  const blob = new Blob([downloadData], { type: 'text' });
  const url = URL.createObjectURL(blob);

  downloadBtn.href = url;
  downloadBtn.download = fileName;
});
§
Posted: 23-12-2021
Edited: 23-12-2021

I can't think of a script better than this one for you to study
https://greasyfork.org/en/scripts/424595-night-mode

This script uses all you are using, and you want the user to be able to see his current settings/words and edit them, and you want your script to save the new settings/words the user wrote in a menu to edit the dictionary, this is basically what this script I shared does, but not about words, it's about numbers and time, if you study it, you will understand how to create a settings page that save your users new words and settings.

This script is as short as yours.

§
Posted: 24-12-2021
const downloadBtn = document.createElement('a');
const downloadData = '123';
const fileName = '321';
...

I could handle with the problem.
I'll may refer to your code a lot in my futher scripts.
Thanks for the help!

§
Posted: 24-12-2021

I can't think of a script better than this one for you to study
https://greasyfork.org/en/scripts/424595-night-mode...

As a begginer, I coulnd't paid much my time to examine other peoples works but only piled up code on my own as inefficiently until now.
I see your scripts have good comments and good features that I'll may use a lot.
Thanks for the good examples to looking through.

Post reply

Sign in to post a reply.