Add twitch support
Search for ln address in channel bio. Test channel: https://www.twitch.tv/rblb0/
I added some code to cache the twitch client id, since it should never change. However, since it might change, the code tries to fetch the resource twice, once with the cached client id, and if it fails, again with a newly obtained client id that is then cached.
@riccardobl On your test channel, https://www.twitch.tv/rblb0/, there is a :zap: emoji on the contents of the page because you don't have recent streams, I used a different test page here https://www.twitch.tv/sedentarismo where the user only see the lightning address if navigating to the "About" page. Do you know if there is some setting that the content creator can use to always display the lightning address on the main channel page?
Looking at the source code of the page with devtools, there is a <meta name="twitter:description" content="⚡[email protected]"> under the <head> tag. I wonder if we could use that instead of the proposed API fetch
Looking at the source code of the page with devtools, there is a
<meta name="twitter:description" content="⚡[email protected]">under the<head>tag. I wonder if we could use that instead of the proposed API fetch
It seems twitch is doing some sort of weird partial page update, if you try to open a video directly: https://www.twitch.tv/videos/1534401704 you'll see the twitter:description tag is not set to the channel bio, even if you navigate back to the about section or channel home.
I've found another api ViewerFeedback_Creator that should work everywhere, however it needs the channel ID and i haven't found a way to obtain it from the streams pages yet.
I've found a way to get the channel id, this should now work on all pages https://github.com/getAlby/lightning-browser-extension/pull/1017/commits/2b6a015117a0e23306cc0b92ff1f9e7e9c2ef760
yay, thanks for the PR! 🚀 @im-adithya you know the batteries well, can you do a review?
Nice PR! Thanks @riccardobl 🚀
Just a few suggestions:
- Please rebase (to remove conflicts) and use the common
findLightningAddressInTextfunction from the helpers file. - Optional chaining wherever possible (as @lujakob suggested above)
- And please separate the handling of the videos and channels pages to increase readability (you can take the GitHub battery as an example)!
Also, is it possible to make an extractClientId function during the start of the battery and proceed only if we get one (and pass it on everywhere we make an API call)? I was thinking of avoiding the usage of browser storage. (it's not worth caching if we can find it by looping through the script tags anyways(?))
@riccardobl are you still working on this?