Jump to content

mbert

Member
  • Posts

    5
  • Joined

  • Last visited

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

mbert's Achievements

Helping Hand

Helping Hand (3/5)

0

Reputation

  1. Unfortunately this does not work with python3. Has anyone found an alternative or a way to get this working?
  2. Just checked, Chrome returns HTML, and so does Firefox.
  3. I am using Vivaldi. It's based on Chrome. But if something uses RTF adding a handler for it based on 'rtfd' should be straightforward.
  4. Thank you. I probably tied my thinking too much to Alfred's APIs. Using a combination of AppleScript and shell scripting it is actually quite easy. The following shell script does it (and can also be used outside of Alfred): #!/bin/sh extractUrls() { cat | \ tr '>' '\n' | \ grep -i 'href=' | \ tr "'" '"' | \ perl -pe 's/.*href=["]+([^"]+).*/$1/' | \ sort | \ uniq } doHtml() { osascript -e 'the clipboard as «class HTML»' | \ perl -ne 'print chr foreach unpack("C*",pack("H*",substr($_,11,-3)))' | \ extractUrls } doRtfd() { osascript -e 'the clipboard as «class rtfd»' | \ perl -ne 'print chr foreach unpack("C*",pack("H*",substr($_,11,-3)))' | \ textutil -stdin -stdout -convert html -format rtfd | \ extractUrls } CLASSES="`osascript -e 'the clipboard as record' | \ tr '«' '\n' | \ grep 'class.*»' | \ perl -pe 's/^class +([^»]+)».*/$1/'`" #echo "classes: $CLASSES" URLS="" for class in $CLASSES; do case $class in HTML) URLS="`doHtml`"; break;; rtfd) URLS="`doRtfd`"; break;; esac done for url in $URLS; do # echo "$url" open "$url" done I have implemented support for two classes that can be in the clipboard HTML - this is what my browser gives me. rftd - from TextEdit.app Support for additional classes will be easy to add. In the end I simply run the 'open' command on all URLs. In my browser this will open all URLs in separate tabs. Maybe there's a more "alfredish" way of doing this, e.g. by triggering a loop of actions that are way more customisable, like using particular browsers etc.?
  5. I am trying to solve the follwoing: Select some text in a browser window. The selection contains links. Extract all links from the selection and open each of them in a nw browser tab. The use case is being able to open all new posts in a forum or something similar in one go. Once I have a set of URLs I guess the rest is trivial. But how do I get the markup from which to extract the URLs? When I do a regular MacOS selection I still have rich text containing stuff like links. When assigning this to a hotkey in an Alfred workflow the meta data is lost, and I have only the plain text which is of course not what I want. Ideally I would even like to use a rectangular selection rather than the OS selection because that would allow me to limit the region from which to extract the URLs more precisely. But I haven't seen any custom selection in the workflow toolbox. Anyone got an idea how I could approach this?
×
×
  • Create New...