There are 1 previous version of this script.
// ==UserScript==
// @name Seminuevos | Legibilidad & Usabilidad
// @namespace http://dev.rsalazar.name/js/
// @include http://www.seminuevos.com/*
// @include http://www.seminuevos.com.mx/*
// ==/UserScript==
try {
var fix = (function( ) {
if ( !String.starts ) {
String.prototype.starts = function( str ) { return ( !!str && 0 == this.indexOf(str) ) };
}
if ( !String.ends ) {
String.prototype.ends = function( str ) { return ( !!str && str == this.substr(-String(str).length) ) };
}
var page = document.location.href;
var domain = page.split('/').slice(0, 3).join('/');
var query = document.location.search;
page = page.substr(domain.length, page.length - domain.length - query.length);
var money = function( text, skip_format ) {
if ( skip_format ) return text;
return '$'+ parseInt(text.replace(/[$,]/g, '')) / 1000 +'k';
}; // string money()
var fixLink = function( a, target ) {
var segs, href;
segs = unescape(a.href).split("', '");
if ( 3 != segs.length ) {
return false;
}
a.href = segs[0].substr(19);
return true;
}; // bool fixLink()
var newElement = function( tag, attrs ) {
var el = document.createElement(tag);
for ( var prop in attrs ) {
if ( 'function' != typeof el[prop] ) {
el[prop] = attrs[prop];
} else {
el[prop].apply(el, attrs[prop]);
}
}
return el;
}; // HtmlElement newElement()
var getArgument = function( name, $default ) {
if ( undefined == this.__args ) {
// Assume all keys have a value (or at least the 'equal' sign)
this.__args = query.substr(1).split(/[&=]/g);
}
var index = this.__args.indexOf(name);
return ( 0 > index ? $default : this.__args[1 + index] );
}; // mixed getArgument()
return {
apply: function( ) {
if ( page.starts('/detalle.asp') ) {
this.detalles();
this.titles();
this.agregarFavoritos();
}
if ( page.starts('/busquedas.asp') ) {
this.links();
}
}, // apply()
titles: function( ) {
var title = '';
var path = 'td.negrita:not(.azul)';
var tds = document.querySelectorAll(path);
for ( var i = 0; i < 4; i ++ ) {
title += ( !title ? '' : ' ' ) + money(tds[i].lastChild.textContent, 3 != i);
}
title = title.replace(/\s+/g, ' ').replace('Volkswagen', 'VW');
if ( !!title ) {
document.title = title;
}
}, // titles()
links: function( ) {
var links = document.querySelectorAll('a[href^="javascript:PopUps"]');
var target = 'popups';
var counter = 0;
if ( 'function' == typeof links.forEach ) {
links.forEach(function( a ) {
fixLink(a, target) && counter ++;
});
} else {
for ( var i = 0; i < links.length; i ++ ) {
fixLink(links[i], target) && counter ++;
}
}
window.status = 'Grease Monkey: '+ counter +' de '+ links.length +' enlaces alterados.';
}, // links()
detalles: function( ) {
unsafeWindow.auto = false;
unsafeWindow.autodelay = 90;
}, // detalles()
agregarFavoritos: function( ) {
this.tr = document.querySelector('td[width="331"] table[height] tr');
this.tds = this.tr.children;
// Move any 3rd+ cell to a new row
if ( 2 < this.tds.length ) {
var td, tr = newElement('tr');
for ( var n = this.tds.length; n > 2; n -- ) {
tr.appendChild(this.tds[2]);
}
this.tr.parentNode.appendChild(tr);
}
// <a href="asp/ml_addfch.asp?idfch=137993"> <img alt="agregar a mi lista" src="images/ic_agregar.gif"/> </a>
this.tr.appendChild(newElement('td', {
valign: 'top',
appendChild:[
newElement('a', {
href: '/asp/ml_addfch.asp?idfch='+ getArgument('temp'),
appendChild:[
newElement('img', {
src: '/images/ic_agregar.gif',
alt: 'agregar a mi lista'
})
]
})
]
}));
return true;
} // agregarFavoritos()
};
})(); // fix object
fix.apply();
} catch ( ex ) {
window.status = 'Greasomonkey: Seminuevos - '+ ex.toString();
} // try..catch