cpriest / SnapLinksPlus

Snap Links Plus is a Browser Addon that lets you lasso links, checkboxes and other elements do things with them.
Other
196 stars 35 forks source link

Feature Request - lasso select text and copy #408

Closed chaoscreater closed 2 years ago

chaoscreater commented 2 years ago

Hi,

I use an extension called SearchBar and it allows you to search a string against multiple search engines very easily.

For example, if I want to search Google, I can use this: google.com/search?q=%s

If I want to look up the up Stackoverflow, I can use this: stackoverflow.com/search?q=%s

Where %s is my search string.

The problem is that I have to manually type each of my search string into SearchBar. Sometimes, I have a list of things to search and it'll be much easier if I could lasso select multiple words (one word per line) and then search them against a particular search engine.

Snap Link Plus only allows you to perform an action against highlighted links. It would be nice if you can highlight just words and copy them to clipboard, OR better yet, highlight the words and search each of them against a specific search engine (like the example I mentioned above).

remi-garcia commented 2 years ago

If I understand correctly you want to select words instead of links and to open these words as part of a fixed link? This seems far from what SLP3 is made for. I like things to do one job efficiently and going the way you ask for seems to be something for another dedicated addon.

I don't see SLP3 having that feature anytime in the future, sorry. @cpriest, any though before closing the issue?

chaoscreater commented 2 years ago

Yes, that is exactly right. The reason I think this is a reasonable feature request is because the current feature set already does 99% of what I'm asking for. SLP3 is already able to do a lasso selection and is able to copy the selection to clipboard. The only thing that is different here is instead of selecting links, we're selecting text. In some sense, it's probably a lot easier, because you don't have to check whether the selected item is a link or not. I imagine this change is small and wouldn't be too difficult or time consuming to implement.

remi-garcia commented 2 years ago

I see a text selection as way more difficult.

From a technical point of view: it is "easy" to know if our selection overlap with <a> field and then to extract the href from this field; For text it would require to get knowledge about <p> field, assuming the website is done correctly..., and then we would need to detect which letters inside the field overlap with our selection and finally to find, for each letter, the word is goes with.

I now understand that it seems similar from the end-user point of view but from the developer point of view it is a totally different feature.

However I believe that your use case would not require lassoing. You would need to make multiple researches at once. You want to fill a field with multiple words and to obtain a search tab for each word you provided? I took a quick look and did not find the right keywords for finding such a tool but I do believe it already exists.

chaoscreater commented 2 years ago

Well that's the thing, I've spent the last 9 hours searching for extensions for both Firefox and Chrome. I've found many tools, but not quite what I want.

As I mentioned earlier, SearchBar is one of the extensions I use that can quickly lookup a keyword against multiple search engines and that is great. However, the problem is that it can only lookup one keyword at a time. The keywords I'm looking up are always random and are not in a table, which means I can't just use extensions that filter & extract words from a column or row of the table. The only thing that makes sense is to do a lasso select, which surprisingly is only found in either LinkClump or in SLP3. There isn't any other extension out there that even offers a lasso select feature.

I even checked Reddit, Stackoverflow and Github and couldn't find anything to do exactly what I want.

remi-garcia commented 2 years ago

Can you give an example of a page you need to get words from?

chaoscreater commented 2 years ago

I can't give you an example sorry, as the words I'm trying to get are from Azure.

In Azure, there's a service offering from MS called Microsoft Defender for Cloud. It will regularly scan your resources (e.g. VMs) hosted in Azure and let you know if you are getting brute force connection attempts for RDP or SSH, etc, from malicious IPs.

It looks something like this: https://portal.azure.com/#blade/Microsoft_Azure_Security/SecurityMenuBlade/7

image

What I'm trying to do is to get the IP addresses in just the first column and then look up the IPs against a community database, such as this:

https://www.abuseipdb.com/check/%s

Rather than highlighting each IP address and then look it up against that site, I'd like to highlight all IPs, copy to clipboard and then run a Powershell script. The Powershell script will take the list of IPs in my clipboard and add them to an array, then do a look up of each IP in the array against that site. This is a lot quicker and more efficient, especially if you have 50+ IPs to lookup. Alternatively, if the browser extension can lasso select and then open a new search tab (with pre-defined search engine URL) for each IP, then that'll work too.

I know the above looks like a table, but none of the Chrome extensions I've used work. I'm talking about extensions that can copy columns from tables, such as ColumnCopy, etc. Sometimes, the data shown isn't even in a format that looks like a table.

You'd need to create your own Azure account (you can get a free trial with $200 credit) and you'd need to create a few test services (e.g. VMs) in order to see some examples.

cpriest commented 2 years ago

What you're looking for is quite far outside the scope of SLP but you can accomplish what you'd like easily with firefox (if its a TABLE) by holding down ctrl and selecting the IP address cells (TD), which will outline them individually, you can then ctrl-c to copy the text of the selected cells.

remi-garcia commented 2 years ago

Can't you use SLP3 in order to select the IP addresses? These should be links that you can copy by holding CTRL down with SLP3. Then you can paste the result in a txt file and use your script.

chaoscreater commented 2 years ago

@cpriest - As mentioned already, it's not a table and even extensions that are designed specifically for tables do not work - as in none of the features work. They do work for other websites, but not in Azure.

