Last active
October 13, 2015 16:39
-
-
Save a-laughlin/88971425d353c884e142 to your computer and use it in GitHub Desktop.
Hide "The Boston Calendar" Events and remember hidden
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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