AlttiRi / twitter-click-and-save

[userscript] Adds buttons to save images and videos in Twitter, also does some other enhancements. (Twitter image and video downloader)
https://greasyfork.org/en/scripts/430132
GNU General Public License v3.0
104 stars 9 forks source link

[Question] Export already saved tweet database to another browser? #17

Closed biggestsonicfan closed 2 years ago

biggestsonicfan commented 2 years ago

I'm upgrading my hard disk and doing a fresh distro install. I'd like to be able to transfer which tweets have already been saved to my new Firefox install but I'm not really sure where the tampermonkey data is stored for tcas.

Is it a straightforward process and my google-fu is just failing me?

AlttiRi commented 2 years ago

I currently did not implemented this https://github.com/AlttiRi/twitter-click-and-save/issues/12

It stores the data in LocalStorage. You can manually copy it from the old browser to the new one. See "ujs-..." values.

OK, I will write the temporal script to simplify the manual work.

AlttiRi commented 2 years ago
The outdated version To export: ```js let exportObject = [ "ujs-click-n-save-settings", "ujs-images-history-by", "ujs-twitter-downloaded-images-names", "ujs-twitter-downloaded-image-tweet-ids", "ujs-twitter-downloaded-video-tweet-ids" ].reduce((acc, name) => { const value = localStorage.getItem(name); if (value === null) { return acc; } acc[name] = localStorage.getItem(name); return acc; }, {}); downloadBlob(new Blob([JSON.stringify(exportObject)]), "ujs-c'n's-export.json"); function downloadBlob(blob, name, url) { const anchor = document.createElement("a"); anchor.setAttribute("download", name || ""); const blobUrl = URL.createObjectURL(blob); anchor.href = blobUrl + (url ? ("#" + url) : ""); anchor.click(); setTimeout(() => URL.revokeObjectURL(blobUrl), 30000); } ``` To import: ```js let input = document.createElement("input"); input.type = "file"; input.accept = "application/json"; document.body.prepend(input); input.addEventListener("change", async event => { const json = JSON.parse(await input.files[0].text()); console.log("json", json); globalThis.json = json; Object.entries(json).forEach(([key, value]) => { localStorage.setItem(key, value); }); }); input.click(); ```

The new version is here: https://github.com/AlttiRi/twitter-click-and-save/issues/12#issuecomment-1326920033

biggestsonicfan commented 2 years ago

OH whoops, didn't see the issue was already open, LOL! Closing as duplicate!