Bookmarklet 重定向到文件输出的 url

问题描述 投票:0回答:1

我有一个 makefile,其 url 类似于

http://{server hosting cluster resource}:{PORT}/?tkn={randomly generated token}
我的目标是编写一个书签来运行此文件,获取输出并将 Firefox 重定向到该 url。

我已经能够获得一个节点终端来运行以下代码并记录我想要的网址。

> process.chdir('path/to/makefile/directory')
> var exec = require('child_process').exec
> exec('make url', function(error, stdout, stderr) { code_url = stdout.split(':\n')[1].trim(); });
> code_url

这确实给出了网址。问题是我似乎无法找到在浏览器中执行此操作的方法。 我不是最熟悉浏览器开发,无法执行该文件。似乎 process 和 require 在 Firefox 设置中都不存在,我还不明白为什么。

我确实知道我最终会得到接近于:

javascript:(function() {/* some code that will pipe the output of my makefile to a variable */; window.open(url)}

我只需要一些帮助从第一个代码块到第二个代码块。

我也尝试过做一个

make -f /full/path/to/file url
,但这也不起作用,这就是导致我更改进程目录的原因。

研究删节: [在node.js中执行并获取shell命令的输出][1] [1]:https://stackoverflow.com/questions/12941083/execute-and-get-the-output-of-a-shell-command-in-node-js [如何在 JavaScript 中执行 shell 命令][2] [2]:https://stackoverflow.com/questions/1880198/how-to-execute-shell-commands-in-javascript [更改节点脚本中的工作目录][3] [3]:https://stackoverflow.com/questions/19803748/change-working-directory-in-my-current-shell-context-when-running-node-script

javascript firefox bookmarklet
1个回答
0
投票

出于安全原因,浏览器不具备此功能。

© www.soinside.com 2019 - 2024. All rights reserved.