【问题标题】:Is it possible to use xdotool to enter a web console command?是否可以使用 xdotool 输入 Web 控制台命令?
【发布时间】:2017-04-07 19:58:55
【问题描述】:

是否可以使用 xdotool 输入 web 控制台命令,如下命令:

$("#var2").css("move", - 44 + "deg")

【问题讨论】:

  • 我认为不会,因为 xdotool 只做你可以用键盘和鼠标做的事情......它不直接与浏览器通信......也许一种解决方法是让它进入Javascript 进入一个隐藏的文本字段并使用邪恶的 eval() 来执行它......!
  • 这听起来像XY Problem。您真正想在这里实现什么?找出更好的方法来解决您的问题试图解决的问题可能会更好。

标签: linux shell xdotool web-console


【解决方案1】:

可以,您可以使用 Web 控制台或地址栏。 这一步:

  • 专注于浏览器
  • 按 F12
  • 类型代码

这个使用 Web 控制台的示例 xdotool 脚本:

search --sync --onlyvisible --name "chrome"
windowactivate --sync
keydown F12
sleep 1
type --clearmodifiers --delay 10 --args 1 "document.getElementsByTagName('body')[0].style.backgroundColor = 'green'"
sleep 1
key Return
sleep 0.5
key F12

将脚本另存为“xdt.txt”,使用 xdotool 运行它

xdotool - < xdt.txt

【讨论】:

    猜你喜欢
    • 2011-08-26
    • 2022-06-14
    • 2023-03-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-08-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多