Compare commits
No commits in common. "4ea99cd4f8e043677673e681496ffbda3397c97f" and "91c93f1fe8489ef524652e40b7189816eb27ec9e" have entirely different histories.
4ea99cd4f8
...
91c93f1fe8
|
@ -57,9 +57,6 @@ function mousemove($main, $control, $options) : bool
|
||||||
$targetPos = $control->getElementRect($element);
|
$targetPos = $control->getElementRect($element);
|
||||||
$targetX = $targetPos['x'] + $targetPos['width'] / 2;
|
$targetX = $targetPos['x'] + $targetPos['width'] / 2;
|
||||||
$targetY = $targetPos['y'] + $targetPos['height'] / 2;
|
$targetY = $targetPos['y'] + $targetPos['height'] / 2;
|
||||||
$scroll = $control->getScrollPosition();
|
|
||||||
$targetX -= $scroll[0];
|
|
||||||
$targetY -= $scroll[1];
|
|
||||||
// echo "move $element - $tokens[1] $targetX $targetY\n";
|
// echo "move $element - $tokens[1] $targetX $targetY\n";
|
||||||
$mouseX = $main->getMouseX();
|
$mouseX = $main->getMouseX();
|
||||||
$mouseY = $main->getMouseY();
|
$mouseY = $main->getMouseY();
|
||||||
|
@ -101,24 +98,6 @@ function mousemoverel($main, $control, $options)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* scroll
|
|
||||||
*
|
|
||||||
* @param \ScriptedBrowser\Main $main
|
|
||||||
* @unused-param $main
|
|
||||||
* @param \ScriptedBrowser\Control $control control interface
|
|
||||||
* @unused-param $control
|
|
||||||
* @param array<string,mixed> $options options
|
|
||||||
* @return bool always true
|
|
||||||
*/
|
|
||||||
function scroll($main, $control, $options)
|
|
||||||
{
|
|
||||||
$amount = $options['parameter'];
|
|
||||||
$delay = $options['delay'];
|
|
||||||
$control->scroll(intval($amount), floatval($delay));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* sleep
|
* sleep
|
||||||
*
|
*
|
||||||
|
|
|
@ -174,16 +174,6 @@ class Control
|
||||||
return (!is_array($url)) ? $url : '';
|
return (!is_array($url)) ? $url : '';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* get scroll position
|
|
||||||
*
|
|
||||||
* @return [int,int] current scroll position
|
|
||||||
*/
|
|
||||||
public function getScrollPosition()
|
|
||||||
{
|
|
||||||
return $this->executeScript('return [window.pageXOffset, window.pageYOffset];');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* move mouse to absolute position
|
* move mouse to absolute position
|
||||||
*
|
*
|
||||||
|
@ -283,23 +273,6 @@ class Control
|
||||||
@socket_close($socket);
|
@socket_close($socket);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* scroll given amount
|
|
||||||
*
|
|
||||||
* @param int $amount
|
|
||||||
* @param float $delay delay per scroll
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function scroll($amount, $delay)
|
|
||||||
{
|
|
||||||
$dir = $amount > 0 ? 5 : 4;
|
|
||||||
$count = abs($amount);
|
|
||||||
for ($i = 0; $i < $count; ++$i) {
|
|
||||||
fwrite($this->xdotool, "click $dir\n");
|
|
||||||
usleep($delay * 1000 * 1000);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* find elements with given css selector
|
* find elements with given css selector
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue