Watch 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:

bookmarklet-extra.js:

(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

If you loved this and want more like it, sign up!


Did I make your day?
Buy me a coffeeBuy me a coffee  

(you can learn about the bigger picture I'm working towards on my patreon page )



Published

2013-1-26



Buy me a coffeeBuy me a coffee


  73% of Goal Reached


Want more like this?