<?xml version="1.0" encoding="utf-8"?>
<parser delay="2500" crpj="true" date="2021.03.06">
    <url><![CDATA[https?://(?:www\.)?(?:xiaohongshu|xhslink)\.com/(?:discovery/item/)?(?<id>\w+)]]></url>
    <title><![CDATA[title="([^"]+)]]></title>
    <thumbnail><![CDATA[thumbnail=([^,]+)]]></thumbnail>
    <duration><![CDATA[<meta\s+content="([^"]+)"\s+tag="sg:videotime">]]></duration>
    <mediaUrl><![CDATA[cr_video_url=([^\$]+)]]></mediaUrl>
    <jsCode><![CDATA[
        try {
            //http://xhslink.com/iXI9wb
            if (document.getElementsByClassName('dplayer-icon dplayer-play-icon').length != 0)
                document.getElementsByClassName('dplayer-icon dplayer-play-icon')[0].click();
            var title = (document.getElementsByTagName('h1').length != 0) ? document.getElementsByTagName('h1')[0].innerText : '';
            title = title.replace(/\s/g, '');
            if (!title && document.head.innerHTML.match(/\"name\":\s+\"([^\"]+)/))
                title = document.head.innerHTML.match(/\"name\":\s+\"([^\"]+)/)[1];
            var thumbnail = (document.getElementsByTagName('video').length != 0) ? document.getElementsByTagName('video')[0].poster : '';
            var video_url = (document.getElementsByTagName('video').length != 0) ? document.getElementsByTagName('video')[0].src : thumbnail;
            if (typeof(gvd) != 'undefined') {
                var url = window.external.url || window.location.href;
                var data = gvd(url);
                //特殊字幕替换
                data = data.replace(/\s/g, ' ');
                var jo = JSON.parse(data);
                if (jo.body && jo.body.video_url) {
                    title = jo.body.title;
                    thumbnail = jo.body.cover_url;
                    video_url = jo.body.video_url;
                }
            }

            document.body.innerHTML = 'title=\"' + title + '\",thumbnail=' + thumbnail + ',cr_video_url=' + video_url + '$';
        }
        catch (ex) {
        }
    ]]></jsCode>
</parser>