Example of Using Oxide with User Script
import QtQuick 2.0 | |
import com.canonical.Oxide 0.1 | |
WebView { | |
width: 800 | |
height: 600 | |
url: 'http://google.com' | |
context: WebContext { | |
userAgent: "Mozilla/5.0 (Ubuntu; Tablet) WebKit/537.21" | |
userScripts: [ | |
UserScript { | |
context: "oxide://osk/" | |
url: Qt.resolvedUrl("userscript.js") | |
incognitoEnabled: true | |
matchAllFrames: true | |
} | |
] | |
} | |
messageHandlers: [ | |
ScriptMessageHandler { | |
msgId: "inputmethod" | |
contexts: ["oxide://osk/"] | |
callback: function(msg, frame) { | |
console.log(msg.args.type, msg.args.state); | |
} | |
} | |
] | |
} |
window.document.addEventListener('click', (function(e) { | |
if (e.srcElement.tagName === ('INPUT'||'TEXTAREA')) { | |
var inputContext = new Object({'type':'input', 'state':'show'}) | |
oxide.sendMessage('inputmethod', inputContext); | |
} | |
}), true); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment