-
-
Notifications
You must be signed in to change notification settings - Fork 551
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
Fixes Issue 294: Add Details feature for playing video #2712
base: master
Are you sure you want to change the base?
Conversation
Adjust the css for the Details area. Modularize the checkSwitchStateAndFetchData() function to DRY code
…ulating the UI of Details area - Change the way of creating SVG to avoid CORS error - Move css styles to extension/styles.css - Use MutationObserver listens for DOM changes (e.g., when YouTube injects ytd-video-owner-renderer), ensuring the element is detected as soon as it's available. - To manipulate the UI, it listens to message from content.js to decide whether or not to display the Details area
… area to channel.js under web-accessible folder. - Check the switch and fetch data immediately after the DOM is loaded - Passing video information to channel.js file by using window.PostMessage() functtion
Hi @AnhChienVu thank you!!
https://github.com/code-charity/youtube/wiki/Contributing#adding-a-feature youtube/js&css/web-accessible/core.js Line 168 in bdc9e0e
#1452( for users: https://github.com/code-charity/youtube/wiki/%F0%9F%9B%88-YouTube-API:--How-to-generate-your-Youtube-API-key ) and this is the first feature loading the video URL again, as if it was a new tab (to make sure if the video is music), or querying independent API server (these might not offers channel video count): youtube/js&css/web-accessible/www.youtube.com/player.js Lines 205 to 255 in c7b13fb
i think we don't need to edit background.js or add a content script. what improves for package.json package-lock.json |
Hi @ImprovedTube, actually, I want to make it separate and clear of code that makes it easier to debug as well as understand the code that I was writing. That's why I explicitly add more cases in background.js. And the content.js will take care of handling message from background then send request to change UI. Because it also makes the feature work well, so to integrate with the existing codes, it should take longer time to deep dive into it. For the package.json and package-lock.json, I was thinking to add .env to secure the YOUTUBE_API_KEY when I publish the PR, but it seems to be not worked when the Chrome Extension is not built in Node.js. So For these files, I can remove these packages |
hi! @AnhChienVu
good! some of it will / should be similar for most extensions did you see?:
|
Thanks @ImprovedTube for your feedback, I am trying to integrate with the existing codes by taking a look at the reaction when user changes setting based on localStorage |
Fixes #294:
In response to the request from issue #294, I have implemented a Details Switch within the Channel Button. This feature allows users to toggle the visibility of the details area, enabling it to be shown or hidden based on the switch's state.
For a detailed explanation of the implementation steps, you can refer to my blog post. To help you quickly understand how this functionality works, I’ve attached a video below:
Untitled.video.-.Made.with.Clipchamp.3.mp4
To address all edge cases where the details area might not appear correctly based on the switch's state, I stored the switch state in local storage. This allows the extension to track and maintain the switch state, ensuring the details are displayed correctly when users navigate back to YouTube, even if they toggled the switch from a different tab (not YouTube).
Another edge case I accounted for is when the user navigates to a new video. The extension tracks the video ID in the URL, and based on this ID, it fetches the corresponding details, removing the existing ones from the screen.
Note: This feature requires a YOUTUBE_API_KEY to fetch the video data. I just used my own API to test, after finishing test, it will be deleted and removed from the source code. If you want to test this function, you can create a new API key.