Skip to content

Instantly share code, notes, and snippets.

@penk
Last active June 9, 2018 08:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save penk/9461136 to your computer and use it in GitHub Desktop.
Save penk/9461136 to your computer and use it in GitHub Desktop.
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