Skip to content

Instantly share code, notes, and snippets.

@danilopopeye
Created August 18, 2013 19:04
Show Gist options
  • Select an option

  • Save danilopopeye/6263361 to your computer and use it in GitHub Desktop.

Select an option

Save danilopopeye/6263361 to your computer and use it in GitHub Desktop.
// getScript()
// more or less stolen form jquery core and adapted by paul irish
function getScript(url,success){
var head = document.getElementsByTagName("head")[0], done = false;
var script = document.createElement("script");
script.src = url;
// Attach handlers for all browsers
script.onload = script.onreadystatechange = function(){
if ( !done && (!this.readyState ||
this.readyState == "loaded" || this.readyState == "complete") ) {
done = true;
success();
}
};
head.appendChild(script);
}
getScript('https://code.jquery.com/jquery.min.js',function(){
jQuery('table').eq(2)
.find('td:first-child').each(function(){
this.innerHTML += '/' + (new Date().getFullYear());
})
.end()
.find('td:last-child').each(function(){
var value = '';
if(!~jQuery(this).parent().text().indexOf('Benefício')){
value += '-';
}
this.innerHTML = value + this.innerHTML.substr(8);
})
.end()
.prepend('<textarea style="height:100px;width:500px;" />')
.find('textarea').val( jQuery('table:eq(2) tbody').html() );
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment