hoothin / SearchJumper

Yet another awesome browser extension for switching search engines, search everything (selection text / image / link / find in page) on any engine with a simple right click or a variety of menus and shortcuts. Build with React & Material-UI. (WIP).
https://hoothin.github.io/SearchJumper
GNU General Public License v3.0
751 stars 39 forks source link

Rules for copying text in ordinary plain, plain with all embedded URLs and html formats #100

Open iG8R opened 10 months ago

iG8R commented 10 months ago

Hi. Suppose a user selects the following text:

SearchJumper-Text-with-URLs-Video_2023-10-30_231457.webm

-

- Is there a way to give an option to save it into the clipboard in the different following formats: 1. plain text with all embedded URLs under texts' highlights and images (my main concern)

    Just a personal work, maybe not suit you and won't provide support.

📧Mail Me (mailto:rixixi@gmail.com)

    Build with React.js
    UI: Material-UI (https://mui.com/)
    Icons: FontAwesome (https://fontawesome.com/)

(https://github.com/hoothin/SearchJumper/blob/main/demo1.gif) (https://github.com/hoothin/SearchJumper/blob/main/demo3.gif) (https://github.com/hoothin/SearchJumper/blob/main/demo2.gif)

2. html text

<html><body>
<!--StartFragment--><blockquote>
<p dir="auto"><em>Just a personal work, maybe not suit you and won't provide support.</em></p>
</blockquote>
<p dir="auto"><a href="mailto:rixixi@gmail.com"><strong>📧Mail Me</strong></a></p>
<ul dir="auto">
<li>Build with React.js</li>
<li>UI: <a href="https://mui.com/" rel="nofollow">Material-UI</a></li>
<li>Icons: <a href="https://fontawesome.com/" rel="nofollow">FontAwesome</a></li>
</ul>
<p dir="auto"><animated-image data-catalyst=""><a target="_blank" rel="noopener noreferrer" href="https://github.com/hoothin/SearchJumper/blob/main/demo1.gif" data-target="animated-image.originalLink"><img src="https://github.com/hoothin/SearchJumper/raw/main/demo1.gif" height="221px" style="max-width: 100%; display: inline-block;" data-target="animated-image.originalImage"></a>
      </animated-image><animated-image data-catalyst=""><a target="_blank" rel="noopener noreferrer" href="https://github.com/hoothin/SearchJumper/blob/main/demo3.gif" data-target="animated-image.originalLink"><img src="https://github.com/hoothin/SearchJumper/raw/main/demo3.gif" height="221px" style="max-width: 100%; display: inline-block;" data-target="animated-image.originalImage"></a>
      </animated-image><animated-image data-catalyst=""><a target="_blank" rel="noopener noreferrer" href="https://github.com/hoothin/SearchJumper/blob/main/demo2.gif" data-target="animated-image.originalLink"><img src="https://github.com/hoothin/SearchJumper/raw/main/demo2.gif" height="221px" style="max-width: 100%; display: inline-block;" data-target="animated-image.originalImage"></a></animated-image></p><!--EndFragment-->
</body>
</html>

3. ordinary plain text

    Just a personal work, maybe not suit you and won't provide support.

📧Mail Me

    Build with React.js
    UI: Material-UI
    Icons: FontAwesome
hoothin commented 10 months ago

You have not even installed SearchJumper. So what are you expecting???

iG8R commented 10 months ago

Well, this is my pre-installation preparation. :)

iG8R commented 10 months ago

What a beautiful design and smooth operation of the script, wow.

hoothin commented 10 months ago

SearchJumper does not have the ability to extract the HTML of selected elements, which may be added in the future. I didn't have a good idea where to add it.

iG8R commented 10 months ago

Is SearchJumper able to intercept what is passed to the clipboard?

If yes, then, usually, when something is copied in the browser, it is transmitted in two versions at once - text/plain and text/html. Maybe then it will be possible to process text/html with SearchJumper?

PS. This feature would be way useful, as when we copy texts from web pages and paste them into applications or forms that don't support pasting texts with richtext/html formatting, we encounter a problem of missing a very important part of these texts - URLs, since usually the overwhelming majority of URLs on any web page are hidden under text descriptions and images.

hoothin commented 10 months ago

No, it can't. https://developer.mozilla.org/en-US/docs/Web/API/Clipboard/read . On firefox, only addon can do that, but not greasemonkey script.

iG8R commented 10 months ago

What a pity :(

hoothin commented 10 months ago

You can try %element now

iG8R commented 10 months ago

Amazing! Thank you very much! Is it possible to customize how the copied text+URL will look, for example, currently it is copied like this

[📧Mail Me](mailto:rixixi@gmail.com)

Build with React.js
UI: [Material-UI](https://mui.com/)
Icons: [FontAwesome](https://fontawesome.com/)

E.i. with [ ] around text and ( ) around the URL. Make it possible for it to look text (URL) or {text | URL}, or text [URL] etc.

iG8R commented 10 months ago

Some texts reveal bugs in their processing, but this in no way diminishes how cool it is!


Icons: [FontAwesome](https://fontawesome.com/)

[![](https://github.com/hoothin/SearchJumper/raw/main/demo1.gif)](https://github.com/hoothin/SearchJumper/blob/main/demo1.gif)

        [

            ![demo1.gif](https://github.com/hoothin/SearchJumper/raw/main/demo1.gif)
          ](https://github.com/hoothin/SearchJumper/blob/main/demo1.gif)

          [

          ](https://github.com/hoothin/SearchJumper/blob/main/demo1.gif)

      [![](https://github.com/hoothin/SearchJumper/raw/main/demo3.gif)](https://github.com/hoothin/SearchJumper/blob/main/demo3.gif)

        [

            ![demo3.gif](https://github.com/hoothin/SearchJumper/raw/main/demo3.gif)
          ](https://github.com/hoothin/SearchJumper/blob/main/demo3.gif)

          [

          ](https://github.com/hoothin/SearchJumper/blob/main/demo3.gif)

      [![](https://github.com/hoothin/SearchJumper/raw/main/demo2.gif)](https://github.com/hoothin/SearchJumper/blob/main/demo2.gif)
iG8R commented 10 months ago

On https://www.twitch.tv/directory

SearchJumper-Text-URL-some-issue-01-Video_2023-11-01_123134.webm

hoothin commented 10 months ago

I've optimized a little, but this is just a experimenting and I think addon like Copy as Markdown will be better. Anyway, you can try %element{}.prop(outerHTML).replace() for more possibilities.

iG8R commented 10 months ago

Thank you for advice. Copy as Markdown - very good addon, but it only copies connected pair [link title](URL)or [page title](URL), not entire selected text with URLs. As for the Markdown format - it is used mostly among among specialists (typesetting, design, IT), for common people, like parents or friends such a text format would be incomprehensible and confusing. That’s actually why I asked for the ability to customize the text-link design type, so that it would be convenient for everyone with whom you communicate and send information. Of course, it is possible to use wildcard substitution manually, but it would be much more convenient for any user, even Vim fans, if there was an option to set formatting options initially.

hoothin commented 10 months ago

It's easy with %element.replace, like

hoothin commented 10 months ago
iG8R commented 10 months ago

Thanks a lot!

iG8R commented 10 months ago

Unfortunately, the new rules do not work as well as the first ones. I know that the script still needs to be optimized, so the data below is just for information on how things are at the moment.

image image

  1. c:%element{}

    [📧Mail Me](mailto:rixixi@gmail.com) 
    Build with React.js
    UI:  [Material-UI](https://mui.com/) 
    Icons:  [FontAwesome](https://fontawesome.com/) 
    [![](https://github.com/hoothin/SearchJumper/raw/main/demo1.gif)](https://github.com/hoothin/SearchJumper/blob/main/demo1.gif) 
    [![demo1.gif](https://github.com/hoothin/SearchJumper/raw/main/demo1.gif)](https://github.com/hoothin/SearchJumper/blob/main/demo1.gif) 
    [![](https://github.com/hoothin/SearchJumper/raw/main/demo3.gif)](https://github.com/hoothin/SearchJumper/blob/main/demo3.gif) 
    [![demo3.gif](https://github.com/hoothin/SearchJumper/raw/main/demo3.gif)](https://github.com/hoothin/SearchJumper/blob/main/demo3.gif) 
    [![](https://github.com/hoothin/SearchJumper/raw/main/demo2.gif)](https://github.com/hoothin/SearchJumper/blob/main/demo2.gif) 

    [Click on text to copy a link to the clipboard - javascript ![](data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAACDklEQVR4Ae1VA6wcURR9tW23+95s7cZVUNuKaiOsu3dqB7UV1EFt27btjup2el6y+ObMFv+f5OwObuacqzyWilQ4CYs8tQwSJw3ilcIu/n6qJ5dJ4gNow8SdD1Q6Nws3DFVpBwO/QBvcYa9n6VwVlALItkIkE8TH+w1ITmVuAuLzIfLFUpW+QVPE0prEt/oN/EJMR1fEP08sUwoCLyJku9qmIlmD8+DjN/3PLZPKVGFuwKTShSFwMIKJKzp5vAzQyVsO9x/9Q3kf9/ndmQOqn172OsLwaRBszwBLFS1Cz/keR4bSJKWrRUpz2WsWARbx1oE19IvOthfVzGD5xLgIFZrtxK6/95f1rukTw+Qz5odGXODdhZCgcuSTTxQ3SNmMeAMm+yR36iuglIcDAn4jukVibqD3NpXOjJgVEWJewWjDjxMEZ04BgjX8Il8iCP0Cd5gqbyLbg5geuP8MPpFVYG7AmCQKoKxjIPIUtCPwluHjg3TVW8exc8EiT1NTFd2M8Ur5qNMshw1CndGOE1GMjHBw58W+CH03wWOy92APa7yoLk0ETkTErEGLnr+ZVjaHkwZ2ghpox8Kv4DkYWwwOkBvBnIYcLjnthso7IcNpENyN/3cxGZItS5bY8jXrbEmWAHwiT0ld5W2Queo/iJ5oVCFvxO+4ZCBuOGpAljUx/I8MJAP/vgEn+K8ZCD9S8Rsz4IeXsWZCowAAAABJRU5ErkJggg==) Stack Overflowhttps://stackoverflow.com › questions › click-on-text-t...](https://stackoverflow.com/questions/51625169/click-on-text-to-copy-a-link-to-the-clipboard) Stack Overflowhttps://stackoverflow.com › questions › click-on-text-t...

  2. c:%element{}.replace(/![.?](.?)/g,"").replace(/[(.?)]((.?))/g,"$1 $2")

    📧Mail Me (mailto:rixixi@gmail.com) 
    Build with React.js
    UI:  Material-UI (https://mui.com/) 
    Icons:  FontAwesome (https://fontawesome.com/) 
    (https://github.com/hoothin/SearchJumper/blob/main/demo1.gif) 
    (https://github.com/hoothin/SearchJumper/blob/main/demo1.gif) 
    (https://github.com/hoothin/SearchJumper/blob/main/demo3.gif) 
    (https://github.com/hoothin/SearchJumper/blob/main/demo3.gif) 
    (https://github.com/hoothin/SearchJumper/blob/main/demo2.gif) 

    Click on text to copy a link to the clipboard - javascript Stack Overflowhttps://stackoverflow.com › questions › click-on-text-t... (https://stackoverflow.com/questions/51625169/click-on-text-to-copy-a-link-to-the-clipboard) Stack Overflowhttps://stackoverflow.com › questions › click-on-text-t...

hoothin commented 10 months ago

So? I think it works as I expected. What's your expected behavior?

iG8R commented 10 months ago

image

hoothin commented 10 months ago

![] means image with no alt info (https://github.com/hoothin/SearchJumper/blob/main/demo1.gif) means this is a link but without text (which was image there). If you don't want to save links without text, add another replace like c:%element{}.replace(/!\[.*?\]\(.*?\)/g,"").replace(/\[ *\]\(.*?\)\s*/g,"").replace(/\[(.*?)\]\((.*?)\)/g,"{ $1 | $2 }").

I don't know why you can't get all links but I get this result on my Chrome. { Click on text to copy a link to the clipboard - javascript Stack Overflowhttps://stackoverflow.com › questions › click-on-text-t... | https://stackoverflow.com/questions/51625169/click-on-text-to-copy-a-link-to-the-clipboard } Stack Overflowhttps://stackoverflow.com › questions › click-on-text-t...Aug 1, 2018 — 2 Answers 2 · Create a