ubuntu: implement inject* functions

This commit is contained in:
Maxim Ermilov
2014-10-18 02:36:31 +04:00
parent 88b71b3a57
commit e5d6d6f69a
4 changed files with 55 additions and 17 deletions
+24
View File
@@ -55,6 +55,19 @@ Rectangle {
}
}
property string usContext: "oxide://main-world/2"
function executeJS(scId, code) {
var req = _view.rootFrame.sendMessage(usContext, "EXECUTE", {code: code});
req.onreply = function(response) {
var code = 'cordova.callback(' + scId + ', JSON.parse(\'' + JSON.stringify(response.result) + '\'))';
console.warn(code);
cordova.javaScriptExecNeeded(code);
console.warn("RESP:" + JSON.stringify(response));
};
}
WebView {
width: parent.width
y: urlEntry.height
@@ -64,5 +77,16 @@ Rectangle {
onLoadingStateChanged: {
root.exec("InAppBrowser", "loadFinished", [_view.loading])
}
context: WebContext {
id: webcontext
userScripts: [
UserScript {
context: usContext
emulateGreasemonkey: true
url: "InAppBrowser_escapeScript.js"
}
]
}
}
}