Last active
December 20, 2015 16:29
-
-
Save jeduan/6162252 to your computer and use it in GitHub Desktop.
Busqueda de departamentos con vanilla js
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
(function(){ | |
//Configuration | |
var colonias = 'Roma Norte,Roma Sur,Cuauhtémoc,Juárez,Del Valle Norte,Narvarte Oriente,Narvarte Poniente,Letrán Valle,Del Valle Sur,Piedad Narvarte,Del Valle Centro,San Pedro de los Pinos,Vertiz Narvarte'.split(','); | |
var sinBusco = true; | |
var util = { | |
$$: function(selector) { | |
return [].slice.call(document.querySelectorAll(selector)) | |
}, | |
closest: function(node, selector) { | |
var currentNode = node; | |
while (currentNode) { | |
if (currentNode.webkitMatchesSelector(selector)) { | |
return currentNode; | |
} else if (!currentNode || !currentNode.ownerDocument || currentNode === document.body) { | |
break; | |
} | |
currentNode = currentNode.parentElement; | |
} | |
return null | |
} | |
} | |
var Tester = function() { | |
this.version = 1 | |
} | |
Tester.prototype.init = function() { | |
if (/segundamano\.(com\.)?mx/.test(document.location.host)) { | |
util.$$('.listing_thumbs_row').forEach(function (row) { | |
var extract = row.querySelector('.listing_row_extract'), | |
location = row.querySelector('.listing_row_location'), | |
extractText = extract.textContent.trim(); | |
if (/Busco/.test(extractText) || /Comparto/.test(extractText)) { | |
row.style.display = 'none'; | |
} | |
if (!~colonias.indexOf(location.textContent.trim())) { | |
row.style.display = 'none'; | |
} | |
}); | |
} | |
} | |
window['yd!'] = new Tester | |
}()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment