Compare commits

..

2 Commits

Author SHA1 Message Date
Sascha Nitsch 052ac74ef7 add matching unwrap function 2024-09-09 18:43:35 +02:00
Sascha Nitsch 96b1c19f0a animate relative mouse movements as well 2024-09-09 18:43:06 +02:00
2 changed files with 31 additions and 2 deletions

View File

@ -177,7 +177,15 @@ function _mousemoveaction($main, $control, $options, $targetX, $targetY)
function mousemoverel($main, $control, $options)
{
$coord = explode(" ", $options['parameter']);
$control->mousemoveRel(intval($coord[0], 10), intval($coord[1], 10));
$x = intval($coord[0], 10);
$y = intval($coord[1], 10);
if (array_key_exists('jump', $options)) {
$control->mousemoveRel($x, $y);
} else {
$mouseX = $main->getMouseX();
$mouseY = $main->getMouseY();
_mousemoveaction($main, $control, $options, $mouseX + $x, $mouseY + $y);
}
return true;
}

View File

@ -9,7 +9,28 @@
namespace ScriptedBrowser\Commands;
/**
* wrap given element in a <span id="">
* unwrap given element from <span data-id="">
*
* @param \ScriptedBrowser\Main $main main instance
* @param \ScriptedBrowser\Control $control control interface
* @unused-param $control
* @param array<string,mixed> $options options
* @return bool true on success
*/
function spanunwrap($main, $control, $options)
{
$id = $options['parameter'];
$js = '
const node = document.querySelector("span[data-id=\"' . $id . '\"]");
const text = node.parentNode.innerHTML;
node.parentNode.innerHTML = text.replace(node.outerHTML, node.innerHTML);
';
$control->executeScript($js);
return true;
}
/**
* wrap given element in a <span data-id="">
*
* @param \ScriptedBrowser\Main $main main instance
* @param \ScriptedBrowser\Control $control control interface