Capturador de URLs

by Ivan Ferrer

HTML

<h2>
  Cole o HTML:
</h2>
<textarea id="insert" style="width:600px; height:300px;"></textarea><br>
  <input type="button"  onclick="executeScript()" value="Executar">

<div id="processado" class="teste" style="display:none;">
</div>

<div id="result"></div>

JavaScript

function executeScript() {
     var content = '<div>' + $('#insert').val() + '</div>';
     var data = '';
     $(content).find('[href],[src],[data-src]')
           .each(function (index, value) {
             data += ((value.src != undefined) ? value.src : (value.href != undefined) ?  value.href : (value.dataset.src != undefined) ? value.dataset.src : null !== null) +"<br>";
           });
           if ( data.indexOf('<br>') == -1 ) {
                 data = 'Não há links para serem processados!';
           }
           $('#result').html('<h3>RESULTADO:</h3>' + data);
 }