Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

User scripts deleted after upgrade #213

Closed
jpillora opened this issue Jan 18, 2022 · 12 comments
Closed

User scripts deleted after upgrade #213

jpillora opened this issue Jan 18, 2022 · 12 comments

Comments

@jpillora
Copy link

System Information:

macOS or iOS version: macOS 12.0.1
Userscripts version: 4.0.9
Safari version: 15.1
Is this issue related to script injection? No
Did the test script (pasted above) successfully run on your machine? Yes

The extension had no scripts/styles after upgrading. Very sad since I didn't save them. I'll now symlink them into my iCloud drive though would be nice to recover them. Any tips? Note, I had to open Safari prefs and re-enable the extension - not sure if this had something to do with it.

@quoid
Copy link
Owner

quoid commented Jan 18, 2022

@jpillora

Dang, I am very sorry that happened to you.

I am assuming you used the default directory for saving your userscripts?

You can look in ~/Library/Containers/ and search for any directory that contains the word userscripts. There might be com.userscripts.macos or simply Userscripts or both.

In those directories, navigate to Data/Documents and look for a scripts folder. Any userscripts using the default save location will be stored there.

The default save location doesn't change between versions, so your userscripts shouldn't have been deleted. However if the container itself changed, it could appear as if your userscripts are deleted. If that is the case, hopefully the old container is still on your file system.

I'll now symlink them into my iCloud drive

You don't need to symlink, you can simply select that as you save location from the containing app. I use my iCloud drive as well, that way I can sync the changes I make on macOS to iOS.

Note, I had to open Safari prefs and re-enable the extension - not sure if this had something to do with it.

The v4.x update changed from Safari App Extensions API to Safari Web Extensions API. There's seems to be a lot of idiosyncrasies with the new api, like simply disappearing after updating.

@quoid
Copy link
Owner

quoid commented Jan 21, 2022

@jpillora just checking in, were you were able to located your userscripts?

@jpillora
Copy link
Author

jpillora commented Jan 21, 2022 via email

@jpillora
Copy link
Author

contains the word userscripts. There might be com.userscripts.macos or simply both

both sounds promising 🤞

@jpillora
Copy link
Author

No luck

m1 ~/Library/Containers/com.userscripts.macos.Userscripts-Extension/Data/Documents/scripts du -h .
  0B	.
m1 ~/Library/Containers/com.userscripts.macos/Data/Documents
m1 cd scripts
cd: The directory '/Users/jpillora/Library/Containers/com.userscripts.macos/Data/Documents/scripts' does not exist

@quoid
Copy link
Owner

quoid commented Jan 21, 2022

@jpillora

Dang, I am sorry that happened.

I am assuming you updated through the App Store, is that correct? What was the previous version?

It's my understanding that macOS should not be destroying app containers on update. I just went through the process on my test MBA and updated from v4.0.9 to v4.0.11 and the containers and script remained. On that machine I am on latest Big Sur, not Monterey. I did a screen recording, if you want to check it out feel free to email (address on profile page).

There's nothing in the code that deletes anything on update, so I am a bit lost here and unsure if this was just an unfortunate edge case or something more widespread.

I wish I could have been of more help.

@jpillora
Copy link
Author

jpillora commented Jan 22, 2022 via email

@quoid
Copy link
Owner

quoid commented Feb 24, 2022

This just happened to me.

My scripts were located in a folder in my iCloud drive and I have 3 devices sharing those scripts (macbook, iphone and ipad).

I was in Files.app on my iphone this evening and noted the scripts folder because I was sharing a userscript with someone. I successfully shared the file.

Several hours later I went on my macbook and noticed no files were loading and the directory was missing from the iCloud drive. I checked the iCloud trash directory by viewing hidden files (cmd + shift + .), and I saw it there.

I am not sure if this is an issue with Userscripts or the Files app, but I am reopening this so I know to dedicate time into seeing what's up. The only "trash methods" used in the codebase, off of the top of my head, on the swift side are here:

Note: This happened outside of an update, just normal usage.

Screen Shot 2022-02-23 at 9 18 54 PM

@quoid quoid reopened this Feb 24, 2022
@quoid
Copy link
Owner

quoid commented Feb 26, 2022

Another note, when this happened, I was having issues with iCloud in general. It was affecting Mail.app. I am not sure if this is related or not.

Screen Shot 2022-02-23 at 9 40 15 PM

@jpillora
Copy link
Author

jpillora commented Feb 26, 2022 via email

@quoid
Copy link
Owner

quoid commented Feb 26, 2022

maybe apple’s fault?

I am thinking that could be the cause. It certainly seemed strange to me that it was only that one folder, which happened to be the one I had selected for Userscripts though. However, coincidences do happen and it could be an upstream bug.

I wish I had known this when you reported the issue at first, but you can recover trashed files on iCloud for up to 30 days. You can view hidden files like I did or use iCloud.com. It's been over 30 days for you so I don't think anything would be recoverable, but if it ever happens again, you could try to recover anything lost.

@ACTCD
Copy link
Collaborator

ACTCD commented Oct 29, 2023

Since it cannot be fixed in this project.
Close this issue.
Maybe improved in the future in #424.

@ACTCD ACTCD closed this as completed Oct 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants