3 ms·
You know what would be cool, if you could use unix cli tools in the browser. Press control+<space>, a small console box shows up and run: |grep ...|awk ... An
by _8j50 3y ago
You know what would be cool, if you could use unix cli tools in the browser. Press control+<space>, a small console box shows up and run:
|grep ...|awk ...
And the text of the document gets processed. But if you want to mess with the dom you could:
Html.Body | sed ... | jq ...
- GlumWoodpecker 3y agoThis probably wouldn't be possible due to browser sandboxing. You could however, use a tool like External Application Button [0] in order to send the URL of the page to a script/program, which in turn can make the body of the page parsable by downloading the URL it gets, automating some action on it. I use it pretty often to automate downloads with yt-dlp or opening a picture directly in GIMP from the browser, but since you're invoking a bash/python/whatever script, the possibilities are basically endless. [0]: https://github.com/andy-portmen/external-application-button https://github.com/andy-portmen/external-application-button
- aidenn0 3y ago> You could however, use a tool like External Application Button [0] in order to send the URL of the page to a script/program, which in turn can make the body of the page parsable by downloading the URL it gets, automating some action on it. This works less well than it used to now that CMSs and blogs are now SPAs that render no text without javascript being enabled.
- GlumWoodpecker 3y agoYes, that is a shame, but that can be worked around by sending it to something like PhantomJS, headless Chromium, or any other scriptable browser that will actually run the JS on the page and render it in the background. Very heavy as you're basically running a full browser in the background, but totally doable.
- _8j50 3y agoI was thinking of running gnu binaries like that as a WASM compiled app/pwa
- schemescape 3y ago> This probably wouldn't be possible due to browser sandboxing. I’m curious about this comment. Surely this should be possible using accessibility hooks for a normal browser or in Nyxt via scripting, right?
- mtlmtlmtlmtl 3y agoYou could probably add this to Nyxt in a solid hour or two of configuration hacking. The "configuration" is just more code that gets compiled in on loading. It's a complete first class citizen unlike extensions for most software which is sandboxed in a separate language and can only see certain APIs. In Nyxt, StumpWM, Emacs, and other Lisp software you can literally put bugfixes in your config, redefine existing functions, and generally do whatever the hell you want.
- sureglymop 3y agoThat is good! I have been creating some add ons for firefox and what i dislike the most is that i can't just easily modify the UI of the browser itself. I hate that i can't change stuff even if i am only creating add-ons for myself...
- deleted 3y ago[deleted]
- newcup 3y agoThe page content piping could be done e.g. like this: (defun get-buffer-text (&optional buf) (nyxt/mode/document:select-all buf) (nyxt/mode/document:copy buf) (trivial-clipboard:text)) (define-internal-page cmd-result (&key text) (:title "*Result*") (spinneret:with-html-string (dolist (line (str:split #\newline text)) (:p line)))) (define-command-global buf-text-to-pipe-cmd (&optional buf cmd) (let* ((buf (or buf (nyxt:current-buffer))) (safe-text (uiop:escape-sh-token (get-buffer-text buf))) (cmd (or cmd (prompt1 :prompt "cmd: " :sources 'prompter:raw-source))) (cmd-output (uiop:run-program `("bash" "-c" ,(str:concat "echo '" safe-text "' | " cmd)) :output :string))) (nyxt:buffer-load-internal-page-focus 'cmd-result :text cmd-output))) And then call the function like C-space buf-text-to-pipe-cmd and specify the commands to pipe to. Output will appear in a new buffer that can be further used as the source for piping. DOM handling would be a tad more laborous, but you can pick DOM elements from output of nyxt:document-model with CSS selectors using clss:select.