Add thumbnails to craigslist with jQuery
Published 2013-1-26Watch on YouTube: youtu.be/YmTLu4JksqE
See How to create a bookmarklet (and load jQuery anywhere)!
Full write-up is forthcoming...
Here's the craigslist thumbnail loader we created in class:
(function () {
"use strict";
var spans = [].slice.call($('span.itempx'));
$('.js-thumbnail').remove();
spans.forEach(function (span) {
var $row = $(span).closest('.row')
, rowText = $row.text()
, rowPic = $row.find('.ih').attr('id')
, img = new Image()
;
if (/\bpic\b/.test(rowText)) {
console.log(rowPic);
img.src = rowPic.replace(/^images:/, 'http://images.craigslist.org/');
$(img).width('75px');
$(img).addClass('js-thumbnail');
$row.prepend(img);
}
});
}());
By AJ ONeal
Thanks!
It's really motivating to know that people like you are benefiting
from what I'm doing and want more of it. :)
Did I make your day?
Buy me a coffee
(you can learn about the bigger picture I'm working towards on my patreon page )