Last active
June 9, 2018 08:46
-
-
Save penk/9461136 to your computer and use it in GitHub Desktop.
Example of Using Oxide with User Script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
} | |
} | |
] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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