Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(ecau): rich copy-paste of webpage images and links #546

Merged
merged 5 commits into from Apr 23, 2023

Conversation

ROpdebee
Copy link
Owner

@ROpdebee ROpdebee commented Aug 4, 2022

We now also accept input from copied web pages and parse URLs from anchors and images on the copied portion, which should make it easier to copy images from providers which are currently not supported (and might never be, depending on their popularity).

Some demos because a picture says a thousand words:

1.mp4
2.mp4

The ebay demo is a bit weird because it doesn't highlight the selection, but the copied portion is just the two sidebar images and not the full-page selection that appeared earlier in the clip.

This probably needs a forum post after release because the feature notification won't properly explain what this is.

We now also accept input from copied web pages and parse URLs from
anchors and images on the copied portion.
@ROpdebee ROpdebee changed the title feat(ecau): paste input from HTML feat(ecau): extract input from copied web page portions Aug 4, 2022
@ROpdebee
Copy link
Owner Author

ROpdebee commented Aug 4, 2022

/deploy-preview for beta testing because the extraction may not be ideal yet and the easiest way to find areas for improvement is by having people use the new version 🙂

github-actions bot added a commit that referenced this pull request Aug 4, 2022
feat(ecau): extract input from copied web page portions (#546)
@github-actions
Copy link

github-actions bot commented Aug 4, 2022

This PR changes 1 built userscript(s):

See all changes

@codecov
Copy link

codecov bot commented Aug 4, 2022

Codecov Report

Merging #546 (58353ea) into main (8248e5c) will decrease coverage by 0.69%.
The diff coverage is n/a.

@@            Coverage Diff             @@
##             main     #546      +/-   ##
==========================================
- Coverage   99.17%   98.48%   -0.70%     
==========================================
  Files          57       58       +1     
  Lines        1341     1385      +44     
  Branches      212      220       +8     
==========================================
+ Hits         1330     1364      +34     
- Misses          8       13       +5     
- Partials        3        8       +5     
Impacted Files Coverage Δ
...enhanced_cover_art_uploads/providers/soundcloud.ts 86.36% <0.00%> (-13.64%) ⬇️
src/lib/util/xhr.ts 100.00% <0.00%> (ø)
...c/mb_enhanced_cover_art_uploads/providers/index.ts 100.00% <0.00%> (ø)
...c/mb_enhanced_cover_art_uploads/providers/tidal.ts 100.00% <0.00%> (ø)
...rc/mb_enhanced_cover_art_uploads/providers/bugs.ts 83.33% <0.00%> (ø)
...rc/mb_enhanced_cover_art_uploads/providers/base.ts 96.72% <0.00%> (+0.29%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

Copy link
Collaborator

@kellnerd kellnerd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've tested this feature a bit and it's a great thing to have (as a substitute for a generic provider). There are two things which don't bother me personally but might confuse the casual user:

  • The pasted HTML fragment may contain irrelevant weblinks which are then of course leading to error messages (unsupported provider etc.). Personally I would have mitigated that by only extracting URLs from <img> tags, but your demo video shows a use case where the extraction from <a> tags makes perfect sense. Maybe anchors could be an optional feature or we could ignore them unless there are no <img> tags present in the HTML fragment?
  • Every image is handled as separate input, so the final status message (in case of success) will always be "Successfully added 1 image(s)", no matter how many images were actually extracted.

It's entirely possible for someone to copy-and-paste a whole chunk
of a document that includes both images and anchors. We probably
don't want to extract from the anchors if there are images. So we'll
first attempt to extract images, and fall back on anchors if there
are no images. If there are neither anchors nor images, we'll fall
back on generic parsing of plain text.
With the new URL parsing, it'd be possible that no URLs were parsed
at all. Let's provide some feedback for that.
@ROpdebee
Copy link
Owner Author

ROpdebee commented Aug 8, 2022

/deploy-preview with new fixes

Maybe anchors could be an optional feature or we could ignore them unless there are no tags present in the HTML fragment?

I've also been thinking of such a system. <img> first, then <a>, then matching URLs in plain textContent (in case someone copies unformatted links from a webpage. Should be fixed now.

Every image is handled as separate input, so the final status message (in case of success) will always be "Successfully added 1 image(s)", no matter how many images were actually extracted.

That was actually already the case for multiple URLs split by whitespace. I thought I changed that when adding more progress indicators, but apparently I forgot. Should also be fixed now.

github-actions bot added a commit that referenced this pull request Aug 8, 2022
feat(ecau): extract input from copied web page portions (#546)
@ROpdebee
Copy link
Owner Author

/deploy-preview it's been over half a year, I think it's about time to release this

github-actions bot added a commit that referenced this pull request Apr 23, 2023
feat(ecau): extract input from copied web page portions (#546)
@ROpdebee ROpdebee changed the title feat(ecau): extract input from copied web page portions feat(ecau): rich copy-paste of webpage images and links Apr 23, 2023
@ROpdebee ROpdebee merged commit 85b165c into main Apr 23, 2023
10 checks passed
@ROpdebee ROpdebee deleted the ecau-paste-html branch April 23, 2023 13:50
@github-actions
Copy link

🚀 Released 1 new userscript version(s):

  • mb_enhanced_cover_art_uploads 2023.4.23.5 in ff927bc

github-actions bot added a commit that referenced this pull request Apr 23, 2023
feat(ecau): rich copy-paste of webpage images and links (#546)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants