Skip to content

Remote jquery selector is a simple function that allows you to select elements on a remote website using simple jquery syntax.

Notifications You must be signed in to change notification settings

Youpinadi/remote-jquery-selector

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Remote jQuery Selector

Remote jquery selector is a simple function that allows you to select elements on a remote website using simple jquery syntax. All you have to do is to add a website url before some selectors and voila!

A live demo can be found here

This is just for fun, of course there is a proxy involved to get the page ;)

You can do lots of cool stuff very quickly:

// generates a random album cover
const cleanTitle = (title) => {
  return title
    .replace(/[A-Z]{2,}/g, '')
    .replace(/[0-9]/g, '')
    .replace(/[\W]+/g, ' ').split(' ').slice(0, 3).join(' ')
}

const generateAlbum = () => {
  $.remote('http://en.wikipedia.org/wiki/Special:Random #firstHeading span, http://www.flickr.com/explore/interesting/7days img.pc_img, http://randomamazonproduct.com .amazon-title')
    .then(($title, $cover, $quote) => {
      var $album = $('.album');
      $album.find('h1').html(cleanTitle($title.text()));
      $album.css({'background-image': 'url("' + $cover.filter(function(x){return x.width >= 240 && x.height >= 240}).attr('src') + '")'});
      $album.find('h3').html(cleanTitle($quote.text()));
    })
}
generateAlbum();

About

Remote jquery selector is a simple function that allows you to select elements on a remote website using simple jquery syntax.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published