JSFiddle - React, Tailwind, and code Playground

by forgetcolor

HTML

<h6 class="uiStreamMessage" data-ft="{&quot;type&quot;:1,&quot;tn&quot;:&quot;K&quot;}"> 
    <span class="messageBody" data-ft="{&quot;type&quot;:3}">Crockett Cove, Deer Isle, July 2012
        <span class="fcg"> — <a class="pronoun-link " href="https://www.facebook.com/media/set/?set=a.10151021253689547.451439.705009546&amp;type=1" data-ft="{&quot;tn&quot;:&quot;A&quot;}">Maine Day 2 </a> (11 photos)</span>
    </span>
</h6><br/>
<div id='tst'></div>

JavaScript

var j = jQuery.noConflict();
String.prototype.contains = function(it) { return this.indexOf(it) != -1; };

j('h6').each(function() {
    var newitem = j(this).find('span.fcg');
    
    if (newitem) {
        var html = newitem.html();
        console.log(html);
        if(html.contains('photos)')) {
            console.log('yes');
            var parsed2 = html.match(/^(.*)(\s+\()(\d+(?:,\d+)*)\s+(.*)/);
            console.log(parsed2);
                if(parsed2) {
                    newitem.html(parsed2[1]+parsed2[2]+
                        '<span class="facebookmetric_hideshow" style="display:none;">'+
                        parsed2[3]+
                        ' </span>'+parsed2[4]
                    );
                }
            }
    }

});