Skip to content

Clickable links in description of both Subscriptions and Search Results page. #2889

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

Merged

Conversation

wbalbo
Copy link
Contributor

@wbalbo wbalbo commented Apr 15, 2025

This should solve the issue: #48

Let me know if anything is wrong.

@ImprovedTube
Copy link
Member

thanks! @wbalbo
typically we make almost every feature depend on a toggle.

(or if something is has no possible disadvantage and actually make sense to run for every users, then we will first ponder about possible side effects first and how to tune the code)

@wbalbo
Copy link
Contributor Author

wbalbo commented Apr 26, 2025

thanks! @wbalbo typically we make almost every feature depend on a toggle.

(or if something is has no possible disadvantage and actually make sense to run for every users, then we will first ponder about possible side effects first and how to tune the code)

Hello, thanks for looking into.

The only "disadvantage" on this is the context menu not appearing on a right click for videos with links in the description, I guess it's not a huge disadvantage anyway.

I am not sure if a toggle is really necessary for this feature, but let me know what you think. My change was really adding an event listener to the ContextMenu event to look for URLs using Regex. If the video doesn't have a link, the context menu will appear as normal; if it does, it will copy the first URL found (only the first) to the clipboard, and then you can paste it into a new tab.

@ImprovedTube
Copy link
Member

ImprovedTube commented May 12, 2025

A feature, that will be manually enabled by who misses it enough to search for it or looks through our whole list
, can simply be released without a final version.

A feature enabled for everybody is easily more complex. Then we better avoid all side effects (keep the context menu)
(and it might only be worth it for lightweight features if it runs X times more often people than will notice it)

@wbalbo
Copy link
Contributor Author

wbalbo commented May 12, 2025

A feature that will be manually enabled by who misses it enough to search for it or looks through our whole list can simply by released with out a final version.

A feature enabled for everybody is easily more complex. Then we better avoid all side effects (keep the context menu) (and its only worth it for lightweight features if it runs for X times more people than will notice it)

Ok, I should create a toggle for this, then. Where do you suggest?

Thanks.

@wbalbo
Copy link
Contributor Author

wbalbo commented May 14, 2025

I created a toggle in the General menu, in the submenu More, at the bottom
image
Let me know if you have a suggestion for a better name.

Once the toggle is on, you can right-click any link in video descriptions of both the Subscriptions page and the Search Results page, and it will copy to your clipboard.

Once the toggle is off, your normal context menu will appear.

Tested on Chrome, and Edge.

… also moving the logic from core.js to the general.js file.
@wbalbo wbalbo self-assigned this May 14, 2025
@wbalbo wbalbo requested a review from ImprovedTube May 14, 2025 18:53
@ImprovedTube
Copy link
Member

Thank you! Now it can easily be merged and released to a million people (ruling out frequent side effect)
In a follow up we could design the toggle to be on by default

I just added a label to this repo: "Feature enabled by default" (Good for almost everyone?)

@ImprovedTube ImprovedTube merged commit 44cdc12 into code-charity:master May 15, 2025
1 check passed
@wbalbo
Copy link
Contributor Author

wbalbo commented May 15, 2025

Thank you! Now it can easily be merged and released to a million people (ruling out frequent side effect) In a follow up we could design the toggle to be on by default

I just added a label to this repo: "Feature enabled by default" (Good for almost everyone?)

Thanks! Yes, I agree that in this specific case is a feature good for practically everyone.

Glad to help!

@ImprovedTube
Copy link
Member

And chosing the oldest relevant issue can be strategic since it persists for so long and is not subject to Youtube's changes and @xinitrc-dev still reacting proves it's longevity too

document_idle

How much did you try with this?
I removed this for now (you moved the feature to JS general.js)

Name Type Description
document_idle string Preferred. Use "document_idle" whenever possible.The browser chooses a time to inject scripts between "document_end" and immediately after the window.onload event fires. The exact moment of injection depends on how complex the document is and how long it is taking to load, and is optimized for page load speed.Content scripts running at "document_idle" don't need to listen for the window.onload event, they are guaranteed to run after the DOM is complete. If a script definitely needs to run after window.onload, the extension can check if onload has already fired by using the document.readyState property.
document_start string Scripts are injected after any files from css, but before any other DOM is constructed or any other script is run.
document_end string Scripts are injected immediately after the DOM is complete, but before subresources like images and frames have loaded.

( https://developer.chrome.com/docs/extensions/develop/concepts/content-scripts )


@wbalbo
Copy link
Contributor Author

wbalbo commented May 15, 2025

And chosing the oldest relevant issue can be strategic since it persists for so long and is not subject to Youtube's changes and @xinitrc-dev still reacting proves it's longevity too

document_idle

How much did you try with this? I removed this for now (you moved the feature to JS general.js)

Name Type Description
document_idle string Preferred. Use "document_idle" whenever possible.The browser chooses a time to inject scripts between "document_end" and immediately after the window.onload event fires. The exact moment of injection depends on how complex the document is and how long it is taking to load, and is optimized for page load speed.Content scripts running at "document_idle" don't need to listen for the window.onload event, they are guaranteed to run after the DOM is complete. If a script definitely needs to run after window.onload, the extension can check if onload has already fired by using the document.readyState property.
document_start string Scripts are injected after any files from css, but before any other DOM is constructed or any other script is run.
document_end string Scripts are injected immediately after the DOM is complete, but before subresources like images and frames have loaded.
( https://developer.chrome.com/docs/extensions/develop/concepts/content-scripts )

Oh yeah, I used only document_idle to be honest because it was the best solution for me. At document_start, I didn't have time to properly catch the specific CSS to do the trick of replacing the context menu to copy to clipboard, until I discovered today that it could be done in the general.js for this specific scenario.

I think document_idle is the best idea for a lot of things in the code, but obviously, this should be done carefully and one thing at a time.

Thanks for removing, I completely forgot haha.

@ImprovedTube
Copy link
Member

ImprovedTube commented May 15, 2025

to make it iintutive/self-explanatory when enabled by default: "copy with one click" could be a sub-option
while we could also remove e.preventDefault(); and add an entry to the context menu or anything or our own tooltip option.

Or, in between: we could suggest user to enable features, or define defaults by certain cohort of users.
Same could apply to some of our existing features and some of Youtube's 1300+ experiment flags

@wbalbo wbalbo deleted the clickable-links-in-description branch May 15, 2025 03:31
@ImprovedTube ImprovedTube added Knowledge Base / Documentation for contributors We should repurpose this for future reference / Wiki / Education / Introduction Feature [potentially] enabled by default Good for almost everybody? labels May 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature [potentially] enabled by default Good for almost everybody? Knowledge Base / Documentation for contributors We should repurpose this for future reference / Wiki / Education / Introduction
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants