Created
March 24, 2009 06:10
-
-
Save albemuth/83969 to your computer and use it in GitHub Desktop.
crautos.com tiene muchos problemas de usabilidad, este script arregla unos cuantos
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name crautos | |
// @namespace crautos | |
// @include http://crautos.com/usados/economicos-usearch.cfm | |
// @include http://crautos.com/usados/economicos-usearch2.cfm* | |
// @include http://crautos.com/usados/economicos-usearch2.cfm* | |
// @include http://www.crautos.com/usados/economicos-usearch.cfm | |
// @include http://www.crautos.com/usados/economicos-usearch2.cfm* | |
// @include http://www.crautos.com/usados/economicos-usearch2.cfm* | |
// ==/UserScript== | |
model_name_xpath = '/html/body/div/table/tbody/tr[2]/td/div/div[2]/div/div/div/div/form/div/table/tbody/tr/td/div/table/tbody/tr/td[2]/div/table/tbody/tr/td/table/tbody/tr[6]/td[2]/input' | |
min_price_xpath = '/html/body/div/table/tbody/tr[2]/td/div/div[2]/div/div/div/div/form/div/table/tbody/tr/td/div/table/tbody/tr/td[2]/div/table/tbody/tr/td/table/tbody/tr[11]/td[2]/input'; | |
max_price_xpath = '/html/body/div/table/tbody/tr[2]/td/div/div[2]/div/div/div/div/form/div/table/tbody/tr/td/div/table/tbody/tr/td[2]/div/table/tbody/tr/td/table/tbody/tr[11]/td[2]/input[2]'; | |
//hide_crap(to_hide); | |
delete_crap(); | |
fix_jslinks(); | |
fix_images(); | |
clear_textfield_if_default(model_name_xpath, 'No Importa'); | |
console.log('done!'); | |
// clear_textfield_if_default(min_price_xpath, '1'); | |
// clear_textfield_if_default(max_price_xpath, '99999999'); | |
function delete_crap () { | |
var form = $('html.js body div table tbody tr td div div div div div div form').detatch(); | |
if (form) $('body').empty().append(form).css('background', 'white'); | |
} | |
function clear_textfield_if_default(elem_xpath, default_string){ | |
node = document.evaluate(elem_xpath, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null ).singleNodeValue; | |
node.addEventListener('blur', function(){ if(node.value == ''){node.value = default_string;}}, true); | |
node.addEventListener('focus', function(){ if(node.value == default_string){node.value = '';}}, true); | |
} | |
function hide_crap(array){ | |
for(var i = 0; i < array.length; i++){ | |
hide_xpath(array[i]); | |
} | |
$('div.usado-agencia').remove(); | |
$('#FlashID').remove(); | |
} | |
function fix_jslinks(){ | |
jsLinks = document.evaluate("//a[starts-with(@href, 'javascript:det')]", document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null); | |
for (i = 0; i < jsLinks.snapshotLength; i++){ | |
permalink = jsLinks.snapshotItem(i).href.replace(/javascript:det\('(\d+)'\)/, "http://crautos.com/usados/economicos-useddetail.cfm?rmax=30&c=$1"); | |
jsLinks.snapshotItem(i).href = permalink; | |
} | |
} | |
function fix_images(){ | |
var H=["mouseover","mouseout"]; | |
if(document.addEventListener) | |
for(j in H) | |
document.addEventListener(H[j],function(e){e.stopPropagation();},true); | |
} | |
function hide_xpath(path){ | |
node = document.evaluate(path, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null ); | |
node = node.singleNodeValue; | |
if(node){ node.style.display = 'none'; } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment