[英]Chrome Extension keypress for Skype Web
I want to write a Chrome Extension that can send messages using Skype for web ( https://web.skype.com/en/ ). 我想编写一个可以使用Skype for web( https://web.skype.com/en/ )发送消息的Chrome扩展程序。 I can get the text in the textarea but I can't get it to trigger the Enter key. 我可以在文本区域中获取文本,但是无法触发Enter键。 How to archive this? 如何存档?
The extension gets loaded ok, and puts a text in the input field, but there it stops. 扩展名可以正常加载,并在输入字段中输入文本,但是在此停止。 I also tried firing change events and input events. 我还尝试触发更改事件和输入事件。 But nothing happens. 但是什么也没发生。
I'm using a wait function because Skype takes a while to load. 我使用的是等待功能,因为Skype需要一段时间才能加载。
My manifest.json 我的manifest.json
{ "manifest_version": 2, "name": "SkypeTest", "version": "0.0.1",
"content_scripts": [{"matches": ["https://web.skype.com/*"],
"js": ["jquery-2.1.4.min.js", "skypeTest.js"]}]}
My skypeTest.js 我的skypeTest.js
;(function() {
var e = jQuery.Event( 'keydown', { which: 13 } );
function init(){
console.log('Script running');
var wait = function() {
var txtArea = $("textarea[name='messageInput']");
if (txtArea.is(':visible')) {
clearTimeout(waiting);
txtArea.val('Hello Skype');
txtArea.trigger('focus').trigger(e);
}
};
var waiting = setInterval(wait, 5000);
}
init();
})();
This is the input field 这是输入字段
<textarea tabindex="10010" maxlength="2000" data-bind="value: messageBody, css: {hide: !isEnabled()},
valueUpdate: ['afterkeydown','propertychange','input'],
event: { keypress: handleKeyPress, keydown: handleKeyDown, input: handleInput,
focus: onFocus, blur: onBlur, paste: onPaste }, hasFocus: chatInputFocus,
l10n_attr: {'placeholder': 'area_text_insertText'}, attr: { 'aria-label': label },
template: { afterRender: handleFocus }" name="messageInput" class="inputField fontSize-p" placeholder="Type a message here"
aria-label="Chat input" style="height: 30px;"></textarea>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.