lisonge / vite-plugin-monkey

A vite plugin server and build your.user.js for userscript engine like Tampermonkey, Violentmonkey, Greasemonkey, ScriptCat
MIT License
1.39k stars 71 forks source link

When debugging on IOS GM functions are undefined #144

Open Thorvarium opened 7 months ago

Thorvarium commented 7 months ago

import { GM_setValue, GM_getValue, GM_info } from "$"; returns undefined while on android it returns correctly

To connect iphone to the local server I am using "vite-plugin-mkcert" and installing the PEM SSL certificate on the iphone. Same for android

lisonge commented 7 months ago

When debugging on IOS

What is your userscript manager ?

and I don't have an ios device, I may not be able to give you a solution, you can pr if you can solve it

Thorvarium commented 7 months ago

When debugging on IOS

What is your userscript manager ?

and I don't have an ios device, I may not be able to give you a solution, you can pr if you can solve it

The scriptmanager on iphone is an app called "Stay" that also let you add scripts. I am not sure how to start debugging. How does it inject the GM functions normally? It does work on iphone after building. The issue is during dev serve

lisonge commented 7 months ago

I am not sure how to start debugging

You can check the console full output

Thorvarium commented 7 months ago

I am not sure how to start debugging

You can check the console full output

I think that safari doesn't like setting properties in the Window itself. The only way that I could pass GM inside is setting inside the unsafe Document. Even when I set other property names, monkeyWindow.XXX is always undefined

bbb651 commented 5 months ago

I highly recommend this app for userscripts on iOS, it's open source, completely free without ads and has support for GM. apis.

Thorvarium commented 5 months ago

I highly recommend this app for userscripts on iOS, it's open source, completely free without ads and has support for GM. apis.

I will try again soon, I did try it last time and had the same issues with passing gm from monkey. Also, I am not a fan how you need to put things inside the Icloud folder, it is a lot more complicated to give user instalation instructions

Thorvarium commented 5 months ago

If I am not mistaken, the UserScript app is even more complicated to debug monkey because you can't pass at all the gm functions to unsafe. You need to create a messaging structure and pass messages between the windows and use the gm funcions inside the UserScript part of the code

bbb651 commented 5 months ago

I highly recommend this app for userscripts on iOS, it's open source, completely free without ads and has support for GM. apis.

I will try again soon, I did try it last time and had the same issues with passing gm from monkey. Also, I am not a fan how you need to put things inside the Icloud folder, it is a lot more complicated to give user instalation instructions

It doesn't have to be an iCloud folder it can be any folder (e.g a local folder, a different cloud storage provider), and I wouldn't say it's "a lot more complicated", the files app isn't a new thing on iOS and even people who aren't familiar with it know what files are. It literally 2 steps: save the file to a folder, select the folder.

Thorvarium commented 5 months ago

I highly recommend this app for userscripts on iOS, it's open source, completely free without ads and has support for GM. apis.

I will try again soon, I did try it last time and had the same issues with passing gm from monkey. Also, I am not a fan how you need to put things inside the Icloud folder, it is a lot more complicated to give user instalation instructions

It doesn't have to be an iCloud folder it can be any folder (e.g a local folder, a different cloud storage provider), and I wouldn't say it's "a lot more complicated", the files app isn't a new thing on iOS and even people who aren't familiar with it know what files are. It literally 2 steps: save the file to a folder, select the folder.

I've tested here, works good on the compiled script. But it doesn't work on run dev mode to debug. They have protections to not allow GM functions to be sent thru the window from what I've been reading on their github