Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

执行一段JavaScript脚本如何获取返回值的问题 #303

Open
popstar2023 opened this issue Feb 14, 2024 · 1 comment
Open

执行一段JavaScript脚本如何获取返回值的问题 #303

popstar2023 opened this issue Feb 14, 2024 · 1 comment

Comments

@popstar2023
Copy link

执行一段JavaScript脚本如果要获取返回值,需要用return开头,但是有时候js代码会很多,直接用return开头可能有时候没有办法实现,特别是中间有声明和使用变量的时候,这个时候看提示会使用是否将执行后的输出/返回值作为字段记录:选择否(任可在任意操作中用F["操作名"]表示此命令返回值,这个用不明白,我现在的需求是执行一段js,我想把这段js的输出或者返回值保存成字段,这个能实现么?
比如我在某个页面执行一段js
const ogImages = [];
const metaTags = document.querySelectorAll('meta[name="og:image"]');
metaTags.forEach(tag => {
ogImages.push(tag.getAttribute('content'));
});
const ogImagesString = ogImages.join('\n');
console.log(ogImagesString);
return ogImagesString;

我想把返回的ogImagesString这个值保存成字段,这个能实现么?

@popstar2023
Copy link
Author

貌似用self.outputParameters["'执行JavaScript"]可以取到'执行JavaScript的返回值,还有其他方式么?
再就是Filed["字段名"]这个除了在重新输入中可以使用,还有哪些场景可以使用?我看了你很多视频和文档,还是有点搞不清楚
PS:self.后面的变量名,我看了你的一些源码,发现很多self.变量名可以直接使用,如果我自定义的变量名和你重复了,这个有什么影响,怎么避免,或者能不能开放一些出来给我们直接使用呢?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant