Only show component if it's the first week of the month

Here’s some JavaScript code you can use to only show a component during the first week of the month.

Date.prototype.getWeekOfMonth = function() {
  var firstWeekday = new Date(this.getFullYear(), this.getMonth(), 1).getDay();
  var offsetDate = this.getDate() + firstWeekday - 1;
  return Math.floor(offsetDate / 7);
};

TB.render('component_ID', function(data) {
    if(new Date().getWeekOfMonth() !== 0){
        data.ele.css('display','none');
    }
    
});

NOTE: Please remember to change ‘component_ID’ to your component ID
image