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

added auto unmute in yt home #11

Merged
merged 1 commit into from
Dec 7, 2024
Merged

added auto unmute in yt home #11

merged 1 commit into from
Dec 7, 2024

Conversation

u-Kuro
Copy link
Owner

@u-Kuro u-Kuro commented Dec 7, 2024

Summary by Sourcery

Enhancements:

  • Improve the unmute functionality for YouTube videos by implementing a more robust mechanism using MutationObserver.

Copy link

vercel bot commented Dec 7, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
kanshi ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 7, 2024 6:20am

Copy link

sourcery-ai bot commented Dec 7, 2024

Reviewer's Guide by Sourcery

This PR enhances the YouTube WebView functionality by improving video auto-unmuting behavior and reorganizing the execution order of various WebView operations. The changes primarily focus on JavaScript injection for handling unmute buttons and anchor tag modifications, while also removing unnecessary pause/resume operations during URL handling.

Sequence diagram for WebView URL handling

sequenceDiagram
    participant User
    participant App as YoutubeViewActivity
    participant WebView

    User->>App: Clicks on a link
    App->>WebView: onPageFinished
    WebView-->>App: Page load complete
    App->>WebView: initAnchor(view)
    App->>WebView: unMuteVideo(view)

    note over App,WebView: Removed pause/resume operations

    App->>WebView: shouldOverrideUrlLoading
    WebView-->>App: URL loading decision
    App->>WebView: initAnchor(view) again

    note over App: Improved execution order for unmute and anchor initialization
Loading

Updated class diagram for YoutubeViewActivity

classDiagram
    class YoutubeViewActivity {
        +onCreate(Bundle)
        +onShowFileChooser(WebView, ValueCallback<Uri[]>, FileChooserParams)
        +onPageStarted(WebView, String, Bitmap)
        +onPageFinished(WebView, String)
        +doUpdateVisitedHistory(WebView, String, boolean)
        +shouldOverrideUrlLoading(WebView, WebResourceRequest)
        +hideStatusBar()
        +initAnchor(WebView)
        +autoPlayVideo(WebView)
        +unMuteVideo(WebView)
    }

    note for YoutubeViewActivity "Reorganized method calls in onPageFinished and shouldOverrideUrlLoading. Enhanced unMuteVideo with MutationObserver."
Loading

File-Level Changes

Change Details Files
Enhanced video auto-unmute functionality with more robust detection and handling
  • Added support for multiple unmute button selectors including 'button.ytp-unmute' and 'button.YtmMuteButtonButton'
  • Implemented a MutationObserver to watch for dynamically added unmute buttons
  • Added checks to prevent duplicate unmute operations using WeakSet
  • Added specific handling for video preview elements
android/app/src/main/java/com/example/kanshi/YoutubeViewActivity.java
Improved anchor tag handling with better initialization and error handling
  • Added check for existing KanshiAnchorObserver to prevent duplicate observers
  • Added try-catch block for anchor tag modifications
  • Improved observer cleanup on error
android/app/src/main/java/com/example/kanshi/YoutubeViewActivity.java
Reorganized WebView lifecycle operations
  • Moved initAnchor and unMuteVideo calls after super.onPageFinished
  • Removed unnecessary pauseWebView and resumeWebView calls during URL handling
  • Added super.onProgressChanged call in progress tracking
android/app/src/main/java/com/example/kanshi/YoutubeViewActivity.java

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time. You can also use
    this command to specify where the summary should be inserted.

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@u-Kuro u-Kuro merged commit f102ced into clean-code Dec 7, 2024
4 checks passed
Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @u-Kuro - I've reviewed your changes and they look great!

Here's what I looked at during the review
  • 🟢 General issues: all looks good
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant