Wingysam / Christmas-Community

Christmas lists for families
GNU Affero General Public License v3.0
201 stars 39 forks source link

Share To using Apple Shortcuts #132

Open bmpreston opened 1 month ago

bmpreston commented 1 month ago

Is there anyway to essentially create an apple shortcuts app, that I can put into the Share To to allow me to 'share' a new item into the webapp?

Wingysam commented 1 month ago

It could technically be done I think! It could break if Christmas Community changes how adding things works in the future though. I'll give it a go and let you know what I come up with.

Wingysam commented 1 month ago

I got it working: https://www.icloud.com/shortcuts/f437f6331c794ce9a3ceeb68d7b95dfe

Keep in mind that if the way the page works changes in the future this will stop working. It also requires you to extract the Cookie header from the site.

bmpreston commented 1 month ago

This is amazing, except can you help point me to the cookie header? Is this the same from device to device, based on the logged in user? ie if I find it on my mac, and transfer this to my iphone, would it still work?

Thank you for you effort!

Wingysam commented 1 month ago

You're welcome!

The cookie from any device will work as long as it's signed into your account. You can use the network device tools on your Mac to get the cookie, or you can use this JavaScript in the console on your Mac:

console.log(document.cookie)
bmpreston commented 1 month ago

Am I looking for the christmas_community.connect.sid?

I am stealing all of the code that the console.log dumped, and putting it into chatgpt. I am horribly mentally underpowered to handle this information. 😂

--I might have Asperger's but I ain't no damned genius... 🤪

Wingysam commented 1 month ago

Yes, that's the cookie you're looking for. You can technically just dump the entire blob from the console.log, but if you have other stuff running on the same IP/port it'll have excess data. The answer to the prompt you get for the cookie should look like this:

christmas_community.connect.sid=<some random data>
bmpreston commented 1 month ago

That SID should remain during browser restarts, server and docker restarts, etc? I might only find it not working if you alter your code?

If I set this as a text value in the Shortcut, it should forever remain until the end of time, and the dinosaurs reclaim this planet?

If you think that's true, you are awesome. I need a link to your support/send a tip page.

Thank you!

Wingysam commented 1 month ago

I believe as long as you use it at least once every week (or whatever you set SESSION_MAX_AGE to) and don't use the "Log out" button on the browser you harvested it from, it will never expire.

If I'm mistaken, I can make a system for long-lived auth cookies that don't expire.

bmpreston commented 1 month ago

That would be ballin'.

Wingysam commented 1 month ago

Let me know if it's still working in a week please! If you'd like to donate, the link is near the bottom of the README.

bmpreston commented 1 month ago

Doesn't seem to work. I added the url, added what I believe is the cookie per the SID grab, and nothing when I visit and 'share from Amazon'. Lemme know if you have other suggestions...

jskiddie commented 1 month ago

@bmpreston wingysams shortcut works for for me :) cookie comes in the form of:christmas_community.connect.sid=tfzdquguzutBu2t37uzg234Kdgfksdfsd and the url in the form of https://wishes.example.com/wishlist/john I have created an improved/easier to use version, provided you are able to install (and if necessary link) the two other shortcuts it depends on as well as scriptable: https://itunes.apple.com/us/app/scriptable/id1405459188 Main Shortcut: "Christmas Community v2.2.shortcut"(1938F4C6F26607CC856FFFD20CB2BDDA) Two dependent shortcuts: "M.D. mkdir -p.shortcut"(4762670BF9C7BF0D5ECB8906D90EDDDA), "M.D. check local path exists bool opti.shortcut"(B2AC4C290D9DE70FD1D097AD49536F47) all md5 ThreeShortcutsv0.0.3.zip