Benjol / SE-AutoReviewComments

AutoReviewComments - Pro-forma comments for SE
http://stackapps.com/q/2116
98 stars 39 forks source link

[Feature Request] Syncing #174

Open SmartManoj opened 5 years ago

SmartManoj commented 5 years ago

Use GM_setValue instead localStorage to sync between browsers

makyen commented 5 years ago

GM_setValue and GM.setValue don't permit syncing between browsers. They would, however, permit syncing comments between Stack Exchange sites. That could also be handled in other ways.

Note that there are incompatibilities in this API between the different userscript managers. Specifically, Greasemonkey 4 is significantly different. This can be worked around by using a shim.

However, that userscript storage would be completely unavailable to the browser extension version(s) of this script. Thus, those versions would need to be accommodated in some manner. While something could be done to allow the browser extension version to store data in extension storage, if userscript storage and extension storage were used exclusively, there would be no way to share comment data between the userscript version and browser script versions. Currently, with using localStorage, you should be able to switch between the userscript version and browser extension versions without loosing your comment data.

SmartManoj commented 5 years ago

For tampermonkey, In @shog repo (SOX) he used GM_setValue for Edit reasons feature. The data are stored in Google Drive when syncing

makyen commented 5 years ago

So, what you're really asking for is that you want to sync to different Chrome browsers on different devices when using Tampermonkey (or maybe? all browsers the user runs Tampermonkey on with "Script Sync" enabled).

There's nothing inherent that prevents using userscript storage, other than the issue that people will no longer be able to share data between the browser extension versions of this script and the userscript versions. You'll probably need to get buy-in that loosing that feature is acceptable. It's unclear how important people consider that to be, but it's definitely something I've used, once. Alternately, you could create some method of sharing data, but it wouldn't be automatic.

Keep in mind:

The project is currently not being actively maintained.
If you submit a PR, there's a good chance it'll be merged.

You will need to write the code to transition everyone from using localStorage to using userscript storage (i.e. copying their current comments to userscript storage). You'll need to do so for every different SE domain (main sites and meta sites). Users, currently, potentially have different comment sets in every single SE domain + every meta site. You'll have to assume that transitioning to using userscript storage is an ongoing process, that may, at any time, encounter a SE domain that has not yet been transitioned. [I've done this in another script, it's not all that difficult.] When doing this, it would be a good time to transition from storing comments as HTML to storing them as Markdown.

You'll need to develop a method to keep comments both separate by domain and ones that are shared across all domains, or even permit the user to select which domains each comment is shared with (although this last could be cumbersome with 340+domains (approx 170 SE sites + a meta site for each) for each comment).

Remember that the script targets use in any userscript manager, not just Tampermonkey, and as a browser extension, so any use of the userscript API must both be compatible across all userscript managers and have a shim that allows use as a browser extension.

Note: All of the above isn't all that difficult. I've considered doing it from time to time over the last few years, because it would enable a feature I'd like to see: having at least some comments that are global across all Stack Exchange sites, rather than having the list be completely separate per site (i.e. there are identical comments I make on multiple sites, which I'd like to not have to specifically copy from one site to another when I change).

SmartManoj commented 5 years ago

the issue that people will no longer be able to share data between the browser extension versions of this script and the userscript versions.

Mostly people have single userscript extension & single version of a script.

makyen commented 5 years ago

That's sort-of true. The auto-update/check feature actually results in it being common that people, unknowingly, run more than one version of the script, because the current version of the script is downloaded and run for every load of a page on which the script runs, regardless of if the user has updated their installed version. This is a separate issue.

The feature currently exists that someone could switch between the userscript and the browser extension version of the script without loosing data, due to the comment data being stored in localStorage. If that's a feature that some people use, who knows. But, it's something that needs to at least be considered when moving in the direction you desire.

SmartManoj commented 5 years ago

If they switch , we could export & import

makyen commented 5 years ago

Obviously, there are options. I haven't said it's a deal-breaker, just A) that it's a feature that exists now; B) that we don't know how much it is used; and C) that it's something that needs to be considered by more than just the person writing the code, if it's a feature that will be eliminated.