opening multiple links from clipboard

Add-ons for Pale Moon and other applications
General discussion, compatibility, contributed extensions, themes, plugins, and more.

Moderators: FranklinDM, Lootyhoof

eriffodrol

opening multiple links from clipboard

Unread post by eriffodrol » 2018-06-21, 05:42

I used to use Multi-Link Paste and Go https://addons.mozilla.org/en-US/firefox/addon/multi-link-paste-and-go for opening multiple links in new tabs from the clipboard. The last version was 5 years ago, so no surprise it's not compatible with PM. I found one other addon with similar function in the Classic Archive but it doesn't work either.

If anyone has any suggestions for alternatives it would be appreciated.

Lew Rockwell Fan
Fanatic
Fanatic
Posts: 190
Joined: 2017-06-14, 15:20

Re: opening multiple links from clipboard

Unread post by Lew Rockwell Fan » 2018-07-04, 20:28

Pretty sure you can script this. Can't give you a step by step off the cuff, but I can get you started. Don't know what tools are available for windows batch files anymore, but if you're in that environment the following can at least suggest search strategies for what you need to study.

Make what's in the clipboard accesible to the script.
In bash with a 'nix, xclip would be the most common way to do this.

Parse the content into urls so you can do unto each in turn.
In ", that depends on how variable the format of what you copied is. If it is always newline delimited, 1 url to a line. that's pretty easy. If it is space delimited, or something even trickier, the easiest thing would probably be to use something like sed or maybe grep or awk to transform it into that format. Whether you'd do best to put that in a file in a ramdisk or on spinnig rust depends on your resources. Then to do unto each line, probably your best bet is to adapt something like this:

Code: Select all

while IFS='' read -r line || [[ -n "$line" ]]; do
    echo "Text read from file: $line"
done < "$1"
That's assuming you break this down into 2 scripts and the url gets to the above code as the argument to a script that is invoked for each url separately. If you roll it all into one script, you'll use some other variable name for the url instad of $1.


"for . . . do . . . done" is more intuitive, but it often doesn't work. TBH, I've read long explanations of why read is robust in this sort of situation and "for" isn't, but they always confused me. I just accept it. Read works.

Use something like xdotool to simulate the keybindings to open tabs and paste in the urls & open them. Menu Wizard is great for exploring keybindings or changing them. I don't think it's been ported yet, but there is an old version at mozila that works pretty well. Whatever procedure you come up with, repeat it for each line.

You may find it easier to break this down into 2 scripts. One to open a new tab, paste the argument into the url field and go there. Another to process the urls in the clipboard one at a time and feed them to the other script.
Last edited by Lew Rockwell Fan on 2018-07-04, 20:39, edited 2 times in total.
"To attempt to silence a man is to pay him homage, for it is an acknowledgement that his arguments are both impossible to answer and impossible to ignore." - John Bryant

Locked