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(parser): Add ClientSideToggleMenuItem #835

Merged
merged 3 commits into from
Dec 12, 2024

Conversation

jonz94
Copy link
Contributor

@jonz94 jonz94 commented Dec 11, 2024

Fixes #595
Fixes #727

Example RawNode data 1:

{
  "clientSideToggleMenuItemRenderer": {
    "defaultText": {
      "runs": [
        {
          "text": "Timestamps"
        }
      ]
    },
    "defaultIcon": {
      "iconType": "ACCESS_TIME"
    },
    "toggledText": {
      "runs": [
        {
          "text": "Timestamps"
        }
      ]
    },
    "toggledIcon": {
      "iconType": "ACCESS_TIME"
    },
    "menuItemIdentifier": "timestamp_toggle",
    "command": {
      "clickTrackingParams": "CAYQl98BIhMI7bKs8KG9iQMVWaPYBR2lDhra",
      "toggleLiveChatTimestampsEndpoint": {
        "hack": true
      }
    }
  }
}

Example RawNode data 2:

{
  "clientSideToggleMenuItemRenderer": {
    "defaultText": {
      "runs": [
        {
          "text": "Reactions"
        }
      ]
    },
    "defaultIcon": {
      "iconType": "HEART_CIRCLE"
    },
    "toggledText": {
      "runs": [
        {
          "text": "Reactions"
        }
      ]
    },
    "toggledIcon": {
      "iconType": "HEART_CIRCLE"
    },
    "isToggled": true,
    "menuItemIdentifier": "reactions_toggle",
    "command": {
      "clickTrackingParams": "CBIQjcsMGDsiEwin892z6KCKAxXtAXsHHdGyB14=",
      "toggleLiveReactionsMuteCommand": {
        "hack": true
      }
    },
    "loggingDirectives": {
      "trackingParams": "CBIQjcsMGDsiEwin892z6KCKAxXtAXsHHdGyB14=",
      "visibility": {
        "types": "12"
      },
      "enableDisplayloggerExperiment": true
    }
  }
}

I notice that the command field is not a conventional NavigationEndpoint

"command": {
  "clickTrackingParams": "CAYQl98BIhMI7bKs8KG9iQMVWaPYBR2lDhra",
  "toggleLiveChatTimestampsEndpoint": {
    "hack": true
  }
}

I'm not sure how to properly parse this.

Or maybe, should we just ignore the command field?
Since it does not interact with any backend endpoint.

@LuanRT
Copy link
Owner

LuanRT commented Dec 11, 2024

It's ok to parse the command. It's supposed to trigger a client side action, and people building YouTube clients that follow YouTube's SDUI rendering approach might find it useful.

@jonz94
Copy link
Contributor Author

jonz94 commented Dec 11, 2024

It's ok to parse the command. It's supposed to trigger a client side action, and people building YouTube clients that follow YouTube's SDUI rendering approach might find it useful.

Thanks for the clarification! I've updated the parser to parse the command data.


I also found another occurrence of the ClientSideToggleMenuItem which includes extra fields not present in the original implementation:

{
  "clientSideToggleMenuItemRenderer": {
    "defaultText": {
      "runs": [
        {
          "text": "Reactions"
        }
      ]
    },
    "defaultIcon": {
      "iconType": "HEART_CIRCLE"
    },
    "toggledText": {
      "runs": [
        {
          "text": "Reactions"
        }
      ]
    },
    "toggledIcon": {
      "iconType": "HEART_CIRCLE"
    },
    "isToggled": true,
    "menuItemIdentifier": "reactions_toggle",
    "command": {
      "clickTrackingParams": "CBIQjcsMGDsiEwin892z6KCKAxXtAXsHHdGyB14=",
      "toggleLiveReactionsMuteCommand": {
        "hack": true
      }
    },
    "loggingDirectives": {
      "trackingParams": "CBIQjcsMGDsiEwin892z6KCKAxXtAXsHHdGyB14=",
      "visibility": {
        "types": "12"
      },
      "enableDisplayloggerExperiment": true
    }
  }
}

And I updated the parser to account for it.

@LuanRT LuanRT merged commit 0b2b0da into LuanRT:main Dec 12, 2024
4 checks passed
@jonz94 jonz94 deleted the add-ClientSideToggleMenuItem branch December 12, 2024 13:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants