Custom gallery with carousel

My solution works but it’s quite messy. So I took danro’s solution Linking to Specific Tab from another Link or Button - #2 by danro - it works, but I need to show two tabs when press the button instead one tab. I just add another string in a code

it works great but …I need to past code into body section for EACH tab.
Is there an easyest way?