-
Notifications
You must be signed in to change notification settings - Fork 40
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
Comments
No, currently this is not implemented yet, and I probably have no time to do it in this year. |
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 ^^ |
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. I believe the logic of ChromeXt/app/src/main/java/org/matrix/chromext/hook/WebView.kt Lines 76 to 78 in b969aaf
You may try to understand it and thus contribute to ChromeXt ;) |
I think it is possible to use Page.addScriptToEvaluateOnNewDocument to setup event listeners on each iframe and execute codes from the main frame. |
You can inject into frames now, the following scripts fixes font problems for // ==UserScript==
// @name Font Loader
// @namespace JingMatrix
// @match https://play.google.com/books/reader?id=*
// @match https://books.googleusercontent.com/books/reader/frame*
// @run-at document-idle
// @grant GM_addStyle
// @grant frames
// @description Fix the problem of custom font loading in browsers on Android 15+
// ==/UserScript==
if (origin == "https://books.googleusercontent.com") {
console.log("Loaded in the frame");
const font_lists = [
"STKaiti",
"STFangsong",
"STXingkai",
"STXihei",
"STLiti",
];
const style = font_lists
.map((font) => `@font-face { font-family: ${font}; src: local(${font}); }`)
.join("\n");
GM_addStyle(style);
} |
We use `Page.navigate` API to implement a simple frames injections, which might not work as expected when the script size is nearly 2M. `@noframes` is also implemented, which is by default effectively true for most scripts because developers must `@grant frames` in the main page to inject into its frames. Close #136 as completed.
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,
The text was updated successfully, but these errors were encountered: