Skip to content

Instantly share code, notes, and snippets.

@a-laughlin
Last active October 13, 2015 16:39
Show Gist options
  • Save a-laughlin/88971425d353c884e142 to your computer and use it in GitHub Desktop.
Save a-laughlin/88971425d353c884e142 to your computer and use it in GitHub Desktop.
Hide "The Boston Calendar" Events and remember hidden
// simple bookmarklet to hide events and re-hide them when re-activated
javascript:(function($){
var itemsStr = localStorage.getItem('hiddenItems') || '[]';
var itemsArr = JSON.parse(itemsStr);
var $a = $('li.event h3 a');
$(document).off('click');
$('.hider').remove();
$(document).on('click','.hider',hiderClicked);
itemsArr.forEach(hideItem);
$a.filter(':visible').after('<input class="hider" type="checkbox"/>');
function hideItem(itm){
$a.filter(':contains("'+itm+'")').closest('li').hide();
}
function hiderClicked(evt){
var str = $.trim($(evt.currentTarget).parent().text());
if(itemsArr.indexOf(str)<0){
itemsArr.push(str);
}
localStorage.setItem('hiddenItems',JSON.stringify(itemsArr));
hideItem(str);
}
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment