add matching unwrap function
parent
96b1c19f0a
commit
052ac74ef7
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue