EltonChou / TwitterMediaHarvest

Download twitter media with only one-click.
https://chrome.google.com/webstore/detail/media-harvest-twitter-med/hpcgabhdlnapolkkjpejieegfpehfdok
MIT License
374 stars 32 forks source link

[FEATURE] Export & Import Download History #139

Closed Explorare closed 4 months ago

Explorare commented 4 months ago

It would be great if I could export the download history of this extension from MS Edge to Firefox, which is my main Web browser. And it would also be useful while transferring data to a new computer. With download history every tweet with a media that have been downloaded in the past will show a yellow icon to prevent duplicate. But a local deduplicate software will do the same job. So, I think this feature has a low priority and doesn't affect the main function.

EltonChou commented 4 months ago

It can export and import download history.

The exported data can be droped on the histsory table to import, but this was for development usage and it was disabled in production build. So you need to run the script in options page's console by yourself.

Backup your history before importing it.

Change chrome to browser in firefox.

Export:

await chrome.runtime.sendMessage({action: 4})

Import:

await chrome.runtime.sendMessage({action: 5, data: <JSON_STRING_DATA>})

Related code

https://github.com/EltonChou/TwitterMediaHarvest/blob/4976253a70096f6417e2279b093fe399c16ea570/src/service_worker/sw.ts#L110-L129 https://github.com/EltonChou/TwitterMediaHarvest/blob/4976253a70096f6417e2279b093fe399c16ea570/src/pages/components/History.tsx#L299-L316

Explorare commented 4 months ago

The function you provide worked as intended for me. And I'd like to append a note for others who want to do the same thing, use online tool to stringify the JSON file generated from the export command to escape any special characters (eg. ' .), or the JSON parser in browser will not happy with it.

Thanks for your kind help and the time and effort to create this useful extension. Have a good day. 😉

EltonChou commented 4 months ago

I am glad that you like this extension. 👍