JSFiddle - React, Tailwind, and code Playground

by antonio ortiz

HTML

<div id="avon_rep_container" class="container-avon-representative-news">
  <table class="marginfix" border="0" cellspacing="0" cellpadding="0" width="100%" bgcolor="#FFFFFF">
    <tbody>
      <tr>
        <td align="center">
          <!-- begin container -->
          <table class="full-width-container" border="0" cellspacing="0" cellpadding="0" width="640">
            <tbody>
              <tr>
                <!-- left spacer -->
                <td class="hide" width="10">&nbsp;</td>
                <!-- end left spacer -->
                <!-- inner container -->
                <td class="full-width-container" style="min-width:620px;" width="620" align="center">
                  <!-- begin table to rearrange content -->
                  <table style="margin-top:20px;" border="0" cellspacing="0" cellpadding="0" width="100%">
                    <tbody>
                      <tr>
                        <td class="rearrange">
                          <!-- include all email body content in below table -->
                          <table class="content" border="0" cellspacing="0" cellpadding="0" width="100%">
                            <tbody>
                              <tr>
                                <td align="center">
                                  <!-- BEGIN CONTENT -->
                                  <!-- Header -->
                                  <table border="0" cellspacing="0" cellpadding="0" width="100%">
                                    <tbody>
                                      <tr>
                                        <td class="full-width-img" style="border-top:1px solid #ccc; border-bottom:1px solid #ccc;" align="center"><img style="display:block;" src="/images/avon_manager_news/newsletter_header_manager_071116.jpg" border="0" alt="Avon Manager News" width="620" height="178" /></td>
                                      </tr>
                                    </tbody>
                                  </table>
   ...

CSS

* {
   -webkit-border-horizontal-spacing: 0px !important;
   -webkit-border-vertical-spacing: 0px !important;
   -webkit-text-size-adjust: none;
   border-collapse: collapse;
   /* prevent iOS font upsizing */
 }
 
 .ExternalClass * {
   line-height: 100%;
 }
 /* force Outlook.com to honor line-height */
 
 td {
   mso-line-height-rule: exactly;
 }
 /* prevent iOS auto-linking */
 
 .applefix1 a {
   color: #666666;
   text-decoration: none;
 }
 /* use on all gray body copy */
 
 .applefix2 a {
   color: #000001;
   text-decoration: none;
 }
 /* use on black headlines */
 
 .applefix3 a {
   color: #ed008c;
   text-decoration: none;
 }
 /* use on colored text, update per campaign */
 /* prevent Outlook purple links */
 
 .navstack a:link {
   color: #666666;
 }
 
 .ctaText a:link {
   color: #ffffff;
 }
 
 .preheader a:link {
   color: #666666;
 }
 
 .headline a:link {
   color: #000001;
 }
 
 .bodycopy a:link {
   color: #666666;
 }
 
 .legalfooter a:link {
   color: #666666;
 }
 /** use on colored copy, update per campaign **/
 
 .colorlink a:link {
   color: #ed008c;
 }
 
 td[class="pattern"] {
   padding: 40px 40px 20px 40px;
 }
 /* .boxmodel {border:1px solid #ccc; margin-bottom:20px;} */
 
 @media only screen and (max-width: 480px) {
   /**********************
    SAMSUNG FIX
    set media query to
    max-width: 480px
    for testing in browser
    set media query to
    max-device-width: 480px
    for production
    **********************/
   /***** specific module styles *****/
   /** freeship banner image swap **/
   /* update below with mobile shipping banner image path and dimensions */
   /** 3-across products **/
   body[yahoo] .width150 {
     /* resize 3rd module */
     width: 150px !important;
   }
   body[yahoo] .width155 {
     /* smaller two across rectangles */
     width: 155px !important;
     height: 118px !important;
   }
   body[yahoo] .three-across img {
     /* resize each image to fit 2-across */
     width: 142px !important;
    ...

JavaScript

var MarkUpChecker = (function iffe() {
  'use strict';


  var URLS = { // Instead of using a switch statement I am using a function which returns a object to do the job
      'smo': 'http://smo.rye.avon.com',
      'smodev': 'http://smodev.rye.avon.com',
      'youravon_sans_w': 'http://youravon.com',
      'youravon': 'http://www.youravon.com',
      'youravon2': 'http://www2.youravon.com'
    },

    publicAPI;

  function getURL() {
    for (var i = 0; i < arguments.length; i++) { // Using a for loop to allow unlimited arguments to be passed in
      return URLS[arguments[i]];
    }
  }
  publicAPI = {

    addURL: function() {
      for (var i = 0; i < arguments.length; i += 2) {
        URLS[arguments[i]] = arguments[i + 1];
      }
      console.dir(URLS);
      return URLS;
    },
    searchURL: function() {
      function insertAfter(newNode, referenceNode) {
        referenceNode.parentNode.insertBefore(newNode, referenceNode.nextSibling);
      }
      var link, url, parser, newPathName = '',
        emailUrl = /img\//gi,
        tsUrl = /\/REPSuite\/static\/html\/inews_archives\/img\//gi,
        newstr = '',
        doc = document,
        avon_rep_container,
        avon_rep_container_id,
        avon_rep_container_links,
        avon_rep_container_images,
        documentTableWrapper,
        docBodyFirstChild,
        nodeToTargetToInsertLP;

      if (!doc.getElementById('avon_rep_container')) {
        avon_rep_container = doc.createElement('div');
        avon_rep_container.setAttribute('id', 'avon_rep_container');
        avon_rep_container.className = 'container-avon-representative-news';
        avon_rep_container_links = avon_rep_container.getElementsByTagName('a');
        avon_rep_container_id = doc.getElementById('avon_rep_container');
        docBodyFirstChild = doc.body.firstChild;
        nodeToTargetToInsertLP = doc.getElementsByClassName('flexTile')[4];


        if (nodeToTargetToInsertLP) {
          documentTableWrapper =...