As for using SLP3 to select the IP address, I tried that already before posting the question. SLP3 is able to detect links in other Azure pages, but not in that specific one. Keep in mind that Azure has this concept of "Blades", where instead of navigating to a new page, it creates a new "blade" for each service that you click on. I'm guessing that SLP3 can only detect links on the root page, but not links that are shown in the blades. It's hard to explain unless you try it yourself.

Anyway, if this feature request is not feasible then that's fine, I get it.

remi-garcia commented 2 years ago

Could you provide the source code of a part of the page with IP addresses? You could modify the addresses to hide sensitive data. Edit: sorry to bother you with that but I wont be able anytime soon to use a Microsoft tool just to see how it works.

Currently my best suggestion would be to save the source code and to use a script to extract with regex all the IP addresses from it.

chaoscreater commented 2 years ago

@remi-garcia - I managed to get this working using 2 different workarounds.

There's a userscript and/or extension called Linkify Plus Plus, which basically turns certain keywords that look like a web address into a clickable link. In my previous screenshot, the IP address looked like a link, but it wasn't a link and wasn't clickable. However, using Linkify Plus Plus gave it a link, which I was then able to use SLP3 to highlight and copy.

I'm not a programmer and know nothing about Javascript, but I did some research and found that ActionMgr.js is where all the magic happens. I modified the JS a bit to include this:

let links = Array.from(new Set(SelectedElements.Links.map((elem) => 'https://www.abuseipdb.com/check/' + elem.textContent)));

So now, every IP address that I highlight with the lasso select will now have the URL AbuseIPDB.com prefixed. This will then be copied to my clipboard.

I can then paste the contents of my clipboard into this Chrome extension, which is for bulk opening multiple URLs: https://chrome.google.com/webstore/detail/bulk-url-opener/kgnfciolbjojfdbbelbdbhhocjmhenep

The OTHER workaround is actually something that is already built into Edge. There's a feature/setting called "Web select", which you can trigger by right clicking anywhere on the website. However, in certain websites (such as Azure), right clicking doesn't work. So you'd have to use another extension such as this one for enabling right click: https://chrome.google.com/webstore/detail/ultimate-enable-right-cli/emfeppdfcjnldjgmofdkbggeacapegen

Basically, Web select allows you to lasso select and then do a copy of the selection into clipboard. From there, I can then run a Powershell script to import the contents of the clipboard into an array, then prefix each element in the array with the URL (as per above). Once this is done, I can then open each URL with whatever browser I want (using Powershell).

Both methods work, but the first one is obviously more elegant. The only downside to this is that I've hardcoded the search engine URL as the prefix. But anyway, I'm happy with this workaround so far and I appreciate all the help.

remi-garcia commented 2 years ago

Thanks for reporting your workaround, this might help others.

However I don't understand why you need bulk-url-opener while SLP3 could open your links instead of copying them.

cpriest commented 2 years ago

@chaoscreator Would you be able to copy/paste the HTML from that portion of the page?

If you hit Crl+Shift+C Firefox will bring up the element Inspector tab and as your mouse hovers over each web element, it should highlight it and show the HTML in the panel that pops up.

You'd find the IP address (before any other script/extension in your workaround modifies it) and click it. Then go up a few parent elements in the element inspector from the IP address. (If it were a table, it would be like A < TD < TR < TABLE, but this is probably a CSS grid or something). On the 2nd or 3rd element up, right-click that node in the inspector and click Copy -> Outer HTML

If you could paste that in this ticket it would let me see what I'd need to perhaps figure out another solution to this. Having IP addresses on a page is a relatively common situation and I could see adding them as a targetable element as a solution.

chaoscreater commented 2 years ago

@remi-garcia - good question. The only reason I'm using Bulk URL Opener extension is because it offers a couple of cool features, such as links de-duplication. Often times, I'll have about 50 IPs to check and so I'll paste all 50 IPs in there and it'll only open links that are unique. So say if I have links like this:


https://abuseipdb.com/check/1.1.1.1
https://abuseipdb.com/check/2.2.2.2
https://abuseipdb.com/check/1.1.1.1

Then it'll only open the first 2 links. Furthermore, it only opens links when the tab is focused. Imagine opening all 50 links in one go, it's gonna make my browser lag and use up unncessary resources. I can just open all 50 links and it'll open instantly, but in a lazy-loading style. When I'm reading to check each tab, it'll load the page. There are other features too, such as loading the list of URLs in reverse order, etc.

Sometimes, I'll have to check multiple IP addresses for various different tenants / customers and so I'll keep adding the URLs to Bulk URL Opener and by the time I'm ready to open them as tabs, I'll probably have 100~150 URLs. It's much easier to just add them to a list and then open in one go, instead of using SLP3 to open them instantly whenever the links are lasso selected.

To me, it's just one extra click. I literally just lasso select the IPs and SLP3 will copy it to my clipboard with URLs prefixed. Then I just copy and paste into Bulk URL Opener and open links and done.

@cpriest

Hope this helps - https://pastebin.com/7ubU15FU

I had to upload to Pastebin, as Github doesn't seem to format HTML in code blocks properly for some reason...

image

remi-garcia commented 2 years ago

I see, this is the same issue as #322

About the pastebin, there is no way the full page passes the W3C markup validation.

@cpriest Maybe, instead of trying to work with nonstandard html, we could just redirect to Linkify Plus Plus in the tutorial and/or an FAQ?

cpriest commented 2 years ago

There are plenty of sites that don't pass validation but work fine, really. There are a few oddball cases though.