0

我正在尝试输出一些关于 DOM 树中节点属性的非常详细的摘要信息。几年前,我编写了一个浏览器扩展程序,它创建了一个新窗口并在那里编写了输出;该扩展不再与现代版本的 Firefox 兼容,因此我尝试将其移植到 Greasemonkey 脚本中,而不是编写一个全新的扩展。不幸的是,跨域脚本策略似乎阻止我向我创建的窗口实际写入任何内容。我有两个问题: 1. 有没有更好的方法可以为一个警告框输出过多的文本,从而可以复制部分或全部,而不需要修改原始页面的 DOM 树?2. 如果没有,我如何创建一个窗口并将文本从 Greasemonkey 脚本输出到它?

顺便说一句,我正在运行当前版本的 Greasemonkey。

4

1 回答 1

0
  1. Is there a better way to output too much text for an alert box, so that some or all can be copied, without modifying the original page's DOM tree?

You can use shadow DOM to create a popup box that is isolated from the original CSS & JS.

  1. If not, how do I create a window and output text to it from a Greasemonkey script?

AFA user-scripts, a new window is a new page. It will be a lot more work if you need to pass data to that window from a user-script. Therefore option 1 would be recommended.

于 2020-11-11T11:50:22.833 回答