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

Userscripts not loading in iframes #136

Open
gpourbaix opened this issue Nov 21, 2023 · 3 comments
Open

Userscripts not loading in iframes #136

gpourbaix opened this issue Nov 21, 2023 · 3 comments
Labels
enhancement New feature or request

Comments

@gpourbaix
Copy link

Hello

Thanks for you module, it's working very nicely.

I have noticed that userscripts are not invoked in iframes.
Is it possible to do something about it ?

Best regards,

@JingMatrix JingMatrix added the enhancement New feature or request label Nov 21, 2023
@JingMatrix
Copy link
Owner

No, currently this is not implemented yet, and I probably have no time to do it in this year.
For anyone who is interested in implementing this function, please refer to my commenst (the fourth point):
#104 (comment)

@gpourbaix
Copy link
Author

Thank for your reply. I did not manage to use CDP in iframe and i felt that it was less stable for main pages.

Just an idea : maybe you could hook shouldInterceptRequest to inject the userscript ? I found an example on stackoverflow :  https://stackoverflow.com/questions/68984756/how-do-i-inject-javascript-to-an-iframe-from-java-code-into-an-android-webview

I'm not an android developper even less an xposed module developper so it's too difficult to do it myself, i've already had a hard time just to compile the code ^^

@JingMatrix
Copy link
Owner

Once you have configured properly the JDK version (see #125), it should be easy to compile.

As for your idea, it is indeed given in the issue of which I cited my own comment above, though the issue was written in Chinese.
If you are using a WebView browser, you can try hook the shouldInterceptRequest method, see the file
WebView.kt .
(As for chromium browsers, one has to use CDP.)

I believe the logic of WebView.kt is fairly clear, where I hooked the onPageStarted method:

findMethod(ViewClient!!, true) { name == "onPageStarted" }
// public void onPageStarted (WebView view, String url, Bitmap favicon)
.hookAfter { onUpdateUrl(it.args[1] as String, it.args[0] as WebView) }

You may try to understand it and thus contribute to ChromeXt ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants