Advertisement
S0lll0s

[NSFW] imgimp NFSFW plugin

Mar 26th, 2014
393
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // for github.com/S0lll0s/imgimp
  2. // usage: nfsfw: [albumid/rss link]
  3. // installation: copy link in index.html, update relative to this file
  4. function GenericRssFeed( url ) {
  5.   Feed.call( this, url );
  6.   this.url = (/^rss: (.+)$/i).exec( this.url )[1]
  7.   this.imageexpr = /src="(.+?\.(jpg|png|gif|jpeg))"/i;
  8.   this.loaded = false;
  9. }
  10.  
  11. GenericRssFeed.prototype.createDOM = function () {
  12.   return '<li class="feed"><div class="spacer"><a class="feed-link feed-remove"><i class="fa fa-times fa-3x"></i></a></div><div class="rss">' + this.url + '</div></li>'
  13. };
  14.  
  15. GenericRssFeed.prototype.loadMore = function () {
  16.   if ( this.loaded )
  17.     return true;
  18.   console.log( '[GRSS]: updating...' );
  19.   var $this = this;
  20.   return $.getFeed({
  21.     url: this.url,
  22.     crossDomain: true,
  23.     success: function( feed ) {
  24.       var i = 0;
  25.       for ( i = 0; i < feed.items.length; i++ ) {
  26.         var item = feed.items[i];
  27.         if ( !$this.imageexpr.test( item.description ) )
  28.           continue;
  29.         $this.images.push({
  30.           'title': item.title,
  31.           'imgurl': $this.imageexpr.exec(item.description)[1],
  32.           'descurl': item.link,
  33.           'feed': $this,
  34.           'date': new Date( item.updated )
  35.         });
  36.       }
  37.       console.log( '[GRSS]: +'+i+'['+$this.images.length+']');
  38.         $this.loaded = true;
  39.     },
  40.     error: function( e ) {
  41.       console.log( e.message );
  42.     }
  43.   });
  44. };
  45.  
  46. types.push({
  47.   name: 'genericrss',
  48.   regex: /^rss: (.+)$/i,
  49.   func: GenericRssFeed
  50. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement