MCPcopy Index your code
hub / github.com/hoothin/UserScripts / dispatchTouchEvent

Function dispatchTouchEvent

Pagetual/pagetual.user.js:12523–12563  ·  view source on GitHub ↗
(ele, type)

Source from the content-addressed store, hash-verified

12521 mouseEvent = new PointerEvent("mouseup", eventParam);
12522 btn.dispatchEvent(mouseEvent);
12523 let dispatchTouchEvent = (ele, type) => {
12524 let touchEvent;
12525 try {
12526 touchEvent = document.createEvent('TouchEvent')
12527 touchEvent.initTouchEvent(type, true, true)
12528 } catch (err) {
12529 try {
12530 touchEvent = document.createEvent('UIEvent')
12531 touchEvent.initUIEvent(type, true, true)
12532 } catch (err) {
12533 touchEvent = document.createEvent('Event')
12534 touchEvent.initEvent(type, true, true)
12535 }
12536 }
12537 if (touchEvent) {
12538 try {
12539 touchEvent.targetTouches = [{
12540 pageX: 1,
12541 pageY: 1,
12542 clientX: 1,
12543 clientY: 1,
12544 target: btn
12545 }];
12546 touchEvent.touches = [{
12547 pageX: 1,
12548 pageY: 1,
12549 clientX: 1,
12550 clientY: 1,
12551 target: btn
12552 }];
12553 touchEvent.changedTouches = [{
12554 pageX: 1,
12555 pageY: 1,
12556 clientX: 1,
12557 clientY: 1,
12558 target: btn
12559 }];
12560 } catch (err) {}
12561 ele.dispatchEvent(touchEvent);
12562 }
12563 }
12564 dispatchTouchEvent(btn, "touchstart");
12565 dispatchTouchEvent(btn, "touchend");
12566

Callers 1

emuClickFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected