Bookmarklet redirect to url output by file

35 Views Asked by At

I have a makefile that a url similar to http://{server hosting cluster resource}:{PORT}/?tkn={randomly generated token} My goal is to write a bookmarklet that will run this file, take the output and redirect firefox to that url.

I have been able to get a node terminal to run the following code and log the url I would like.

> 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

This does give the the url. Problem is that I cannot seem to find a way to do this action in a browser. I am not the most familiar with browser development and am not able to get the file to execute. It seems like both process and require do not exist in the firefox setting and I don't understand why yet.

I do know that I will end up with something close to:

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

I just need some help getting from the first code block to the second.

I did also try to do a make -f /full/path/to/file url and that did not work either and is what lead me to changing the process directory.

Abridged research: [Execute and get the output of a shell command in node.js][1] [1]: https://stackoverflow.com/questions/12941083/execute-and-get-the-output-of-a-shell-command-in-node-js [How to execute shell commands in JavaScript][2] [2]: https://stackoverflow.com/questions/1880198/how-to-execute-shell-commands-in-javascript [Change working directory in Node script][3] [3]: https://stackoverflow.com/questions/19803748/change-working-directory-in-my-current-shell-context-when-running-node-script

1

There are 1 best solutions below

1
Gabe On

A browser does not have this ability for security reasons.