Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <div id="ig-wrapper"></div>
              
            
!

CSS

              
                html, body {
	background: rgba(250,250,250,1);
	width: 100%; height: 100%;
	padding: 0px; margin: 0px;
	overflow: hidden;
	font-family: arial, sans-serif;
	color: #262626;	
}
h1 {
	text-align: center;
	font-family: arial,sans-serif;
}
h1 i {
	font-size: 0.75em;
	color: #262626;
	cursor: pointer;
}
h1 i:hover {
	color: #c66;
	animation: fa-spin 1s linear infinite;
}
#form-hashtag {
	background-color: transparent;
	border: 0px;
	color: #262626;
	font-size: 1em;
}
#form-hashtag::placeholder {
	font-size: 1rem;
	vertical-align: center;
	padding: 0px 0px 0px 0.5em;
}
.loading-wrapper {
	margin: 0px auto;
}
#ig-wrapper {
	margin: 0px auto;
	display: flex;
	flex-direction: row;
	flex-wrap: wrap;
	justify-content: space-between;
	width: 510px;
	height: 510px;
}
.ig-item {
	position: relative;
	display: block;
	margin: 0px; padding: 5px;
	width: 160px; height: 160px;
	overflow: hidden;
}
.ig-item a {
	position: relative;
	display: block;
	width: 150px; height: 150px;
	margin: 0px; padding: 5px;
	background: #f09433; 
  background: -moz-linear-gradient(45deg, #f09433 0%, #e6683c 25%, #dc2743 50%, #cc2366 75%, #bc1888 100%); 
  background: -webkit-linear-gradient(45deg, #f09433 0%,#e6683c 25%,#dc2743 50%,#cc2366 75%,#bc1888 100%); 
  background: linear-gradient(45deg, #f09433 0%,#e6683c 25%,#dc2743 50%,#cc2366 75%,#bc1888 100%); 
  filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#f09433', endColorstr='#bc1888',GradientType=1 );
}
.ig-item a img {
	border-radius: 0px;
	transition: opacity 0.3s;
/* 	border: 2px solid #cc6; */
}
.ig-item a:hover img {
	opacity: 0.5;
}
.no-result {
	margin: 0px auto;
}
              
            
!

JS

              
                
var settings = {
  hashtag: 'hkcats',
  get: '',
  imageSize: 150,
  limit: 9,
  links: true,
  squareImages: true,
  template: ''
};

function page_init() {
  $("body").prepend("<h1>IG: #<input id='form-hashtag' type='text' value='" + settings.hashtag + "' placeholder='Enter single hashtag, e.g. cats' /> <i class='fas fa-redo' title='Reload'></i></h1>");
  $('#form-hashtag').on('keypress', function (e) {
    console.log("keypress")
    if(e.which === 13){
      fetchIG();           
    }
  });

  fetchIG();
}

function fetchIG() {
  if ($("#form-hashtag").val() == "") {
    return false;
  }
  $(".fa-redo").off('click');
  $("#form-hashtag").attr("disabled", "disabled");
  $("#ig-wrapper").html("<div class='loading-wrapper'><i class='fas fa-2x fa-spinner fa-pulse'></i></div>");
  $.ajax({
    url: "https://www.instagram.com/explore/tags/" + $("#form-hashtag").val() + "/?__a=1",
    success: function (data) {
      $("#ig-wrapper").html("");
      var nodes;
      nodes = data.graphql.hashtag.edge_hashtag_to_media.edges;

      var item_count = nodes.length < settings.limit ? nodes.length : settings.limit;
      console.log("Count: "+item_count);

      for (var i = 0; i < item_count; i++) {
        post = nodes[i].node;
        image = $('<img/>');
        imageUrl = '';
        linkUrl = 'https://www.instagram.com/p/' + post.shortcode + '/';

        if (settings.squareImages) {
          var size; // is an index in an array
          switch (settings.imageSize) {
            case 150:
              size = 0;
              break;
            case 240:
              size = 1;
              break;
            case 320:
              size = 2;
              break;
            case 480:
              size = 3;
              break;
            case 640:
              size = 4;
              break;
          }
          imageUrl = post.thumbnail_resources[size].src;
        } else {
          imageUrl = post.display_url;
        }
        imageDesc = post.edge_media_to_caption.edges[0].node.text;

        image.attr('src', imageUrl);

        if (settings.template == '') {
          if (settings.links) {
            link = $('<a/>', {
              href: linkUrl,
              target: '_blank',
              title: imageDesc
            }).append(image);
            item = $('<div class="ig-item ig-item'+i+'" />').append(link);

            $("#ig-wrapper").append(item);
            $(".ig-item"+i).hide().delay(50*i).fadeIn(300);
          } else {
            $("#ig-wrapper").append(image);
            $(".ig-item"+i).hide().delay(50*i).fadeIn(300);
          }
        } else {
          $("#ig-wrapper").append(buildTemplate(post, imageUrl, linkUrl));
        }
      }
      console.log("click on");
      $(".fa-redo").click(function() {
        console.log("click off");
        $(".fa-redo").off('click');
        fetchIG();
      });
      $("#form-hashtag").removeAttr("disabled");
    },
    error: function (err) {
      switch (err.status) {
        case 404:
          $("#ig-wrapper").html("<div class='no-result'>Sorry, but there was no results for #" + $("#form-hashtag").val() + ". Please try to enter another hashtag.</div>");
          break;
        default:
          $("#ig-wrapper").html("<div class='no-result'>Error occured. Please try again later.</div>");
          break;
      }
      console.log("click on");
      $(".fa-redo").click(function() {
        fetchIG();
      });
      $("#form-hashtag").removeAttr("disabled");

    }
  });
}

$(function () {
  page_init();
});

              
            
!
999px

Console