0

This opens a Zip code field. If I enter a Zip code manually a list of providers is shown. If I set the value with the script the list is not shown. So I am trying to simulate keypresses, but it is not working.

// ==UserScript==
// @name     titantv
// @version  1
// @include  https://www.titantv.com/*
// @grant    none
// ==/UserScript==

var create = document.getElementById('ctl00_Main_TVL_ctl00_Nav_ctl00_AddLineup');
create.click();

setTimeout(function(){
    var broadcast = document.getElementById('broadcast');
    broadcast.click();

    setTimeout(function(){
        var zip = document.getElementById('zipEntryInput');
        zip.dispatchEvent(new KeyboardEvent('keydown',{'key':'50'}));
    }, 2000);
}, 2000);
  • Try to focus it and use document.execCommand, [example](https://stackoverflow.com/a/57900849). – wOxxOm May 11 '20 at 16:06
  • This doesn't work and returns false: document.getElementById('zipEntryInput').focus();document.execCommand('InsertText', false, zipCode); But this returns true: document.queryCommandSupported('insertText'); – barrygood May 11 '20 at 17:48
  • I guess it means the element is neither an HTML input nor contenteditable. Try your original code but fix the parameters per [Is it possible to simulate key press events programmatically?](https://stackoverflow.com/q/596481) – wOxxOm May 11 '20 at 17:51
  • The element is a simple input field: I've tried many combinations of parameters to no avail. – barrygood May 11 '20 at 21:02

0 Answers0