I have to say that programmatically being able to show and hide content in a widget is fabulous. I now have a Global > Global Header widget that displays an image and text only when it is the "home" page.
This is how I implemented one widget:
<widgetGH1></widgetGH1>
<script type="text/javascript">
if(location.href === 'https://example.com/') {
$('widgetGH1').html('<img src="//example.com/uploads/image.png"> Site Welcome Text');
}
</script>