Skip to content

Instantly share code, notes, and snippets.

@27Bslash6
Last active December 24, 2015 01:59
Show Gist options
  • Save 27Bslash6/6727471 to your computer and use it in GitHub Desktop.
Save 27Bslash6/6727471 to your computer and use it in GitHub Desktop.
//https://github.com/carhartl/jquery-cookie
!function(a){"function"==typeof define&&define.amd?define(["jquery"],a):a(jQuery)}(function(a){function c(a){if(e.raw)return a;try{return decodeURIComponent(a.replace(b," "))}catch(c){}}function d(a){0===a.indexOf('"')&&(a=a.slice(1,-1).replace(/\\"/g,'"').replace(/\\\\/g,"\\")),a=c(a);try{return e.json?JSON.parse(a):a}catch(b){}}var b=/\+/g,e=a.cookie=function(b,f,g){if(void 0!==f){if(g=a.extend({},e.defaults,g),"number"==typeof g.expires){var h=g.expires,i=g.expires=new Date;i.setDate(i.getDate()+h)}return f=e.json?JSON.stringify(f):String(f),document.cookie=[e.raw?b:encodeURIComponent(b),"=",e.raw?f:encodeURIComponent(f),g.expires?"; expires="+g.expires.toUTCString():"",g.path?"; path="+g.path:"",g.domain?"; domain="+g.domain:"",g.secure?"; secure":""].join("")}for(var j=b?void 0:{},k=document.cookie?document.cookie.split("; "):[],l=0,m=k.length;m>l;l++){var n=k[l].split("="),o=c(n.shift()),p=n.join("=");if(b&&b===o){j=d(p);break}b||void 0===(p=d(p))||(j[o]=p)}return j};e.defaults={},a.removeCookie=function(b,c){return void 0!==a.cookie(b)?(a.cookie(b,"",a.extend({},c,{expires:-1})),!0):!1}});
$(document).ready(function () {
if($.cookie('show-images') === undefined) {
$('img').each(function() {
if($(this).height()>100 && $(this).width()<800) {
if ( $(this).parent().is( "a" ) ) {
$(this).unwrap();
}
$(this).attr({src:'http://www.greenpeace.org/international/Global/international/artwork/climate/2013/SaveTheArctic/blackout.png'})
var imglink = $(this).wrap('<a href="http://www.greenpeace.org/international/blackout/?blackimg">')
.after('<br><small><a href="http://www.greenpeace.org/international/blackout/?blackimg">Want to know why this image is blacked out? Click here.</a></small><br>');
}
})
}
$('a.show-images').click(function () {
$.cookie('show-images',true, { expires: 31, path: '/' });
});
});
<script>
jQuery(document).ready(function() {$.cookie('show-images',true, { expires: 31, path: '/' }); });
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment