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

Cannot inject custom js in webapps #124

Closed
mymike00 opened this Issue Dec 2, 2018 · 5 comments

Comments

Projects
None yet
4 participants
@mymike00
Copy link

mymike00 commented Dec 2, 2018

I have a plain webapp (no qml at all, I have Exec=webapp-container in the .desktop file) and a file called webapp-properties.json which calls a custom script.
the code in this custom script was executed with oxide, but not anymore with morph

@cibersheep

This comment has been minimized.

Copy link

cibersheep commented Dec 10, 2018

There's a workaround and is using a qml with a webview and embed the js as a UserScript
In the import area you could:

import QtWebEngine 1.7 as Oxide

And in a Page element

WebContext {
	id: webcontextIF

        userScripts: [
            Oxide.WebEngineScript {
                id: cssinjection
                injectionPoint: WebEngineScript.DocumentCreation
                sourceUrl: Qt.resolvedUrl("js/cssinjection.js")
                worldId: WebEngineScript.MainWorld
            }
	]
}

And the webview:

WebView {
	id: webview

	context: webcontextIF
	url: 'https://whatever'
}
@mymike00

This comment has been minimized.

Copy link
Author

mymike00 commented Dec 11, 2018

Thanks, I'll try that workaround, but I highly prefer not using qml in simple webapp like mine...

@balcy

This comment has been minimized.

Copy link
Collaborator

balcy commented Dec 22, 2018

do you have an example of an app using it ? I've found hints to webapp-properties.json in the source code of morph, but not understood how the properties really work.

@mymike00

This comment has been minimized.

Copy link
Author

mymike00 commented Dec 28, 2018

my .desktop has

Exec=webapp-container --webappModelSearchPath=. --store-session-cookies --webappUrlPatterns=https?://www.mywebsite.com/* https://www.mywebsite.com/mypath %u

.apparmor is

{
    "template": "ubuntu-webapp",
    "policy_groups": [
        "keep-display-on",
        "networking",
        "webview"
    ],
    "policy_version": 1.3
}

then I have a file called webapp-properties.json

{
    "includes": ["https://www.mywebsite.com:*/*"],
    "name": "ExtendedWebappProperties",
    "scripts": ["myscript.js"],
    "domain":"",
    "homepage":""
}

and obviously a script called myscript.js

@UniversalSuperBox

This comment has been minimized.

Copy link
Member

UniversalSuperBox commented Feb 8, 2019

Closed via #140

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.