Skip to content

Instantly share code, notes, and snippets.

@wpgaurav
Created January 19, 2024 08:55
Show Gist options
  • Save wpgaurav/a8b137cd4b5f2515b4054deedbf4ef92 to your computer and use it in GitHub Desktop.
Save wpgaurav/a8b137cd4b5f2515b4054deedbf4ef92 to your computer and use it in GitHub Desktop.
Fix for Marketers Delight Social Share accessibility
document.addEventListener('DOMContentLoaded', function() {
// Find all elements with the class 'share-text'
var shareTextElements = document.querySelectorAll('.share-text');
shareTextElements.forEach(function(shareTextElement) {
// Find child elements with a class starting with 'md-icon-'
var shareIcons = shareTextElement.querySelectorAll('[class*="md-icon-"]');
shareIcons.forEach(function(icon) {
// Extract the part of the class name after 'md-icon-'
var iconName = icon.className.match(/md-icon-([^\s]+)/);
if (iconName && iconName[1]) {
// Create a new span element with the class 'hide'
var newSpan = document.createElement('span');
newSpan.className = 'hide';
newSpan.textContent = iconName[1];
// Insert the new span before the closing of '.share-text'
shareTextElement.appendChild(newSpan);
}
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment