Skip to content
This repository has been archived by the owner on Jan 22, 2022. It is now read-only.

Commit

Permalink
add custom user scripts for webapps defined in webapp-properties.json (
Browse files Browse the repository at this point in the history
  • Loading branch information
balcy authored and UniversalSuperBox committed Feb 8, 2019
1 parent 490782b commit 7e0a951
Showing 1 changed file with 37 additions and 3 deletions.
40 changes: 37 additions & 3 deletions src/app/webcontainer/webapp-container.qml
Original file line number Diff line number Diff line change
Expand Up @@ -179,9 +179,43 @@ BrowserWindow {
focus: true

onLoaded: {
var context = item.currentWebview.context
onlineAccountsController.setupWebcontextForAccount(context)
item.currentWebview.settings.localContentCanAccessRemoteUrls = localContentCanAccessRemoteUrls
var context = item.currentWebview.context;
onlineAccountsController.setupWebcontextForAccount(context);
item.currentWebview.settings.localContentCanAccessRemoteUrls = localContentCanAccessRemoteUrls;

loadCustomUserScripts();
}

function loadCustomUserScripts() {

var scripts = [];

// app specific user scripts
var idx = webappModel.getWebappIndex(getWebappName());
var customScripts = webappModel.data(idx, UnityWebApps.UnityWebappsAppModel.Scripts);

if (customScripts.length === 0)
{
return;
}

var i;
for (i = 0; i < customScripts.length; i++)
{
var script = Qt.createQmlObject('import QtWebEngine 1.7; WebEngineScript {}', webappViewLoader);
script.sourceUrl = customScripts[i];
script.injectionPoint = WebEngineScript.DocumentCreation;
script.worldId = WebEngineScript.MainWorld;
script.runOnSubframes = true;
scripts.push(script);
}

// global user scripts
for (i = 0; i < item.currentWebview.profile.userScripts.length; i++) {
scripts.push(item.currentWebview.profile.userScripts[i]);
}

item.currentWebview.profile.userScripts = scripts;
}
}

Expand Down

0 comments on commit 7e0a951

Please sign in to comment.